Пример #1
0
		private void generateNewWiki(string wikiname, IMvcContext context, IWikiRepository repo)
		{
			var executor = context.Application.MvcFactory.GetAction(context);
			try {
				var sb = new StringBuilder();
				sb.AppendFormat("<h1>JSONAPI: {0}</h1>", context.ActionName);
				sb.AppendFormat("<ul><li>{0}</li></ul>", executor.GetType().FullName);

				sb.AppendLine("<p>Документация на данный момент отсутствует. Данный файл сформирован автоматически</p>");
				var page = new WikiPage
				           	{
				           		Level = FileLevel.sys,
				           		Code = wikiname,
				           		Content = sb.ToString(),
				           		Properties = new Dictionary<string, string>
				           		             	{
				           		             		{"type", "quickdoc"},
				           		             		{"quickname", context.ActionName},
				           		             	}
				           	};
				repo.Save(page);
			}finally {
				context.Application.MvcFactory.ReleaseAction(context);
			}
		}
Пример #2
0
 public string Render(WikiPage page) {
    
     var current = page.Content;
     foreach (var render in renders) {
         current = render.Render(page, current);
     }
     return current;
 }
Пример #3
0
 public void Save(WikiPage page) {
     lock (this) {
         //Rerender(page);
         Persister.Write(page);
         
         
     }   
 }
Пример #4
0
 public void set(string code, string  content, string  level) {
     var page = Repository.Get(code);
     if(null==page) {
         page = new WikiPage {Code = code};
     }
     FileLevel _level;
     FileLevel.TryParse(level,out _level);
     page.Level = _level;
     page.Content = content;
     Repository.Save(page);
     RenderText("OK");
 }
Пример #5
0
 public string Render(WikiPage page, string currentcontent) {
     string finder = StandardWikiFormats.GetLinkFinder(Folder);
     currentcontent = currentcontent.replace(finder,
                                             m =>
                                                 {
                                                     string code = m.Groups["code"].Value;
                                                     string title = m.Groups["title"].Value;
                                                     bool existed = Repository.Exists(code);
                                                     return formatLink(code, title, existed);
                                                 }
         );
     return currentcontent;
 }
 private WikiPage internalLoad(string code) {
     var path = getPath(code);
     if (myapp.files.Exists(path)) {
         
         var content = myapp.files.Read(path);
         IDictionary<string, string> tags = extractTags(content);
         var result = new WikiPage();
         result.Code = code;
         result.Level = IoExtensions.GetLevel(FilePathResolverExtensions.Resolve(myapp.files, path));
         result.Content = content;
         result.FilePath = myapp.files.Resolve(path, true);
         result.LastWriteTime = File.GetLastWriteTime(result.FilePath);
         foreach (var t in tags) {
             result.Properties[t.Key] = t.Value;
         }
         return result;
     }
     return null;
 }
Пример #7
0
 public WikiPage Refresh(WikiPage page) {
     Persister.Reload(true,page.Code);
     return Persister.Load(page.Code);
     
 }
Пример #8
0
 public void Rerender(WikiPage page) {
     lock (this) {
         page.RenderedContent = null;
         page.RenderedContent = Render.Start().Render(page);
     }
 }
Пример #9
0
 public string render(WikiPage page)
 {
     return this.wrender.Render(page);
 }
Пример #10
0
		public void write(WikiPage page) {
			this.OutputStream.Write(this.workrender.Render(page));
		}
 private string getWritePath(WikiPage page) {
     if(page.Code.StartsWith("-")) {
         return "~/extensions/" + page.Code.Substring(1) + ".wiki.html";
     }
     return "~/" + page.Level + "/wiki/" + page.Code + ".html";
 }
 public void Write(WikiPage page) {
     Reload(false);
     var path = getWritePath(page);
     
     var existedtags = extractTags(page.Content);
     foreach (var existedtag in existedtags) {
        // if(!page.Properties.ContainsKey(existedtag.Key)) {
             page.Properties[existedtag.Key] = existedtag.Value;
         //}
     }
     if(!page.Content.Contains("<!--@@")) {
         page.Content = "<!--@@ -->"+ page.Content;
     }
     page.Content = page.Content.replace(@"\<\!--@@[\s\S]*? --\>",
                                         "<!--@@ \r\n" + TagHelper.ToString(page.Properties).Replace("/ /","/\r\n/") + "\r\n -->\r\n");
     myapp.files.Write(path, page.Content);
     var filepath = myapp.files.Resolve(path, true);
     page.FilePath = filepath;
     page.LastWriteTime = DateTime.Now;
     cache[page.Code] = page;
 }