Permalink
Browse files

• select the Show Wiki command and it opens the intro page, you can e…

…dit the page (using the edit links), visit pages linked from it, or create those pages which are references but still do not exist (they have a “create” link)

This is a very rudimentary system. Pages without headings get no edit link, and it badly needs a refresh system (could just be a link to the page itself in the top for “manual” refresh)


git-svn-id: http://svn.textmate.org/trunk/Bundles/Experimental Wiki.tmbundle@5248 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
0 parents commit 3197d3425ca271020b1038a906a673d3f2fb9784 @sorbits sorbits committed Sep 17, 2006
Showing with 116 additions and 0 deletions.
  1. +21 −0 Commands/Show Wiki.tmCommand
  2. +67 −0 Support/bin/linkify.rb
  3. +10 −0 Support/pages/intro.mdown
  4. +8 −0 Support/pages/links.mdown
  5. +10 −0 info.plist
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>beforeRunningCommand</key>
+ <string>nop</string>
+ <key>command</key>
+ <string>FILE=`"$TM_BUNDLE_SUPPORT/bin/linkify.rb" "$TM_BUNDLE_SUPPORT/pages/intro.mdown"`
+echo "&lt;meta http-equiv='Refresh' content='0;URL=tm-file://$FILE'&gt;"
+
+</string>
+ <key>input</key>
+ <string>none</string>
+ <key>name</key>
+ <string>Show Wiki</string>
+ <key>output</key>
+ <string>showAsHTML</string>
+ <key>uuid</key>
+ <string>011517D7-AA14-46B6-9141-51411F33E6E8</string>
+</dict>
+</plist>
@@ -0,0 +1,67 @@
+#!/usr/bin/env ruby -w
+
+require "pathname"
+require "fileutils"
+
+markdown = "#{ENV['HOME']}/Library/Application Support/TextMate/Support/bin/Markdown.pl"
+
+def e_url(str)
+ str.gsub(/([^a-zA-Z0-9\/_.-]+)/n) do
+ '%' + $1.unpack('H2' * $1.size).join('%').upcase
+ end
+end
+
+def e_sh(str)
+ str.to_s.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF])/, '\\')
+end
+
+def e_sh_js(str)
+ (e_sh str).gsub("\\", "\\\\\\\\")
+end
+
+script = Pathname.new($0).realpath.to_s
+
+file = ARGV.shift || "/Users/duff/Source/TextMate/manual/pages/010_preface.markdown"
+path = Pathname.new(file).realpath
+dir = path.parent.to_s
+
+tmp = '/tmp/tm_wiki'
+FileUtils.mkdir tmp unless File.exists? tmp
+dst_name = tmp + '/' + path.basename.to_s.sub(/\..+\z/, '') + '.html'
+
+open("|#{e_sh markdown} > #{e_sh dst_name}", "w") do |io|
+ io << DATA.read
+
+ line_no = 1
+ open(file) do |src|
+ src.each_line do |line|
+ if line =~ /^#+.*/
+ line = line + " <small>(<a href='txmt://open?line=#{line_no + 1}&url=file://#{e_url path.to_s}'>edit</a>)</small>"
+ end
+
+ line = line.gsub(/\[([^\]]+)\]\[\]/) do |m|
+ dest = "#{dir}/#{$1}.mdown"
+ if File.exists? dest
+ "<a href='#' onClick='visit(\"#{e_sh_js script}\", \"#{e_sh_js dest}\"); return false;'>#{$1}</a>"
+ else
+ "#{$1} (<a href='txmt://open?url=file://#{e_url dest}'>create</a>)"
+ end
+ end
+
+ line_no = line_no + 1
+
+ io << line
+ end
+ end
+end
+
+print dst_name
+
+__END__
+<script type="text/javascript">
+ function visit (script, page) {
+ var link = TextMate.system(script + " " + page, null).outputString;
+ window.location="tm-file://" + link;
+ }
+</script>
+
@@ -0,0 +1,10 @@
+
+# Introduction
+
+This is a small wiki.
+
+You can edit all the pages by using the edit links.
+
+You can also follow [links][] to other pages.
+
+This page was created by [Allan Odgaard][].
@@ -0,0 +1,8 @@
+
+# Links
+
+A link will link to a local file.
+
+You can get back to the [intro][] or you can create a new page.
+
+For example there is no page for [credits][].
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>name</key>
+ <string>Experimental Wiki</string>
+ <key>uuid</key>
+ <string>BC4D60B2-A514-4B5C-B178-20AE7557A4A3</string>
+</dict>
+</plist>

0 comments on commit 3197d34

Please sign in to comment.