Exemplo n.º 1
0
        public bool Process(WikiDocument doc, TagObj obj)
        {
            WikiHeader summary;
            object     summaryText = obj[SUMMARY];

            if (summaryText != null)
            {
                obj[SUMMARY]  = null;
                summary       = new WikiHeader();
                summary.level = 1;
                summary.name  = PAGENAME;
                string sum = summaryText.ToString();
                if (String.IsNullOrEmpty(sum))
                {
                    sum = PAGENAME;
                }
                summary.text.Add(sum);
                doc.headers.Insert(0, summary);
            }
            WikiHeader head0 = doc.headers.Count > 0 ? doc.headers[0] : null;

            if ((head0 == null) || (!head0.name.Equals(PAGENAME)))
            {
                summary       = new WikiHeader();
                summary.level = 1;
                summary.name  = PAGENAME;
                summary.text.Add(PAGENAME);
                doc.headers.Insert(0, summary);
            }
            return(true);
        }
Exemplo n.º 2
0
        public bool Process(WikiDocument doc, TagObj obj)
        {
            WikiHeader contact;

            contact = doc.FindHeader("Contact Information");
            if (contact != null)
            {
                int i = 0;
                while (i < contact.text.Count)
                {
                    string line = contact.text[i];
                    if (!String.IsNullOrEmpty(line))
                    {
                        if (line.StartsWith(":"))
                        {
                            line = line.Trim().Substring(1);
                            if (String.IsNullOrEmpty(line))
                            {
                                contact.text.RemoveAt(i);
                                continue;
                            }
                            if (line.StartsWith("Tel:"))
                            {
                                string tel = line.Substring("Tel:".Length).Trim();
                                if (String.IsNullOrEmpty(tel))
                                {
                                    contact.text.RemoveAt(i);
                                    continue;
                                }
                            }
                            else if (line.StartsWith("Fax:"))
                            {
                                string tel = line.Substring("Fax:".Length).Trim();
                                if (String.IsNullOrEmpty(tel))
                                {
                                    contact.text.RemoveAt(i);
                                    continue;
                                }
                            }
                            else if (line.StartsWith("Info:"))
                            {
                                string tel = line.Substring("Info:".Length).Trim();
                                if (String.IsNullOrEmpty(tel))
                                {
                                    contact.text.RemoveAt(i);
                                    continue;
                                }
                            }
                        }
                        else if (line.EndsWith("http://"))
                        {
                            contact.text[i] = line.Substring(0, line.Length - "http://".Length);
                        }
                    }
                    i++;
                }
            }
            return(true);
        }
Exemplo n.º 3
0
 public bool Process(WikiDocument doc)
 {
     ProcessHeader(doc.rowData);
     foreach (WikiHeader header in doc.headers)
     {
         ProcessHeader(header);
     }
     return(true);
 }
Exemplo n.º 4
0
 public void Process(WikiDocument doc, WikiMedia.ExportNotify notify)
 {
     foreach (string name in blacklist)
     {
         WikiHeader header = doc.FindHeader(name);
         if (header != null)
         {
             notify("E\t" + doc.title + "\tInvalid header: " + name + "\n");
         }
     }
 }
Exemplo n.º 5
0
        public bool Process(WikiDocument doc)
        {
            TagObj obj = new TagObj(doc);

            for (int i = 0; i < fixes.Length; i++)
            {
                fixes[i].Process(doc, obj);
            }
            obj.Update();
            return(true);
        }
Exemplo n.º 6
0
 public void Process(WikiDocument doc, WikiMedia.ExportNotify notify)
 {
     foreach (string name in requiredNames)
     {
         WikiHeader header = doc.FindHeader(name);
         if (header == null)
         {
             notify("E\t" + doc.title + "\tMissing header: " + name + "\n");
         }
     }
 }
Exemplo n.º 7
0
        public bool Process(WikiDocument doc, TagObj obj)
        {
            string str = obj[STATUS_STR];
            Status status;

            try {
                status = (Status)Enum.Parse(typeof(Status), str.ToString().ToUpper());
            }
            catch {
                status = Status.UNKNOWN;
            }
            obj[STATUS_STR] = status.ToString().ToUpper();
            return(true);
        }
Exemplo n.º 8
0
        public void Process(WikiDocument doc, WikiMedia.ExportNotify notify)
        {
            WikiHeader header;

            header = doc.FindHeader("Contact Information");
            if (header != null)
            {
                foreach (string line in header.text)
                {
                    if (line.EndsWith("http://"))
                    {
                        notify("E\t" + doc.title + "\tInvalid header: Contact Information\n");
                    }
                }
            }
        }
Exemplo n.º 9
0
        public bool Process(WikiDocument doc, TagObj obj)
        {
            string val = obj[field];

            if (!String.IsNullOrEmpty(val))
            {
                string newVal = null;
                mapping.TryGetValue(val, out newVal);
                if (String.IsNullOrEmpty(newVal))
                {
                    newVal = val;
                }
                obj[field] = newVal;
            }
            return(true);
        }
Exemplo n.º 10
0
 public bool Process(WikiDocument doc)
 {
     for (int i = doc.headers.Count - 1; i >= 0; i--)
     {
         WikiHeader header = doc.headers[i];
         if (header.text.Count == 0)
         {
             int nextLev = header.level;
             if (i < doc.headers.Count - 1)
             {
                 nextLev = doc.headers[i + 1].level;
             }
             if (header.level >= nextLev)
             {
                 doc.headers.RemoveAt(i);
             }
         }
     }
     return(true);
 }
Exemplo n.º 11
0
 public void Process(string[] pages, string[,] replaces, WikiProcessor[] procs, WikiErrorCheck[] checks, bool preview, bool save, WikiMedia.ExportNotify notify)
 {
     Regex[] re = CalcRegex(replaces);
     foreach (string pageName in pages)
     {
         if (!String.IsNullOrEmpty(pageName))
         {
             Page page = new Page(site, pageName);
             page.Load();
             if (!String.IsNullOrEmpty(page.text))
             {
                 string text = page.text.Trim();
                 page.text = text;
                 text      = DoRegex(page.text, re, replaces);
                 WikiDocument doc = new WikiDocument(pageName, text);
                 foreach (WikiProcessor p in procs)
                 {
                     p.Process(doc);
                 }
                 foreach (WikiErrorCheck check in checks)
                 {
                     check.Process(doc, notify);
                 }
                 text = doc.ToString().Trim();
                 if (!text.Equals(page.text))
                 {
                     notify("W\t" + pageName + "\tchanged \n");
                     if (preview)
                     {
                         char[]     sep     = { '\n' };
                         IDiffList  oldText = new DiffList_String(page.text, sep);
                         IDiffList  newText = new DiffList_String(text, sep);
                         double     time    = 0;
                         DiffEngine de      = new DiffEngine();
                         time = de.ProcessDiff(oldText, newText);
                         ArrayList rep = de.DiffReport();
                         Results   dlg = new Results(oldText, newText, rep, time);
                         dlg.Size          = new Size(1000, 700);
                         dlg.ShowInTaskbar = false;
                         dlg.StartPosition = FormStartPosition.Manual;
                         dlg.ShowDialog();
                         dlg.Dispose();
                     }
                     if (save)
                     {
                         try {
                             page.text = text;
                             page.Save();
                         }
                         catch (Exception e) {
                             notify("E\t" + pageName + "\t" + e.Message + "\n");
                         }
                     }
                 }
                 else
                 {
                     notify("N\t" + pageName + "\t\n");
                 }
             }
             else
             {
                 notify("I\t" + pageName + "\t\n");
             }
         }
     }
 }
Exemplo n.º 12
0
 public TagObj(WikiDocument doc)
 {
     this.doc = doc;
     ReadObj();
 }