{aTopic |
  [
request.AreDifferencesShown.IfTrue
  {
    MenuItem("Don't highlight differences between this topic and previous version", "Hide Changes", federation.LinkMaker.LinkToTopic(aTopic.Fullname))
  }
  IfFalse
  {
    MenuItem("Show differences between this topic and previous version", "Show Changes", federation.LinkMaker.LinkToTopicWithDiffs(aTopic.Fullname))
  },
  aTopic.Version.IfNull
  {
    aTopic.Namespace.IsReadOnly.IfFalse
    {
      MenuItem("Edit this topic", "Edit", federation.LinkMaker.LinkToEditTopic(aTopic.Fullname))
    }
    IfTrue
    {
      ""
    }
  }
  Else
  {
    ""
  },
  MenuItem("Show printable view of this topic", "Print", federation.LinkMaker.LinkToPrintView(aTopic.Fullname)),
  MenuItem("Show recently changed topics", "Recent Changes", federation.LinkMaker.LinkToRecentChanges(aTopic.Namespace.Name)),
  MenuItem("Show RRS feeds to keep up-to-date", "Subscriptions", federation.LinkMaker.LinkToSubscriptions(aTopic.Namespace.Name)),
  MenuItem("Show disconnected topics", "Lost and Found", federation.LinkMaker.LinkToLostAndFound(aTopic.Namespace.Name)),
  MenuItem("Find references to this topic", "Find References", federation.LinkMaker.LinkToSearchFor(null, aTopic.Name)),
  aTopic.Namespace.IsReadOnly.IfFalse
  {
    MenuItem("Rename this topic", "Rename", federation.LinkMaker.LinkToRename(aTopic.Fullname))
  }
  IfTrue
  {
    ""
  },
  MenuItem("Show Main FlexWiki Administration Page", "Administration Page", federation.LinkMaker.SimpleLinkTo("admin/default.aspx")),
  namespace.HasManageNamespacePermission.IfTrueIfFalse
  ({
     [
       MenuItem("Show Topic Lock Management Page", "Topic Locks", federation.LinkMaker.SimpleLinkTo("admin/TopicLocks.aspx")),
       Presentations.FormStart(federation.LinkMaker.SimpleLinkTo("admin/TopicLocks.aspx"), "post"),
       Presentations.HiddenField("namespace", aTopic.Namespace.Name),
       Presentations.HiddenField("topic", [aTopic.Namespace.Name, ".", aTopic.Name].ToOneString),
       Presentations.HiddenField("returnUrl", federation.LinkMaker.LinkToTopic(aTopic.Fullname)),
       Presentations.HiddenField("fileaction", aTopic.IsTopicLocked.IfFalseIfTrue({"Lock"},{"Unlock"})),
       Presentations.SubmitButton("goButton", aTopic.IsTopicLocked.IfFalseIfTrue({"Lock Topic"},{"Unlock Topic"})), 
       Presentations.FormEnd(),
     ]
  }, { "" }),
  Newline,"----", Newline,
  [
    "||{T-}",
    "'''Search'''", 
    "||",
    Newline, 
    "||{+}",
    Presentations.FormStart(federation.LinkMaker.LinkToSearchNamespace(aTopic.Namespace.Name), "get"),
    Presentations.HiddenField("namespace", aTopic.Namespace.Name),
    Presentations.InputField("search", "", 15),
    Presentations.ImageButton("goButton", federation.LinkMaker.LinkToImage("images/go-dark.gif"), "Search for this text"), 
    Presentations.FormEnd(),
    "||",
    Newline
  ],
  Newline, "----", Newline,
  [
    "'''History'''", Newline,
    aTopic.Changes.Snip(5).Collect
    { each |
      [
	"||{T-+}", 
	Presentations.Link(federation.LinkMaker.LinkToTopic(each.Fullname), [each.Timestamp].ToString), 
	"||", 
	Newline,
	"||{T-+}``", 
	each.Author, 
	"``||", 
	Newline
      ]
    },
    Newline,
    MenuItem("List all versions of this topic", "List all versions", federation.LinkMaker.LinkToVersions(aTopic.Fullname)),
    aTopic.Version.IfNotNull
    {[
      Newline,
      Presentations.FormStart(federation.LinkMaker.LinkToRestore(aTopic.Fullname), "post"),
      Presentations.HiddenField("RestoreTopic", aTopic.Fullname),
      Presentations.SubmitButton("restoreButton", "Restore Version"), 
      Presentations.FormEnd(),
    ]}
    Else
    {
      ""
    },
    Newline
  ],
  Newline, "----", Newline,
  Presentations.Image(
    federation.LinkMaker.LinkToImage("images/flexwikirss.png"),
      ["RSS feed for the ", namespace.Name, " namespace"].ToString,
      federation.LinkMaker.SimpleLinkTo(["Rss.aspx?namespace=", namespace.Name].ToString))
]
}