示例#1
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();
		}
示例#2
0
		/// <summary>
		/// Register the given ContentBase in the federation.
		/// </summary>
		/// <param name="cb"></param>
		public void RegisterNamespace(ContentBase cb)
		{		
			_NamespaceToContentBaseMap[cb.Namespace] = cb;

			// Hook the FederationUpdate events so we can aggregate them for listeners to the Federation
			cb.FederationUpdated += new ContentBase.FederationUpdateEventHandler(FederationUpdateMonitor);	
			RecordNamespacesListChanged();
		}
示例#3
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();
		}
示例#4
0
 public override IList AllAbsoluteTopicNamesFor(ContentBase cb)
 {
     ArrayList answer = new ArrayList();
     if (Namespace != null)
         answer.Add(new AbsoluteTopicName(Fullname));
     if (Namespace == null)
     {
         answer.Add(new AbsoluteTopicName(Name, cb.Namespace));
         foreach (ContentBase each in cb.ImportedContentBases)
             answer.Add(new AbsoluteTopicName(Name, each.Namespace));
     }
     return answer;
 }
示例#5
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;
		}
示例#6
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;
		}
示例#7
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);
		}
示例#8
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();
		}
示例#9
0
		public abstract IList AllAbsoluteTopicNamesFor(ContentBase cb);
示例#10
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);
		}
示例#11
0
 /// <summary>
 /// Unregister the given ContentBase in the federation.
 /// </summary>
 /// <param name="cb"></param>
 public void UnregisterNamespace(ContentBase cb)
 {		
   cb.FederationUpdated -= new ContentBase.FederationUpdateEventHandler(FederationUpdateMonitor);	
   _NamespaceToContentBaseMap.Remove(cb.Namespace);
   RecordNamespacesListChanged();
 }
示例#12
0
 /// <summary>
 /// Answer a collection of possible AbsoluteTopicNames for this topic that are known in a given ContentBase.
 /// Mostly useful in other overrides. Since this name is already absolute, we always answer a collection of one.
 /// </summary>
 /// <param name="info">Identifies the content base relative to whose reachable namespaces the topic name should be resolved</param>
 /// <returns></returns>
 public override IList AllAbsoluteTopicNamesFor(ContentBase info)
 {
     ArrayList answer = new ArrayList();
     answer.Add(this);
     return answer;
 }