예제 #1
0
파일: Program.cs 프로젝트: sbyse/icklewik
        static void Main(string[] args)
        {
            string scanDirectory = Path.GetFullPath(args[0]);
            string outputDirectory = Path.GetFullPath(args[1]);

            Convertor convertor = new Convertor(new MarkdownSharpDialogue());
            WikiSite site = new WikiSite(
                new WikiConfig()
                {
                    SiteName = "Tester",
                    RootSourcePath = scanDirectory,
                    RootWikiPath = outputDirectory,
                    Convertor = new Convertor(new MarkdownSharpDialogue())
                },
                new MasterRepository(convertor.FileExtension),
                new NullSourceWatcher(),
                new PageCache());

            site.InitialisationComplete += site_InitialisationComplete;

            site.Start();

            waitHandle.WaitOne();

            site.Dispose();

            Console.Write("Done");
        }
예제 #2
0
        public TestWikiSite()
        {
            // setup initial site structure
            Directory.CreateDirectory(Path.Combine(".", "subdir1"));
            Directory.CreateDirectory(Path.Combine(".", "subdir1", "subdir2"));
            Directory.CreateDirectory(Path.Combine(".", "subdir1", "subdir2", "subdir3"));
            Directory.CreateDirectory(Path.Combine(".", "subdir1", "subdir2", "subdir3", "subdir4"));
            System.IO.File.AppendAllText(Path.Combine(".", "index.md"), "Hello World");
            System.IO.File.AppendAllText(Path.Combine(".", "subdir1", "index.md"), "Hello World Sub Directory");
            System.IO.File.AppendAllText(Path.Combine(".", "subdir1", "subdir2", "index.md"), "Hello World Sub Sub Directory");

            createdDirectories = new List<string>();
            updatedDirectories = new List<string>();
            deletedDirectories = new List<string>();
            movedDirectories = new List<string>();

            createdPages = new List<string>();
            updatedPages = new List<string>();
            deletedPages = new List<string>();
            movedPages = new List<string>();

            Convertor convertor = new Convertor(new MarkdownSharpDialogue());
            WikiConfig wikiConfig = new WikiConfig()
                {
                    SiteName = "Tester",
                    RootSourcePath = PathHelper.GetFullPath("."),
                    RootWikiPath = PathHelper.GetFullPath(".", "wiki"),
                    Convertor = new Convertor(new MarkdownSharpDialogue())
                };

            site = new WikiSite(wikiConfig,
                new MasterRepository(convertor.FileExtension),
                new SourceWatcher(wikiConfig.RootSourcePath, wikiConfig.Convertor.FileSearchString),
                new PageCache()
            );

            // setup event handlers
            site.DirectoryAdded += (source, args) => createdDirectories.Add(args.WikiUrl);
            site.DirectoryUpdated += (source, args) => updatedDirectories.Add(args.WikiUrl);
            site.DirectoryDeleted += (source, args) => deletedDirectories.Add(args.WikiUrl);
            site.DirectoryMoved += (source, args) => movedDirectories.Add(args.WikiUrl);

            site.PageAdded += (source, args) => createdPages.Add(args.WikiUrl);
            site.PageUpdated += (source, args) => updatedPages.Add(args.WikiUrl);
            site.PageDeleted += (source, args) => deletedPages.Add(args.WikiUrl);
            site.PageMoved += (source, args) => movedPages.Add(args.WikiUrl);

            site.Start();

            Thread.Sleep(1000);
        }