Exemple #1
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			_topicString  = Request.QueryString["topic"];
			
			try
			{
				_diff		= Convert.ToInt32(Request.QueryString["diff"]);
			}
			catch {}
			try
			{
				_oldid		= Convert.ToInt32(Request.QueryString["oldid"]);
			}
			catch {}

			try
			{
				_requestedTopic = new AbsoluteTopicName(_topicString);
			}
			catch {}

			if (_requestedTopic == null || _diff >= _oldid)
			{
				Response.Redirect("default.aspx");
			}
		}
Exemple #2
0
		public void ControlPageTitle()
		{
			AbsoluteTopicName top = new AbsoluteTopicName("TitledTopic", TheFederation.DefaultContentBase.Namespace);
			string t = TheLinkMaker.LinkToTopic(top);
			DocumentElement doc = TheBrowser.Navigate(t, true);
			
			Assert.AreEqual("This fat hen", doc.Title);
		}
Exemple #3
0
		public void ControlTopicBar()
		{
			AbsoluteTopicName top = new AbsoluteTopicName("TitledTopic", TheFederation.DefaultContentBase.Namespace);
			string t = TheLinkMaker.LinkToTopic(top);
			DocumentElement doc = TheBrowser.Navigate(t, true);
			HTMLElement staticTopicBar = (HTMLElement)doc.GetElementByName("StaticTopicBar");

			Assert.AreEqual("This fat hen", staticTopicBar.InnerText);
		}
Exemple #4
0
        public string GetTopicField(FlexWiki.AbsoluteTopicName topic, string field)
        {
            Hashtable hash = GetFederation().ContentBaseForNamespace(topic.Namespace).GetFieldsForTopic(topic);

            if (hash == null)
            {
                return(null);
            }
            return((string)hash[field]);
        }
Exemple #5
0
        public string GetDisplay(FlexWiki.AbsoluteTopicName topic)
        {
            string display = GetTopicField(topic, "Display");

            if (display == null)
            {
                return(topic.FormattedName);
            }
            return(display);
        }
Exemple #6
0
		static void Print(Federation federation, AbsoluteTopicName topic)
		{
			string formattedBody = federation.GetTopicFormattedContent(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);
		}
Exemple #7
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);
		}
Exemple #8
0
        /// <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
        }
Exemple #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="topic">Topic context</param>
		/// <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(AbsoluteTopicName topic, 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(topic, input, output, relativeToContentBase, lm, ew, 0, accumulator);
			return output.ToString();
		}
Exemple #10
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;
		}
Exemple #11
0
        private void WriteLocation(HtmlTextWriter writer, FlexWiki.AbsoluteTopicName topic, string display)
        {
            writer.WriteLine("<div id='wiki_nav'>");
            writer.WriteLine("<div id='wiki_search'><input type='text' name='wiki_search' value='' /> <input type='submit' value='Procurar' /></div>");
            writer.WriteLine("<a href='{0}'>Manual</a>", OrionGlobals.getSectionBaseUrl("wiki"));

            string parent = GetTopicField(topic, "Parent");

            if (parent != null)
            {
                FlexWiki.AbsoluteTopicName parentTopic = new FlexWiki.AbsoluteTopicName(parent);
                writer.WriteLine(" &raquo; <a href='{0}'>{1}</a>", GetUrl(parentTopic), GetDisplay(parentTopic));
            }

            if (topic.Fullname != "Orionsbelt.Orionsbelt")
            {
                writer.WriteLine(" &raquo; <a href='{0}'>{1}</a>", GetUrl(topic), display);
            }
            writer.WriteLine("</div>");
        }
Exemple #12
0
        public static ArrayList GetTopicSpacedLines( string topicName )
        {
            #if WIKI
            AbsoluteTopicName topic = new AbsoluteTopicName(topicName);
            ContentBase cb = GetFederation().ContentBaseForNamespace(topic.Namespace);

            using (TextReader sr = cb.TextReaderForTopic(topic)) 	{
                ArrayList lines = new ArrayList();
                string line = null;
                while( (line = sr.ReadLine()) != null ) {
                    if( line.StartsWith(" ") ) 	{
                        lines.Add(line.Trim());
                    }
                }
                return lines;
            }
            #else
            return new ArrayList();
            #endif
        }
Exemple #13
0
		public void CreateTestPage()
		{
			AbsoluteTopicName top = new AbsoluteTopicName("DummyPage", TheFederation.DefaultContentBase.Namespace);

			bool exists;
			
			exists = TheFederation.TopicExists(top);
			Assert.IsTrue(!exists);

			string home = TheLinkMaker.LinkToTopic(top);
			DocumentElement doc = TheBrowser.Navigate(home, true);
			Assert.IsTrue(doc.Body.OuterHTML.IndexOf("Formatting Tips") > 0);
			InputElement text = (InputElement) doc.GetElementByName("Text1");
			text.Value = "This is SoCool!";
			ButtonElement save = (ButtonElement) doc.GetElementByName("SaveButton");

			save.Click(true);
			// Make sure it actually got saved
			exists = TheFederation.TopicExists(top);
			Assert.IsTrue(exists);
		}
Exemple #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();
		}
Exemple #15
0
		private string LinkWikiNames (string input)
		{
			StringBuilder answer = new StringBuilder();

			string str = input;
			ArrayList processed = new ArrayList();
			while (str.Length > 0)
			{
				Match m = extractWikiLinks.Match(str);
				if (!m.Success)
					break;
				string each = m.Groups["topic"].ToString();
				string before = m.Groups["before"].ToString();
				string after = m.Groups["after"].ToString();
				string relabel = m.Groups["relabel"].ToString();
				string anchor = m.Groups["anchor"].ToString();
				
				RelativeTopicName relName = new RelativeTopicName(TopicName.StripEscapes(each));

				// Ignore apparent links to non-existent namespaces.
				if ((null == relName.Namespace) || (null != TheFederation.ContentBaseForNamespace(relName.Namespace)))
				{
					// Build a list of all the possible absoluteNames for this topic
					ArrayList absoluteNames = new ArrayList();
					// Start with the singulars in the various reachable namespaces, then add the plurals
					absoluteNames.AddRange(ContentBase.AllAbsoluteTopicNamesThatExist(relName));
					AddCacheRule(ContentBase.CacheRuleForAllPossibleInstancesOfTopic(relName));
					foreach (TopicName alternate in relName.AlternateForms)
					{
						AddCacheRule(ContentBase.CacheRuleForAllPossibleInstancesOfTopic(alternate));
						absoluteNames.AddRange(ContentBase.AllAbsoluteTopicNamesThatExist(alternate));
					}
					
					// Now see if we got any hits or not
					string rep = beforeOrRelabel + "(" + RegexEscapeTopic(each) + ")" + afterWikiName;
					AbsoluteTopicName appearedAs = new AbsoluteTopicName(each);  // in case it was a plural form, be sure to show it as it appeared
					string displayname = TopicName.StripEscapes((ContentBase.DisplaySpacesInWikiLinks ? appearedAs.FormattedName : appearedAs.Name));
					if (relabel.Length > 0)
					{
						displayname = relabel;
					}

					if (absoluteNames.Count == 0)
					{
						if (!IsUnbracketedOneWordName(each))
						{
							// It doesn't exist, so give the option to create it
							AbsoluteTopicName abs = relName.AsAbsoluteTopicName(ContentBase.Namespace);
							str = ReplaceMatch(answer, str, m, before + "<a title=\"Click here to create this topic\" class=\"create\" href=\"" + LinkMaker().LinkToEditTopic(abs) + "\">" + displayname + "</a>" + after);
						}
						else
							str = ReplaceMatch(answer, str, m, m.Value);
					}
					else
					{
						// We got hits, let's add links

						if (absoluteNames.Count == 1)
						{
							// The simple case is that there's only one link to point to, so we output just a normal link
							AbsoluteTopicName abs = (AbsoluteTopicName)absoluteNames[0];
							string tip = TipForTopic(abs);
							string tipid = null;
							string tipHTML = null;
							bool defaultTip = tip == null;
							if (defaultTip)
							{
								tip = "Click to read this topic";
							}
							tipid = NewUniqueIdentifier();
							tipHTML = Formatter.EscapeHTML(tip);
							if (defaultTip)
							{
								tipHTML = "<span class=\"DefaultTopicTipText\">" + tipHTML + "</span>";
							}
							tipHTML += "<div class=\"TopicTipStats\">" + TheFederation.GetTopicModificationTime(abs).ToString() + " - " + TheFederation.GetTopicLastModifiedBy(abs) + "</div>";
							tipHTML = "<div id=" + tipid +" style=\"display: none\">" + tipHTML + "</div>";
							Output.AddToFooter(tipHTML);
							string replacement = "<a ";
							if (tip != null)
							{
								replacement += "onmouseover=\"TopicTipOn(this, '" + tipid + "', event);\" onmouseout=\"TopicTipOff();\" ";
							}
							replacement += "href=\"" + LinkMaker().LinkToTopic(abs);
							if (anchor.Length > 0)
							{
								replacement += "#" + anchor;
								if (0 == relabel.Length)
								{
									displayname += "#" + anchor;
								}
							}
							replacement += "\">" + displayname + "</a>";
							str = ReplaceMatch(answer, str, m, before + replacement + after) ;
						}
						else
						{
							// There's more than one; we need to generate a dynamic menu
							string clickEvent;
							clickEvent = "onclick=\"javascript:LinkMenu(new Array(";
							bool first = true;
							foreach (AbsoluteTopicName eachAbs in absoluteNames)
							{	
								if (!first)
									clickEvent += ", ";
								first = false;
								clickEvent += "new Array('" + eachAbs + "', '" + LinkMaker().LinkToTopic(eachAbs) + "')";
							}
							clickEvent += "), event);\"";

							str = ReplaceMatch(answer, str, m, before + "<a title=\"Different versions of this topic exist.  Click to pick one.\" " + clickEvent + ">" + displayname + "</a>" + after) ;
						}
					}
				}
				else
				{
					str = ReplaceMatch(answer, str, m, before + relName.Fullname + after);
				}
			}

			// Add on whatever's not yet been consumed
			answer.Append(str);
			return answer.ToString();
		}
Exemple #16
0
		private string TipForTopic(AbsoluteTopicName topic)
		{
			string answer = TheFederation.GetTopicProperty(topic, "Summary");
			if (answer == "")
				answer = null;
			return answer;
		}
Exemple #17
0
		private string IncludedTopic(TopicName topic, int headingLevelBase)
		{
			// TODO: how do we identify specific versions? [maybe this just works now? since versionids are a formal part of a wikiname???]
			// TODO: how do we show diffs?
			string ns = ContentBase.UnambiguousTopicNamespace(topic);
			ContentBase containingContentBase = TheFederation.ContentBaseForNamespace(ns);
			AbsoluteTopicName abs = new AbsoluteTopicName(topic.Name, ns);
			string content = containingContentBase.Read(abs.LocalName).TrimEnd();
			WikiOutput output = WikiOutput.ForFormat(_Output.Format, Output);
			Formatter.Format(abs, content, output, ContentBase, LinkMaker(), _ExternalWikiMap, headingLevelBase, CacheRuleAccumulator);
			return output.ToString().Trim();
		}
Exemple #18
0
		/// <summary>
		/// Restores the passed in Topic version as the current version
		/// </summary>
		/// <param name="topic">Topic Version to Restore</param>
		/// <returns></returns>
		protected TopicName RestorePreviousVersion(AbsoluteTopicName topic)
		{
			LogEvent e = TheFederation.LogEventFactory.CreateAndStartEvent(Request.UserHostAddress, VisitorIdentityString, topic.ToString(), LogEvent.LogEventType.WriteTopic);
			try
			{
				AbsoluteTopicName newVersionName = new AbsoluteTopicName(topic.Name, topic.Namespace);
				newVersionName.Version = TopicName.NewVersionStringForUser(VisitorIdentityString);
				ContentBase cb = TheFederation.ContentBaseForNamespace(topic.Namespace);
				cb.WriteTopicAndNewVersion(newVersionName.LocalName, TheFederation.Read(topic));
			}
			finally
			{
				e.Record();
			}
			return new AbsoluteTopicName(topic.Name, topic.Namespace);
		}
Exemple #19
0
    private IBELObject BorderPropertyFromTopic(AbsoluteTopicName relativeToTopic, AbsoluteTopicName abs, Border border, CompositeCacheRule rule)
    {
      ContentBase cb = ContentBaseForTopic(abs);
      if (cb == null)
      {
        return null;
      }
      rule.Add(cb.CacheRuleForAllPossibleInstancesOfTopic(abs));
      if (!cb.TopicExists(abs))
      {
        return null;
      }

      // OK, looks like the topic exist -- let's see if the property is there
      string borderPropertyName = BorderPropertyName(border);
      string prop = GetTopicProperty(abs, borderPropertyName);
      if (prop == null || prop == "")
      {
        return null;
      }

      // Yup, so evaluate it!
      string code = "federation.GetTopic(\"" + abs.Fullname + "\")." + borderPropertyName + "(federation.GetTopicInfo(\"" + relativeToTopic + "\"))";

      BehaviorInterpreter interpreter = new BehaviorInterpreter(code, this, this.WikiTalkVersion, null);
      if (!interpreter.Parse())
      {
        throw new Exception("Border property expression failed to parse.");
      }
      TopicContext topicContext = new TopicContext(this, this.ContentBaseForTopic(abs), new TopicInfo(this, abs));
      IBELObject obj = interpreter.EvaluateToObject(topicContext, null);
      if (interpreter.ErrorString != null)
      {
        obj = new BELString(interpreter.ErrorString);
      }

      foreach (CacheRule r in interpreter.CacheRules)
      {
        rule.Add(r);
      }
      return obj;
    }
Exemple #20
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;
		}
Exemple #21
0
		public TopicInfo(Federation aFed, AbsoluteTopicName name)
		{
			_Fullname = name;
			_Federation = aFed;
		}
Exemple #22
0
		[Test] public void TestInlineWikiTalk()
		{
			WikiOutput output = WikiOutput.ForFormat(OutputFormat.HTML, null);
			AbsoluteTopicName top = new AbsoluteTopicName("InlineTestTopic", _cb.Namespace);
			Formatter.Format(top, TheFederation.ContentBaseForTopic(top).Read(top.LocalName), output,  _cb, _lm, _externals, 0, null);
			string result = output.ToString();
			Assert.IsTrue(result.IndexOf("aaa foo zzz") >= 0);
		}
Exemple #23
0
 public static string GetUrl(FlexWiki.AbsoluteTopicName topic)
 {
     return(GetUrl(topic.Namespace, topic.Name));
 }
Exemple #24
0
		public DynamicTopic(Federation aFed, AbsoluteTopicName name)
		{
			_CurrentFederation = aFed;
			_Name = name;
		}
Exemple #25
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);
		}
Exemple #26
0
		string FormattedTestText(string inputString, AbsoluteTopicName top)
		{
			WikiOutput output = WikiOutput.ForFormat(OutputFormat.Testing, null);
			Formatter.Format(top, inputString, output,  _cb, _lm, _externals, 0, null);
			string o = output.ToString();
			string o1 = o.Replace("\r", "");
			return o1;
		}
Exemple #27
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);
		}
Exemple #28
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;
		}
Exemple #29
0
		public TopicChange(AbsoluteTopicName topic, DateTime changeStamp, string author)
		{
			_Topic = topic;
			_Author = author;
			_Timestamp = changeStamp;
		}
Exemple #30
0
		string FormattedTopic(AbsoluteTopicName top)
		{
			return FormattedTestText(TheFederation.ContentBaseForTopic(top).Read(top.LocalName), top);
		}
Exemple #31
0
		protected AbsoluteTopicName GetTopicName()
		{
			string topic;
			
			topic = Request.PathInfo;
			if (topic.StartsWith("/"))
				topic = topic.Substring(1);

			// See if we're dealign with old style references or new ones
			// OLD: My.Name.Space.Topic
			// NEW: My.Name.Space/Topic.html
			bool isNewStyle = topic.IndexOf("/") != -1;	// if we have a slash, it's new

			// OK, we've got the namespace and the name now
			AbsoluteTopicName abs;
			if (topic == null || topic.Length == 0)
			{
				abs = new AbsoluteTopicName(DefaultContentBase.HomePage, DefaultContentBase.Namespace);
			}
			else
			{
				if (isNewStyle)
				{
					string ns, top;
					int slash = topic.IndexOf("/");
					ns = topic.Substring(0, slash);
					top = topic.Substring(slash + 1);

					int tailDot = top.LastIndexOf(".");
					if (tailDot != -1)
						top = top.Substring(0, tailDot);	// trim of the extension (e.g., ".html")

					abs = new AbsoluteTopicName(ns + "." + top);
				}
				else
				{
					abs = new AbsoluteTopicName(topic);
				}
			}
			return abs;
		}
Exemple #32
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();
		}
Exemple #33
0
		void FormattedTopicContainsTest(AbsoluteTopicName top, string find)
		{
			FormatTestContains(FormattedTopic(top), find);
		}
Exemple #34
0
		public VisitorEvent(AbsoluteTopicName topic, string verb, DateTime when)
		{
			_Topic = topic;
			_Verb = verb;
			_When = when;
		}
Exemple #35
0
		void FormatTest(string inputString, string outputString, AbsoluteTopicName top)
		{
			string o1 = FormattedTestText(inputString, top);
			string o2 = outputString.Replace("\r", "");
			if (o1 != o2)
			{
				Console.Error.WriteLine("Got     : " + o1);
				Console.Error.WriteLine("Expected: " + o2);
			}
			Assert.AreEqual(o2, o1);
		}