示例#1
0
		public FileSystemStore(Federation aFed, string ns, string root)
		{
			// For FileSystemStores, the only thing in the connection string is the root
			SetFederation(aFed);

			Namespace = ns;

			// Calculate the root -- taking into account the relative location of the directory if needed
			if (root.StartsWith(".\\"))
			{
				FileInfo fi = new FileInfo(aFed.FederationNamespaceMapFilename);
				root = fi.DirectoryName + "\\" + root.Substring(2);
			}
			_Root = root;
			_State = State.New;
			if (Directory.Exists(root))
			{
				Read();
			}
			else
			{
				try
				{
					Directory.CreateDirectory(root);
				} 
				catch (DirectoryNotFoundException e)
				{
					e.ToString();
				}
			}
		}
示例#2
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();
		}
示例#3
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);
 }
示例#4
0
        /// <summary>
        /// Called when a provider is first created.  Must register all associated namespaces with the federation.
        /// Can also be used to create initial content in the namespaces.
        /// </summary>
        /// <param name="aFed"></param>
        public IList CreateNamespaces(Federation aFed)
        {
            ArrayList answer = new ArrayList();

            if (SqlNamespaceProvider.Exists(Namespace, ConnectionString))
            {
                throw new Exception("Namespace with the specified name already exists.");
            }

            this.CreateNamespace(Namespace, ConnectionString);

            SqlStore store = new SqlStore();

            throw new NotImplementedException();
            /*
            NamespaceManager manager = aFed.RegisterNamespace(store);
            manager.WriteTopic(manager.DefinitionTopicName.LocalName, "");
            manager.SetTopicPropertyValue(manager.DefinitionTopicName.LocalName, "Contact", Contact, false);
            manager.SetTopicPropertyValue(manager.DefinitionTopicName.LocalName, "Title", Title, false);
            string defaultImportedNamespaces = System.Configuration.ConfigurationSettings.AppSettings["DefaultImportedNamespaces"];
            if (defaultImportedNamespaces != null)
            {
                manager.SetTopicPropertyValue(manager.DefinitionTopicName.LocalName, "Import", defaultImportedNamespaces, false);
            }

            // whoever is last should write a new version
            manager.SetTopicPropertyValue(manager.DefinitionTopicName.LocalName, "Description", NamespaceDescription, true);
            answer.Add(Namespace);
            return ArrayList.ReadOnly(answer);

            */
        }
示例#5
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;
				}
			}
		}
示例#6
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;
                }
            }
        }
		public void UpdateNamespaces(Federation aFed)
		{
			// just kill the old ones and reload new ones
			foreach (string each in NamespaceNames)
				aFed.UnregisterNamespace(aFed.ContentBaseForNamespace(each));
			LoadNamespaces(aFed);
		}
示例#8
0
 public NewsletterManager(Federation aFed, LinkMaker lm, IDeliveryBoy boy, string newslettersFrom, string headInsert)
 {
     _LinkMaker = lm;
     _NewslettersFrom = newslettersFrom;
     _Federation = aFed;
     _DeliveryBoy = boy;
     _HeadInsert = headInsert;
 }
示例#9
0
 /// <summary>
 /// Called when a provider should instantiate and register all of its namespaces in a federation.  
 /// Note that when a provider is first created (e.g., via the admin UI) that this function is not 
 /// called.
 /// </summary>
 /// <param name="aFed"></param>
 public void LoadNamespaces(Federation aFed)
 {
     throw new NotImplementedException();
     /*
     SqlStore store = new SqlStore();
     aFed.RegisterNamespace(store);
      */
 }
示例#10
0
		public NewsletterDaemon(Federation fed, string rootURL, string newslettersFrom, 
			string headInsert, bool sendAsAttachments)
		{
			_TheFederation = fed;
			RootURL = rootURL;
			_NewslettersFrom = newslettersFrom;
			_HeadInsert = headInsert;
			_sendAsAttachments = sendAsAttachments; 
		}
示例#11
0
        public BehaviorInterpreter(string contextString, string input, Federation aFed, int wikiTalkVersion, IWikiToPresentation presenter)
        {
            _Federation = aFed;
            _ContextString = contextString == null ? "(unknown location)" : contextString;
            WikiTalkVersion = wikiTalkVersion;
            Presenter = presenter;

            Input = input;
            State = InterpreterState.ReadyToParse;
        }
示例#12
0
        static void Print(Federation federation, TopicName topic)
        {
            string formattedBody = federation.GetTopicFormattedContent(new QualifiedTopicRevision(topic), null);

            // Now calculate the borders
            string leftBorder = federation.GetTopicFormattedBorder(topic, Border.Left);
            string rightBorder =federation.GetTopicFormattedBorder(topic, Border.Right);
            string topBorder = federation.GetTopicFormattedBorder(topic, Border.Top);
            string bottomBorder = federation.GetTopicFormattedBorder(topic, Border.Bottom);

            //			Console.Out.WriteLine(formattedBody);
        }
示例#13
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);
		}
示例#14
0
		static void Print(Federation federation, AbsoluteTopicName topic)
		{
			bool diffs = false;

			string formattedBody = federation.GetTopicFormattedContent(topic, diffs);

			// Now calculate the borders
			string leftBorder = federation.GetTopicFormattedBorder(topic, Border.Left);
			string rightBorder =federation.GetTopicFormattedBorder(topic, Border.Right);
			string topBorder = federation.GetTopicFormattedBorder(topic, Border.Top);
			string bottomBorder = federation.GetTopicFormattedBorder(topic, Border.Bottom);

//			Console.Out.WriteLine(formattedBody);
		}
示例#15
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);
        }
示例#16
0
文件: Wiki.cs 项目: zi-yu/orionsbelt
        /// <summary>Mostra o controlo</summary>
        protected override void Render(HtmlTextWriter writer)
        {
#if WIKI
        #if DEBUG
            Check(GetFederation(), "Federation");
        #endif
            if (WikiSearch != null)
            {
                WriteSearchResults(writer);
                return;
            }

            string currentTopic = "Orionsbelt.Orionsbelt";

            OrionTopic obj = (OrionTopic)Context.Items["WikiTopic"];
            if (obj != null)
            {
                currentTopic = obj.ToString();
            }

            if (obj != null && !obj.Exists)
            {
                writer.WriteLine("Lamentamos, mas o tpico {0} ainda no foi adicionado.", obj.ToString());
                ExceptionLog.log("WikiTopic", string.Format("Access detected to WikiTopic '{0}' that does not exist.", obj.ToString()));
                return;
            }

            FlexWiki.AbsoluteTopicName topic = new FlexWiki.AbsoluteTopicName(currentTopic);

            string display = GetDisplay(topic);
            OrionGlobals.RegisterRequest(Chronos.Messaging.MessageType.ResearchManagement, string.Format("{0} - {1}", CultureModule.getContent("help"), display));

            FlexWiki.Federation fed = GetFederation();

            string formattedBody = fed.GetTopicFormattedContent(topic, false);
            writer.WriteLine("<div id='TopicTip'></div>");
            writer.WriteLine("<div id='wiki'>");
            WriteLocation(writer, topic, display);
            CheckPreviewImage(writer, topic);
            writer.WriteLine("<h1>{0}</h1>", display);
            writer.WriteLine(formattedBody);
            writer.WriteLine("</div>");
#else
            writer.WriteLine("<p>This <b>orionsbelt</b> version was compiled without Wiki support!</p>");
            writer.WriteLine("<p>If this is an online version... then... er... maybe we forgot the wiki, please warn us!</p>");
#endif
        }
示例#17
0
        // Constructors

        internal NamespaceManager(Federation federation, ContentProviderBase contentProvider,
            string ns, NamespaceProviderParameterCollection parameters)
        {
            _federation = federation;
            _contentProviderChain = contentProvider;
            _namespace = ns;

            if (parameters != null)
            {
                foreach (NamespaceProviderParameter parameter in parameters)
                {
                    _parameters.Add(parameter);
                }
            }

            _contentProviderChain.Initialize(this); 
        }
示例#18
0
		public CalendarStore(Federation fed, string ns, int year, int month)
		{
			SetFederation(fed);
			Namespace = ns;
			Year = year;
			Month = month;
			foreach (DateTime each in Dates)
			{
				AbsoluteTopicName abs = TopicNameForDate(each);
				_Topics[abs] = each;
				_Topics[abs.LocalName] = each;
			}

			AbsoluteTopicName a = new AbsoluteTopicName("_NormalBorders", Namespace);
			BackingTopic top = new BackingTopic(a, DefaultNormalBordersContent, true);
			BackingTopics[a.Name] = top;
			_Topics[a] = DateTime.MinValue;
		}
示例#19
0
		public SqlStore(Federation aFed, string ns, string connectionString)
		{
			SetFederation(aFed);

			Namespace = ns;

			_ConnectionString = connectionString;

			_State = State.New;
			// Check if the namespace exists in the database
			// If does not exist then create the database.
			if( SqlNamespaceProvider.Exists(Namespace, ConnectionString) )
			{
				Read();
			}
			else
			{
				SqlHelper.CreateNamespace(Namespace, ConnectionString);
			}
		}
示例#20
0
		public DynamicTopic(Federation aFed, AbsoluteTopicName name)
		{
			_CurrentFederation = aFed;
			_Name = name;
		}
示例#21
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();
		}
示例#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
 // Constructors
 public TopicVersionInfo(Federation aFed, QualifiedTopicRevision name)
 {
     _topicVersionKey = name;
     _federation = aFed;
 }
示例#24
0
 internal void Initialize(Federation federation)
 {
   _federation = federation; 
   _configurationProvider.Initialize(federation); 
 }
示例#25
0
文件: Form1.cs 项目: nuxleus/flexwiki
		private void button3_Click(object sender, System.EventArgs e)
		{
			Federation fed = new Federation(textBoxFederationPath.Text, OutputFormat.Testing, null);
			BehaviorInterpreter interpreter = new BehaviorInterpreter("Input Form", textBoxInput.Text, CurrentFederation, 1, this);
					
			ClearCacheView();

			if (Parse(interpreter) == null)
			{
				Fail("Unable to run; parse failed:" + interpreter.ErrorString);
				tabControl.SelectedTab = tabParser;
			}

			// Begin execution
			tabControl.SelectedTab = tabOutput;
			ExecutionContext ctx = new ExecutionContext(CurrentTopicContext);
			string final = null;
			if (!interpreter.EvaluateToPresentation(CurrentTopicContext, new Hashtable()))
			{
				Fail(interpreter.ErrorString);
				return;
			}
			WikiOutput output = WikiOutput.ForFormat(OutputFormat.Testing, null);
			interpreter.Value.ToPresentation(this).OutputTo(output);
			final = output.ToString();
			Success(final);
			UpdateCacheView(interpreter.CacheRules);
		}
        private void EstablishFederation()
        {
            if (Federation != null)
            {
                return;
            }

            FlexWikiWebApplication application = new FlexWikiWebApplication(new LinkMaker(PageUtilities.RootUrl));
            Federation = new Federation(application);
        }
 public AllTopicsInNamespaceCacheRule(Federation fed, string ns)
 {
     _Namespace = ns;
     _Federation = fed;
 }
示例#28
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();
        }
示例#29
0
		void EstablishFederation()
		{
			if (TheFederation != null)
			{
				// If we have one, just make sure it's valid
				TheFederation.Validate();
				return;
			}

			// nope - need a new one
			string federationNamespaceMap = FederationNamespaceMapPath;
			if (federationNamespaceMap == null)
				throw new Exception("No namespace map file defined.  Please set the FederationNamespaceMapFile key in <appSettings> in web.config to point to a namespace map file.");
			string fsPath = MapPath(federationNamespaceMap);
			Federation fed = new Federation(fsPath, OutputFormat.HTML, TheLinkMaker);
			fed.EnableCaching(CacheManager); // Give the federation a cache to work with 
			SetFederation(fed);
			
			// Setup event monitoring
			SetupUpdateMonitoring();
		}
示例#30
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);
 }
示例#31
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();
        }
示例#32
0
文件: Form1.cs 项目: nuxleus/flexwiki
		void UpdateFederationInfo()
		{
			_CurrentFederation = null;
			errorProviderFederationFile.SetError(textBoxFederationPath, "");
			string fn = textBoxFederationPath.Text;
			if (!System.IO.File.Exists(fn))
			{
				errorProviderFederationFile.SetError(textBoxFederationPath, "File not found");
				return;
			}
			_CurrentFederation = new Federation(fn, OutputFormat.Testing, null);
			comboBoxTopic.Items.Clear();
			foreach (ContentBase cb in _CurrentFederation.ContentBases)
			{
				foreach (AbsoluteTopicName tn in cb.AllTopics(false))
				{
					comboBoxTopic.Items.Add(tn.ToString());
				}
			}
			if (comboBoxTopic.Items.Count > 0 && (comboBoxTopic.SelectedValue == null || (string)(comboBoxTopic.SelectedValue) == ""))
				comboBoxTopic.SelectedValue = comboBoxTopic.Items[0];
		}