示例#1
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Usage();
                return;
            }
            string fsPath = args[0];
            string topic = null;
            if (args.Length > 1)
                topic = args[1];
            LinkMaker lm = new LinkMaker("http://dummy");

            PrintTopicApplication application = new PrintTopicApplication(fsPath, lm);
            Federation fed = new Federation(application);
            if (topic != null)
                Print(fed, new TopicName(topic));
            else
            {
                int max = 10;
                foreach (TopicName top in fed.DefaultNamespaceManager.AllTopics(ImportPolicy.DoNotIncludeImports))
                {
                    Print(fed, top);
                    if (max-- <= 0)
                        break;
                }
            }
        }
示例#2
0
		static void Main(string[] args)
		{
			if (args.Length < 1)
			{
				Usage();
				return;
			}
			string fsPath = args[0];
			string topic = null;
			if (args.Length > 1)
				topic = args[1];
			LinkMaker lm = new LinkMaker("http://dummy");

			Federation fed = new Federation(fsPath, OutputFormat.HTML, lm);
			fed.EnableCaching();
			if (topic != null)
				Print(fed, new AbsoluteTopicName(topic));
			else
			{
				int max = 10;
				foreach (AbsoluteTopicName top in fed.DefaultContentBase.AllTopics(false))
				{
					Print(fed, top);
					if (max-- <= 0)
						break;
				}
			}
		}
示例#3
0
		[SetUp] public void Init()
		{
			// Dump the contents of the embedded resources to a file so we can read them 
			// in during the tests. 
			meerkatRssPath = Path.GetFullPath("meerkat.rss.xml"); 
			testRssXmlPath = Path.GetFullPath("rsstest.xml"); 
			testRssXslPath = Path.GetFullPath("rsstest.xsl"); 
			Assembly a = Assembly.GetExecutingAssembly(); 
			WriteResourceToFile(a, "FlexWiki.UnitTests.TestContent.meerkat.rss.xml", meerkatRssPath); 
			WriteResourceToFile(a, "FlexWiki.UnitTests.TestContent.rsstest.xml", testRssXmlPath); 
			WriteResourceToFile(a, "FlexWiki.UnitTests.TestContent.rsstest.xsl", testRssXslPath); 

			_lm = new LinkMaker(_base);
			TheFederation = new Federation(OutputFormat.HTML, _lm);
			TheFederation.WikiTalkVersion = 1;

			_cb = CreateStore("FlexWiki");
			_cb.Title  = "Friendly Title";

			WriteTestTopicAndNewVersion(_cb, "HomePage", "Home is where the heart is", user);
			WriteTestTopicAndNewVersion(_cb, "BigPolicy", "This is ", user);
			WriteTestTopicAndNewVersion(_cb, "BigDog", "This is ", user);
			WriteTestTopicAndNewVersion(_cb, "BigAddress", "This is ", user);
			WriteTestTopicAndNewVersion(_cb, "BigBox", "This is ", user);
			WriteTestTopicAndNewVersion(_cb, "IncludeOne", "inc1", user);
			WriteTestTopicAndNewVersion(_cb, "IncludeTwo", "!inc2", user);
			WriteTestTopicAndNewVersion(_cb, "IncludeThree", "!!inc3", user);
			WriteTestTopicAndNewVersion(_cb, "IncludeFour", "!inc4", user);
			WriteTestTopicAndNewVersion(_cb, "IncludeNest", @"		{{IncludeNest1}}
			{{IncludeNest2}}", user);
			WriteTestTopicAndNewVersion(_cb, "TopicWithColor", "Color: Yellow", user);
			WriteTestTopicAndNewVersion(_cb, "IncludeNest1", "!hey there", user);
			WriteTestTopicAndNewVersion(_cb, "IncludeNest2", "!black dog", user);
			WriteTestTopicAndNewVersion(_cb, "IncludeNestURI", @"wiki://IncludeNest1 wiki://IncludeNest2 ", user);
			WriteTestTopicAndNewVersion(_cb, "ResourceReference", @"URI: http://www.google.com/$$$", user);
			WriteTestTopicAndNewVersion(_cb, "FlexWiki", "flex ", user);
			WriteTestTopicAndNewVersion(_cb, "InlineTestTopic", @"aaa @@""foo""@@ zzz", user);
			WriteTestTopicAndNewVersion(_cb, "OneMinuteWiki", "one ", user);
			WriteTestTopicAndNewVersion(_cb, "TestIncludesBehaviors", "@@ProductName@@ somthing @@Now@@ then @@Now@@", user);
			WriteTestTopicAndNewVersion(_cb, "_Underscore", "Underscore", user);
			WriteTestTopicAndNewVersion(_cb, "TopicWithBehaviorProperties", @"
Face: {""hello"".Length}
one 
FaceWithArg: {arg | arg.Length }
FaceSpanningLines:{ arg |

arg.Length 

}

", user);
			WriteTestTopicAndNewVersion(_cb, "TestTopicWithBehaviorProperties", @"
len=@@topics.TopicWithBehaviorProperties.Face@@
lenWith=@@topics.TopicWithBehaviorProperties.FaceWithArg(""superb"")@@
lenSpanning=@@topics.TopicWithBehaviorProperties.FaceSpanningLines(""parsing is wonderful"")@@
", user);


			_externals = new Hashtable();
		}
示例#4
0
 public void SetUp()
 {
     _lm = new LinkMaker(_bh);
     MockWikiApplication application = new MockWikiApplication(null, _lm, OutputFormat.HTML, 
         new MockTimeProvider(TimeSpan.FromSeconds(1))); 
     Federation = new Federation(application);
 }
        public MockWikiApplication(LinkMaker linkMaker,
            OutputFormat outputFormat)
        {
            _linkMaker = linkMaker;
            _ouputFormat = outputFormat;

            LoadConfiguration();
        }
 public MockWikiApplication(FederationConfiguration configuration, LinkMaker linkMaker,
     OutputFormat outputFormat, ITimeProvider timeProvider)
 {
     _configuration = configuration;
     _linkMaker = linkMaker;
     _ouputFormat = outputFormat;
     _timeProvider = timeProvider;
 }
示例#7
0
 public NewsletterManager(Federation aFed, LinkMaker lm, IDeliveryBoy boy, string newslettersFrom, string headInsert)
 {
     _LinkMaker = lm;
     _NewslettersFrom = newslettersFrom;
     _Federation = aFed;
     _DeliveryBoy = boy;
     _HeadInsert = headInsert;
 }
示例#8
0
		/// <summary>
		/// Answer the formatted text for a given topic, formatted using a given OutputFormat and possibly showing diffs with the previous revision
		/// </summary>
		/// <param name="topic">The topic</param>
		/// <param name="format">What format</param>
		/// <param name="showDiffs">true to show diffs</param>
		/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
		/// <returns></returns>
		public static string FormattedTopic(AbsoluteTopicName topic, OutputFormat format, bool showDiffs, Federation aFederation, LinkMaker lm, CompositeCacheRule accumulator)
		{ 
		
			// Show the current topic (including diffs if there is a previous version)
			AbsoluteTopicName previousVersion = null;
			ContentBase relativeToBase = aFederation.ContentBaseForNamespace(topic.Namespace);

			if (showDiffs)
				previousVersion = relativeToBase.VersionPreviousTo(topic.LocalName);

			return FormattedTopicWithSpecificDiffs(topic, format, previousVersion, aFederation, lm, accumulator);
		}
示例#9
0
		/// <summary>
		/// Format a string of wiki content in a given OutputFormat with references all being relative to a given namespace
		/// </summary>
		/// <param name="input">The input wiki text</param>
		/// <param name="format">The desired output format</param>
		/// <param name="relativeToContentBase">References will be relative to this namespace</param>
		/// <param name="lm">Link maker (unless no relativeTo content base is provide)</param>
		/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
		/// <returns></returns>
		public static string FormattedString(string input, OutputFormat format, ContentBase relativeToContentBase, LinkMaker lm, CompositeCacheRule accumulator)
		{
			// TODO -- some of the cases in which this call happens actually *are* nested, even though the false arg
			// below says that they aren't.  This causes scripts to be emitted multiple times -- should clean up.
			WikiOutput output = WikiOutput.ForFormat(format, null);	
			Hashtable ew;
			if (relativeToContentBase != null)
				ew = relativeToContentBase.ExternalWikiHash();
			else
				ew = new Hashtable();
			Format(null, input, output, relativeToContentBase, lm, ew, 0, accumulator);
			return output.ToString();
		}
示例#10
0
文件: Wiki.cs 项目: zi-yu/orionsbelt
        private static FlexWiki.Federation GetFederation()
        {
            object obj = HttpContext.Current.Application["---FEDERATION---"];

            if (obj == null)
            {
                string              path = GetFederationFile();
                FlexWiki.LinkMaker  lm   = new FlexWiki.LinkMaker(string.Format("{0}wiki/", OrionGlobals.AlnitakUrl));
                FlexWiki.Federation fed  = new FlexWiki.Federation(path, FlexWiki.Formatting.OutputFormat.HTML, lm);
                HttpContext.Current.Application["---FEDERATION---"] = fed;
                return(fed);
            }

            return((FlexWiki.Federation)obj);
        }
示例#11
0
		static public IWikiToPresentation WikiToPresentation(AbsoluteTopicName topic, WikiOutput output, ContentBase contentBase, LinkMaker maker, Hashtable external, int headingLevelBase, CompositeCacheRule accumulator)
		{
			ArrayList lines = new ArrayList();
			lines.Add(new StyledLine("", LineStyle.Unchanged));
			return new Formatter(topic, lines, output, contentBase, maker, external,  headingLevelBase, accumulator);
		}
示例#12
0
		/// <summary>
		/// Create a new formatter for a string of input content.
		/// </summary>
		/// <param name="source">Input wiki string</param>
		/// <param name="output">Output object to which output is sent</param>
		/// <param name="contentBase">The ContentBase that contains the wiki string text</param>
		/// <param name="maker">A link maker </param>
		/// <param name="external">External wiki map</param>
		/// <param name="headingLevelBase">Relative heading level</param>
		/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
		/// 
		Formatter(AbsoluteTopicName topic, string source, WikiOutput output, ContentBase contentBase, LinkMaker maker, Hashtable external, int headingLevelBase, CompositeCacheRule accumulator)
		{
			_Topic = topic;
			_Source = SplitStringIntoStyledLines(source, LineStyle.Unchanged);
			_LinkMaker = maker;	
			ContentBase = contentBase;
			_Output = output;
			_ExternalWikiMap = external;
			_HeadingLevelBase = headingLevelBase;
			_CacheRuleAccumulator = accumulator;
		}
示例#13
0
        public void Init()
        {
            _lm = new LinkMaker(_base);
            MockWikiApplication application = new MockWikiApplication(
                null,
                _lm,
                OutputFormat.HTML,
                new MockTimeProvider(TimeSpan.FromSeconds(1)));

            Federation = new Federation(application);
            Federation.WikiTalkVersion = 1;

            _namespaceManager = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki");
            //_namespaceManager.Title  = "Friendly Title";

            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "HomePage", "Home is where the heart is", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "BigPolicy", "This is ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "BigDog", "This is ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "BigAddress", "This is ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "BigBox", "This is ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeOne", "inc1", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeTwo", "!inc2", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeThree", "!!inc3", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeFour", "!inc4", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeNest", @"		{{IncludeNest1}}
            {{IncludeNest2}}", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TopicWithColor", "Color: Yellow", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeNest1", "!hey there", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeNest2", "!black dog", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeNestURI", @"wiki://IncludeNest1 wiki://IncludeNest2 ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "ResourceReference", @"URI: http://www.google.com/$$$", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "FlexWiki", "flex ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "InlineTestTopic", @"aaa @@""foo""@@ zzz", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "OneMinuteWiki", "one ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TestIncludesBehaviors", "@@ProductName@@ somthing @@Now@@ then @@Now@@", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "_Underscore", "Underscore", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TopicWithBehaviorProperties", @"
            Face: {""hello"".Length}
            one
            FaceWithArg: {arg | arg.Length }
            FaceSpanningLines:{ arg |

            arg.Length

            }

            ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TestTopicWithBehaviorProperties", @"
            len=@@topics.TopicWithBehaviorProperties.Face@@
            lenWith=@@topics.TopicWithBehaviorProperties.FaceWithArg(""superb"")@@
            lenSpanning=@@topics.TopicWithBehaviorProperties.FaceSpanningLines(""parsing is wonderful"")@@
            ", user);

            _externals = new ExternalReferencesMap();
        }
示例#14
0
		/// <summary>
		/// Format a given input string to the given output
		/// </summary>
		/// <param name="source">Input wiki content as a list of StyledLines</param>
		/// <param name="output">Output object to which output is sent</param>
		/// <param name="contentBase">The ContentBase that contains the wiki string text</param>
		/// <param name="maker">A link maker </param>
		/// <param name="external">External wiki map</param>
		/// <param name="headingLevelBase">Relative heading level</param>
		/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
		/// 
		static public void Format(AbsoluteTopicName topic, IList source, WikiOutput output, ContentBase contentBase, LinkMaker maker, Hashtable external, int headingLevelBase, CompositeCacheRule accumulator)
		{
			Formatter f = new Formatter(topic, source, output, contentBase, maker, external, headingLevelBase, accumulator);
			f.Format();
		}
    private void WriteNewTopic(AbsoluteTopicName theTopic, string postedTopicText, string visitorIdentityString, string version)
		{
			_linkMaker = new LinkMaker(RootUrl(Context.Request));

			AbsoluteTopicName newVersionName = new AbsoluteTopicName(theTopic.Name, theTopic.Namespace);
			newVersionName.Version = TopicName.NewVersionStringForUser(visitorIdentityString);
			TheFederation.ContentBaseForTopic(newVersionName).WriteTopicAndNewVersion(newVersionName.LocalName, postedTopicText);
		}
    private string InternalGetHtmlForTopic(AbsoluteTopicName topicName, string version)
    {
      _linkMaker = new LinkMaker(RootUrl(Context.Request));

      if (version != null && version == topicName.Version)
      {
        return FlexWiki.Formatting.Formatter.FormattedTopic(topicName, Formatting.OutputFormat.HTML, null,  TheFederation, _linkMaker, null);
      }
      else
      {
        IEnumerable changeList;
        changeList = TheFederation.ContentBaseForTopic(topicName).AllChangesForTopic(topicName.LocalName);

        foreach (TopicChange change in changeList)
        {
          if (change.Version == version)
          {
            return FlexWiki.Formatting.Formatter.FormattedTopic(change.Topic, Formatting.OutputFormat.HTML, null,  TheFederation, _linkMaker, null);
          }
        }

        return FlexWiki.Formatting.Formatter.FormattedTopic(topicName, Formatting.OutputFormat.HTML, null,  TheFederation, _linkMaker, null);
      }
    }
示例#17
0
        /// <summary>
        /// Answer the formatted text for a given topic, formatted using a given OutputFormat and possibly showing diffs
        /// with a specified revision
        /// </summary>
        /// <param name="topic">The topic</param>
        /// <param name="format">What format</param>
        /// <param name="showDiffs">true to show diffs</param>
        /// <param name="accumulator">composite cache rule in which to accumulate cache rules (ignored for diffs)</param>
        /// <returns></returns>
        public static string FormattedTopicWithSpecificDiffs(QualifiedTopicRevision topic, OutputFormat format, QualifiedTopicRevision diffWithThisVersion, Federation aFederation, LinkMaker lm)
        {
            // Setup a special link maker that knows what to make the edit links return to
            LinkMaker linker = lm.Clone();
            linker.ReturnToTopicForEditLinks = topic;
            NamespaceManager relativeToBase = aFederation.NamespaceManagerForNamespace(topic.Namespace);

            WikiOutput output = WikiOutput.ForFormat(format, null);
            if (diffWithThisVersion != null)
            {
                ArrayList styledLines = new ArrayList();
                IList leftLines;
                IList rightLines;
                using (TextReader srLeft = relativeToBase.TextReaderForTopic(topic.AsUnqualifiedTopicRevision()))
                {
                    leftLines = MergeBehaviorLines(srLeft.ReadToEnd().Replace("\r", "").Split('\n'));
                }
                using (TextReader srRight = relativeToBase.TextReaderForTopic(diffWithThisVersion.AsUnqualifiedTopicRevision()))
                {
                    rightLines = MergeBehaviorLines(srRight.ReadToEnd().Replace("\r", "").Split('\n'));
                }
                IEnumerable diffs = Diff.Compare(leftLines, rightLines);
                foreach (LineData ld in diffs)
                {
                    LineStyle style = LineStyle.Unchanged;
                    switch (ld.Type)
                    {
                        case LineType.Common:
                            style = LineStyle.Unchanged;
                            break;

                        case LineType.LeftOnly:
                            style = LineStyle.Add;
                            break;

                        case LineType.RightOnly:
                            style = LineStyle.Delete;
                            break;
                    }
                    styledLines.Add(new StyledLine(ld.Text, style));
                }
                Format(topic, styledLines, output, relativeToBase, linker, relativeToBase.ExternalReferences, 0);
            }
            else
            {
                using (TextReader sr = relativeToBase.TextReaderForTopic(topic.AsUnqualifiedTopicRevision()))
                {
                    Format(topic, sr.ReadToEnd(), output, relativeToBase, linker, relativeToBase.ExternalReferences, 0);
                }
            }

            return output.ToString();
        }
示例#18
0
 /// <summary>
 /// Format a string of wiki content in a given OutputFormat with references all being relative to a given namespace
 /// </summary>
 /// <param name="topic">Topic context</param>
 /// <param name="input">The input wiki text</param>
 /// <param name="format">The desired output format</param>
 /// <param name="relativeToContentStore">References will be relative to this namespace</param>
 /// <param name="lm">Link maker (unless no relativeTo content base is provide)</param>
 /// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
 /// <returns></returns>
 public static string FormattedString(QualifiedTopicRevision topic, string input, OutputFormat format, NamespaceManager relativeToContentStore, LinkMaker lm)
 {
     // TODO -- some of the cases in which this call happens actually *are* nested, even though the false arg
     // below says that they aren't.  This causes scripts to be emitted multiple times -- should clean up.
     WikiOutput output = WikiOutput.ForFormat(format, null);
     ExternalReferencesMap ew;
     if (relativeToContentStore != null)
     {
         ew = relativeToContentStore.ExternalReferences;
     }
     else
     {
         ew = new ExternalReferencesMap();
     }
     Format(topic, input, output, relativeToContentStore, lm, ew, 0);
     return output.ToString();
 }
示例#19
0
 /// <summary>
 /// Create a new formatter for an input list of StyledLines
 /// </summary>
 /// <param name="source">Input wiki content as a list of StyledLines</param>
 /// <param name="output">Output object to which output is sent</param>
 /// <param name="namespaceManager">The ContentProviderChain that contains the wiki string text</param>
 /// <param name="maker">A link maker </param>
 /// <param name="external">External wiki map</param>
 /// <param name="headingLevelBase">Relative heading level</param>
 /// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
 /// 
 Formatter(QualifiedTopicRevision topic, IList source, WikiOutput output, NamespaceManager namespaceManager,
     LinkMaker maker, ExternalReferencesMap external, int headingLevelBase)
 {
     _topic = topic;
     _source = source;
     _output = output;
     _linkMaker = maker;
     NamespaceManager = namespaceManager;
     _externalWikiMap = external;
     _headingLevelBase = headingLevelBase;
 }
示例#20
0
		/// <summary>
		/// Answer the formatted text for a given topic, formatted using a given OutputFormat and possibly showing diffs
		/// with a specified revision
		/// </summary>
		/// <param name="topic">The topic</param>
		/// <param name="format">What format</param>
		/// <param name="showDiffs">true to show diffs</param>
		/// <param name="accumulator">composite cache rule in which to accumulate cache rules (ignored for diffs)</param>
		/// <returns></returns>
		public static string FormattedTopicWithSpecificDiffs(AbsoluteTopicName topic, OutputFormat format, AbsoluteTopicName diffWithThisVersion, Federation aFederation, LinkMaker lm, CompositeCacheRule accumulator)
		{ 

			// Setup a special link maker that knows what to make the edit links return to 
			LinkMaker linker = lm.Clone();
			linker.ReturnToTopicForEditLinks = topic;
			ContentBase relativeToBase = aFederation.ContentBaseForNamespace(topic.Namespace);

			if (accumulator != null)
				accumulator.Add(relativeToBase.CacheRuleForAllPossibleInstancesOfTopic(topic));
			WikiOutput output = WikiOutput.ForFormat(format, null);
			if (diffWithThisVersion != null)
			{
				ArrayList styledLines = new ArrayList();
				IList leftLines;
				IList rightLines;
				using (TextReader srLeft = relativeToBase.TextReaderForTopic(topic.LocalName))
				{
					leftLines = MergeBehaviorLines(srLeft.ReadToEnd().Replace("\r", "").Split('\n'));
				}
				using (TextReader srRight = relativeToBase.TextReaderForTopic(diffWithThisVersion.LocalName))
				{
					rightLines = MergeBehaviorLines(srRight.ReadToEnd().Replace("\r", "").Split('\n'));
				}
				IEnumerable diffs = Diff.Compare(leftLines, rightLines);
				foreach (LineData ld in diffs)
				{ 
					LineStyle style = LineStyle.Unchanged;
					switch (ld.Type)
					{
						case LineType.Common:
							style = LineStyle.Unchanged;
							break;

						case LineType.LeftOnly:
							style = LineStyle.Add;
							break;

						case LineType.RightOnly:
							style = LineStyle.Delete;
							break;
					}
					styledLines.Add(new StyledLine(ld.Text, style));
				}
				Format(topic, styledLines, output, relativeToBase, linker, relativeToBase.ExternalWikiHash(), 0, accumulator);
			}
			else
			{
				using (TextReader sr = relativeToBase.TextReaderForTopic(topic.LocalName))
				{
					Format(topic, sr.ReadToEnd(), output, relativeToBase, linker, relativeToBase.ExternalWikiHash(), 0, accumulator);
				}
			}

			return output.ToString();
		}
示例#21
0
		/// <summary>
		/// Create a new formatter for an input list of StyledLines
		/// </summary>
		/// <param name="source">Input wiki content as a list of StyledLines</param>
		/// <param name="output">Output object to which output is sent</param>
		/// <param name="contentBase">The ContentBase that contains the wiki string text</param>
		/// <param name="maker">A link maker </param>
		/// <param name="external">External wiki map</param>
		/// <param name="headingLevelBase">Relative heading level</param>
		/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
		/// 
		Formatter(AbsoluteTopicName topic, IList source, WikiOutput output, ContentBase contentBase, LinkMaker maker, Hashtable external, int headingLevelBase, CompositeCacheRule accumulator)
		{
			_Topic = topic;
			_Source = source;
			_Output = output;
			_LinkMaker = maker;
			ContentBase = contentBase;
			_ExternalWikiMap = external;
			_HeadingLevelBase = headingLevelBase;
			_CacheRuleAccumulator = accumulator;
		}
示例#22
0
		/// <summary>
		/// Answer the formatted text for a given topic, formatted using a given OutputFormat and possibly showing diffs with the previous revision
		/// </summary>
		/// <param name="topic">The topic</param>
		/// <param name="format">What format</param>
		/// <param name="showDiffs">true to show diffs</param>
		/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
		/// <returns></returns>
		public static string FormattedTopic(AbsoluteTopicName topic, OutputFormat format, AbsoluteTopicName previousVersion, Federation aFederation, LinkMaker lm, CompositeCacheRule accumulator)
		{ 
			ContentBase relativeToBase = aFederation.ContentBaseForNamespace(topic.Namespace);
			return FormattedTopicWithSpecificDiffs(topic, format, previousVersion, aFederation, lm, accumulator);
		}
示例#23
0
 private void Initialize(OutputFormat format, LinkMaker linker)
 {
   Format = format;
   LinkMaker = linker;
   InitializePerformanceCounters();
 }
示例#24
0
 /// <summary>
 /// Create a new formatter for a string of input content.
 /// </summary>
 /// <param name="source">Input wiki string</param>
 /// <param name="output">Output object to which output is sent</param>
 /// <param name="namespaceManager">The ContentProviderChain that contains the wiki string text</param>
 /// <param name="maker">A link maker </param>
 /// <param name="external">External wiki map</param>
 /// <param name="headingLevelBase">Relative heading level</param>
 /// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
 /// 
 Formatter(QualifiedTopicRevision topic, string source, WikiOutput output, NamespaceManager namespaceManager,
     LinkMaker maker, ExternalReferencesMap external, int headingLevelBase)
 {
     _topic = topic;
     _source = SplitStringIntoStyledLines(source, LineStyle.Unchanged);
     _linkMaker = maker;
     NamespaceManager = namespaceManager;
     _output = output;
     _externalWikiMap = external;
     _headingLevelBase = headingLevelBase;
 }
示例#25
0
 /// <summary>
 /// Answer a new Federation
 /// </summary>
 public Federation(OutputFormat format, LinkMaker linker)
 {
   Initialize(format, linker);
 }
示例#26
0
 /// <summary>
 /// Format a given input string to the given output
 /// </summary>pre
 /// <param name="source">Input wiki content as a list of StyledLines</param>
 /// <param name="output">Output object to which output is sent</param>
 /// <param name="namespaceManager">The ContentProviderChain that contains the wiki string text</param>
 /// <param name="maker">A link maker </param>
 /// <param name="external">External wiki map</param>
 /// <param name="headingLevelBase">Relative heading level</param>
 /// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
 /// 
 public static void Format(QualifiedTopicRevision topic, IList source, WikiOutput output,
     NamespaceManager namespaceManager, LinkMaker maker, ExternalReferencesMap external, int headingLevelBase)
 {
     Formatter f = new Formatter(topic, source, output, namespaceManager, maker, external, headingLevelBase);
     f.Format();
 }
示例#27
0
 /// <summary>
 /// Answer a new federation loaded from the given configuration file
 /// </summary>
 /// <param name="configFile">Path to the config file</param>
 public Federation(string configFile, OutputFormat format, LinkMaker linker)
 {
   Initialize(format, linker);
   FileInfo info = new FileInfo(configFile);
   LoadFromConfiguration(FederationConfiguration.FromFile(configFile));
 }
示例#28
0
 /// <summary>
 /// Answer the formatted text for a given topic, formatted using a given OutputFormat and possibly showing diffs with the previous revision
 /// </summary>
 /// <param name="topic">The topic</param>
 /// <param name="format">What format</param>
 /// <param name="showDiffs">true to show diffs</param>
 /// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
 /// <returns></returns>
 public static string FormattedTopic(QualifiedTopicRevision topic, OutputFormat format, QualifiedTopicRevision previousVersion, Federation aFederation, LinkMaker lm)
 {
     NamespaceManager relativeToBase = aFederation.NamespaceManagerForNamespace(topic.Namespace);
     return FormattedTopicWithSpecificDiffs(topic, format, previousVersion, aFederation, lm);
 }
示例#29
0
		[SetUp] public void Init()
		{
			string author = "tester-joebob";
			_lm = new LinkMaker("http://bogusville");
			TheFederation = new Federation(OutputFormat.HTML, _lm);

			_versions = new ArrayList();
			_base = CreateStore("FlexWiki.Base");

			WriteTestTopicAndNewVersion(_base, "TopicOne", @"1
2
3
4
5
6
7
8
9", author);
			System.Threading.Thread.Sleep(100); // need the newer one to be newer enough!
			WriteTestTopicAndNewVersion(_base, "TopicOne", @"1
2
a
b
c
3
4
5
6
7
8
9", author);
			System.Threading.Thread.Sleep(100); // need the newer one to be newer enough!
			WriteTestTopicAndNewVersion(_base, "TopicOne", @"1
2
a
b
6
7
8
9", author);

			foreach (TopicChange change in _base.AllChangesForTopic(new LocalTopicName("TopicOne")))
				_versions.Add(change.Version);
		}
示例#30
0
 public static IWikiToPresentation WikiToPresentation(QualifiedTopicRevision topic, WikiOutput output,
     NamespaceManager namespaceManager, LinkMaker maker, ExternalReferencesMap external, int headingLevelBase)
 {
     ArrayList lines = new ArrayList();
     lines.Add(new StyledLine("", LineStyle.Unchanged));
     return new Formatter(topic, lines, output, namespaceManager, maker, external, headingLevelBase);
 }
示例#31
0
		protected virtual void PageLoad()
		{
			if (CheckForConfigurationFormatUpgrade())
				return;

			// Setup the federation -- either find the existing one or create a new one
			_LinkMaker = new LinkMaker(RootUrl(Request));
			EstablishFederation();

			// Make sure we've setup a LogEventFactory for the federation
			string logFile = ConfigurationSettings.AppSettings["LogPath"];
			string relativeTo = Server.MapPath("~");
			if (logFile != null)
			{
			  logFile = System.IO.Path.Combine(relativeTo, logFile); 
			}
			ILogEventFactory factory = TheFederation.LogEventFactory;
			if (factory == null)
				TheFederation.LogEventFactory = new WebApplicationLogEventFactory(Application, logFile);
			
			string ns = TheFederation.DefaultNamespace;
			if (ns == null)
                throw new Exception("No default namespace defined in configuration file: " + TheFederation.FederationNamespaceMapFilename);

			ContentBase cb  = TheFederation.ContentBaseForNamespace(ns);
			if (cb == null)
				throw new Exception("Default namespace (" + ns + ") doesn't exist.");

			// Commented out by david ornstein 11/14/2004 -- As far as i can tell there's no need for this call (and its presence is now causing unneeded/expected federation
			// update events to fire).  If you're reading this aftre a few months and it's still here, you can rip it out...
			//TheFederation.DefaultNamespace = ns;

			EstablishNewsletterDaemon(
				ConfigurationSettings.AppSettings["SMTPServer"], 
				ConfigurationSettings.AppSettings["SMTPUser"], 
				ConfigurationSettings.AppSettings["SMTPPassword"],
				ConfigurationSettings.AppSettings["NewslettersFrom"]);

			ProcessUnauthenticatedUserName();
		}