soywiki 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +0 -15
- data/README.markdown +24 -21
- data/Rakefile +3 -1
- data/bin/soywiki-expand +7 -3
- data/lib/index_template.html.haml +28 -0
- data/lib/page_template.html.haml +27 -0
- data/lib/soywiki/html.rb +104 -0
- data/lib/soywiki.rb +17 -5
- data/lib/soywiki.vim +0 -2
- data/soywiki.gemspec +1 -1
- data/website/soywiki-template.html +1 -1
- metadata +7 -4
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,25 +1,10 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
couchrest (1.0.1)
|
5
|
-
json (>= 1.4.6)
|
6
|
-
mime-types (>= 1.15)
|
7
|
-
rest-client (>= 1.5.1)
|
8
4
|
haml (3.0.25)
|
9
|
-
json (1.5.1)
|
10
|
-
mime-types (1.16)
|
11
|
-
rack (1.2.1)
|
12
|
-
rest-client (1.6.1)
|
13
|
-
mime-types (>= 1.16)
|
14
|
-
sinatra (1.1.2)
|
15
|
-
rack (~> 1.1)
|
16
|
-
tilt (~> 1.2)
|
17
|
-
tilt (1.2.2)
|
18
5
|
|
19
6
|
PLATFORMS
|
20
7
|
ruby
|
21
8
|
|
22
9
|
DEPENDENCIES
|
23
|
-
couchrest
|
24
10
|
haml
|
25
|
-
sinatra
|
data/README.markdown
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# SoyWiki
|
2
2
|
|
3
|
-
SoyWiki
|
4
|
-
|
3
|
+
SoyWiki turns Vim into a powerful, lean, and fast wiki. It's got all
|
4
|
+
the protein of a more conventional wiki, but a lot less of the fat and
|
5
|
+
cholesterol.
|
5
6
|
|
6
7
|
A quick overview of its characteristics and features:
|
7
8
|
|
@@ -124,7 +125,7 @@ You can get very far with SoyWiki using normal CamelCase WikiWords.
|
|
124
125
|
|
125
126
|
But if you want, you can also namespace your WikiWords, like so:
|
126
127
|
|
127
|
-
|
128
|
+
namespace.WikiWord
|
128
129
|
|
129
130
|
A namespaced WikiWord is a WikiWord prefixed by a namespace and a
|
130
131
|
period. The namespace word must start with a lower-case letter and
|
@@ -145,8 +146,8 @@ namespace called `recipes.SoyRaspberrySmoothie` you can type the link as
|
|
145
146
|
just `SoyRaspberrySmoothie`. SoyWiki will know that this is a link to
|
146
147
|
another page in the same namespace.
|
147
148
|
|
148
|
-
When you
|
149
|
-
namespace `main`.
|
149
|
+
When you start SoyWiki for the first time, the active namespace is the
|
150
|
+
default namespace `main`.
|
150
151
|
|
151
152
|
|
152
153
|
## Wiki navigation
|
@@ -157,7 +158,7 @@ commands:
|
|
157
158
|
* `CTRL-k` and `CTRL-j` move the cursor directly to the next or previous WikiLink on the page
|
158
159
|
* `ENTER` follows the WikiLink under the cursor
|
159
160
|
* `,f` follows the first WikiLink after the cursor
|
160
|
-
* `CTRL-l` opens a WikiLink in a vertical split window; press again
|
161
|
+
* `CTRL-l` opens a WikiLink in a vertical split window; press `CTRL-l` again
|
161
162
|
while the cursor is on the top line to close the new window
|
162
163
|
* `CTRL-h` does the same, but in a regular split window
|
163
164
|
* `q` closes a split window
|
@@ -260,21 +261,24 @@ same wiki page.
|
|
260
261
|
## Search
|
261
262
|
|
262
263
|
* `:SWSearch` [term]
|
263
|
-
* `:
|
264
|
+
* `:SWNamespaceSearch` [term]
|
264
265
|
|
265
|
-
These commands search your SoyWiki wiki.
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
266
|
+
These commands search your SoyWiki wiki. `:SWNamespaceSearch` confines
|
267
|
+
your search to the current namespace.
|
268
|
+
|
269
|
+
Vim will load any matches in the quickfix list window. If there are
|
270
|
+
matches, you can use `:cn` and `:cp` to go from match to match, `:cl` to
|
271
|
+
list the matches, and `:cc [item number]` to see a particular match ln
|
272
|
+
the list. See `:help quickfix` to see the list of matches. for more
|
273
|
+
QuickFix commands.
|
270
274
|
|
271
275
|
Examples:
|
272
276
|
|
273
277
|
:SWSearch Gnu
|
274
|
-
:
|
278
|
+
:SWNamespaceSearch Gnu
|
275
279
|
|
276
280
|
You can use `:SWS` as a shortcut for `:SWSearch`. You can also
|
277
|
-
tab-complete `:SWNS` to `:
|
281
|
+
tab-complete `:SWNS` to `:SWSNamespaceSearch`.
|
278
282
|
|
279
283
|
Searches are case-insensitve.
|
280
284
|
|
@@ -354,6 +358,12 @@ recursive, you can effectively nest outlines within outlines, like
|
|
354
358
|
dreams within dreams.
|
355
359
|
|
356
360
|
|
361
|
+
## Exporting to HTML
|
362
|
+
|
363
|
+
Want to share your wiki with non-Vim-users? Export your wiki into a directory
|
364
|
+
of html pages, type `soywiki --html` from the root directory of your wiki.
|
365
|
+
|
366
|
+
|
357
367
|
## Extra macros
|
358
368
|
|
359
369
|
SoyWiki adds a few convenient Vim macros that you can use anytime.
|
@@ -387,13 +397,6 @@ file names without any awkward character escaping.
|
|
387
397
|
[ward]:http://c2.com/cgi/wiki?WikiCase
|
388
398
|
|
389
399
|
|
390
|
-
## Why name a wiki engine after a legume?
|
391
|
-
|
392
|
-
I am a fan of food made of [soy][soylink]: soy ice cream, soy milk, soy
|
393
|
-
burgers, soy butter, you name it. The word "soy" has come to signify a
|
394
|
-
newer, lighter, healthier alternative to the same old same old. SoyWiki
|
395
|
-
may not be an actual soy product, but it tries to be a wiki engine with
|
396
|
-
soy-like benefits.
|
397
400
|
|
398
401
|
[soylink]:http://www.mayoclinic.com/health/soy/NS_patient-soy
|
399
402
|
|
data/Rakefile
CHANGED
@@ -32,10 +32,11 @@ desc "build and push website"
|
|
32
32
|
task :web => :build_webpage do
|
33
33
|
puts "Building and pushing website"
|
34
34
|
`scp website/soywiki.html zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
35
|
+
`open http://danielchoi.com/software/soywiki.html`
|
35
36
|
end
|
36
37
|
|
37
38
|
desc "build website locally"
|
38
|
-
task :
|
39
|
+
task :build_web_locally => :build_webpage do
|
39
40
|
Dir.chdir("website") do
|
40
41
|
`open soywiki.html`
|
41
42
|
end
|
@@ -51,6 +52,7 @@ task :build_webpage do
|
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
55
|
+
|
54
56
|
desc "Run tests"
|
55
57
|
task :test do
|
56
58
|
$:.unshift File.expand_path("test")
|
data/bin/soywiki-expand
CHANGED
@@ -13,10 +13,14 @@ PROCESSED_FILES = []
|
|
13
13
|
def indent(text, level, mode)
|
14
14
|
return text if mode == 'seamless'
|
15
15
|
return text if level == 0
|
16
|
-
('
|
16
|
+
('|' * level) + ' ' + text
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
|
+
def divider
|
21
|
+
puts '+' + '-' * 78 + '+'
|
22
|
+
end
|
23
|
+
|
20
24
|
def expand(file, mode, level=0)
|
21
25
|
PROCESSED_FILES << file
|
22
26
|
lines = File.readlines(file)
|
@@ -34,11 +38,11 @@ def expand(file, mode, level=0)
|
|
34
38
|
end
|
35
39
|
if File.file?(link.to_file_path) && !PROCESSED_FILES.include?(link.to_file_path)
|
36
40
|
if mode == 'seamful'
|
37
|
-
|
41
|
+
divider
|
38
42
|
end
|
39
43
|
expand(link.to_file_path, mode, level + 1) # recursive call
|
40
44
|
if mode == 'seamful'
|
41
|
-
|
45
|
+
divider
|
42
46
|
end
|
43
47
|
elsif PROCESSED_FILES.include?(link)
|
44
48
|
puts indent("#{link} [[already expanded]]", level, mode)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
:css
|
5
|
+
h3 { margin-top: 0 }
|
6
|
+
.sidebar { float:left; width: 20%; font-size: small }
|
7
|
+
.main { margin-left: 22%; width: 70% }
|
8
|
+
ul { list-style-type: none; margin-left: 0; padding-left: 0 }
|
9
|
+
.page-count { font-size: smaller; color: #CCC }
|
10
|
+
%body
|
11
|
+
.sidebar
|
12
|
+
%h3 Namespaces
|
13
|
+
%ul
|
14
|
+
- namespaces.each do |namespace, count|
|
15
|
+
%li
|
16
|
+
- if root
|
17
|
+
%a{:href => "#{namespace}/index.html"}= namespace
|
18
|
+
- else
|
19
|
+
%a{:href => "../#{namespace}/index.html"}= namespace
|
20
|
+
%span.page-count
|
21
|
+
= count
|
22
|
+
- if ! root
|
23
|
+
%h3= namespace
|
24
|
+
%ul
|
25
|
+
- pages.each do |page|
|
26
|
+
%li
|
27
|
+
%a{:href => "#{page}.html"}= page
|
28
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
:css
|
5
|
+
h3 { margin-top: 0 }
|
6
|
+
.sidebar { float:left; width: 20%; font-size: small }
|
7
|
+
.main { margin-left: 22%; width: 70% }
|
8
|
+
ul { list-style-type: none; margin-left: 0; padding-left: 0 }
|
9
|
+
.page-count { font-size: smaller; color: #CCC }
|
10
|
+
|
11
|
+
%body
|
12
|
+
.sidebar
|
13
|
+
%h3 Namespaces
|
14
|
+
%ul
|
15
|
+
- namespaces.each do |namespace, count|
|
16
|
+
%li
|
17
|
+
%a{:href => "../#{namespace}/index.html"}= namespace
|
18
|
+
%span.page-count
|
19
|
+
= count
|
20
|
+
%h3= namespace
|
21
|
+
%ul
|
22
|
+
- pages.each do |page|
|
23
|
+
%li
|
24
|
+
%a{:href => "#{page}.html"}= page
|
25
|
+
.main
|
26
|
+
%h2= title
|
27
|
+
%pre= body
|
data/lib/soywiki/html.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'haml'
|
2
|
+
module Soywiki
|
3
|
+
module Html
|
4
|
+
|
5
|
+
def self.href_wiki_links(text)
|
6
|
+
text = text.gsub(WIKI_WORD) {|match|
|
7
|
+
href = if match =~ /\w\./ # namespace
|
8
|
+
"../#{match.gsub(".", "/")}.html"
|
9
|
+
else
|
10
|
+
match + '.html'
|
11
|
+
end
|
12
|
+
%{<a href="#{href}">#{match}</a>}
|
13
|
+
}
|
14
|
+
return text
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.href_hyperlinks(text)
|
18
|
+
text = text.gsub(HYPERLINK) {|match|
|
19
|
+
%{<a href="#{match}">#{match}</a>}
|
20
|
+
}
|
21
|
+
return text
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.process(t)
|
25
|
+
href_hyperlinks(href_wiki_links(t))
|
26
|
+
end
|
27
|
+
|
28
|
+
PAGE_TEMPLATE = File.read(File.join(File.dirname(__FILE__), '..', 'page_template.html.haml'))
|
29
|
+
|
30
|
+
def self.generate_page(text, namespace, pages, namespaces)
|
31
|
+
title = text.split("\n")[0]
|
32
|
+
body = process(text.split("\n")[1..-1].join("\n").strip)
|
33
|
+
Haml::Engine.new(PAGE_TEMPLATE).render(nil, :body => body,
|
34
|
+
:title => title,
|
35
|
+
:namespace => namespace,
|
36
|
+
:namespaces => namespaces, :pages => pages)
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
HTML_DIR = 'soywiki-html-export'
|
41
|
+
INDEX_PAGE_TEMPLATE = File.read(File.join(File.dirname(__FILE__), '..', 'index_template.html.haml'))
|
42
|
+
|
43
|
+
def self.wiki_page?(file)
|
44
|
+
file.gsub("/", '.') =~ WIKI_WORD
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.make_index_page(dir, pages, namespaces)
|
48
|
+
outfile = File.join(HTML_DIR, dir, 'index.html')
|
49
|
+
html = Haml::Engine.new(INDEX_PAGE_TEMPLATE).render(nil,
|
50
|
+
:namespace => dir,
|
51
|
+
:root => false,
|
52
|
+
:pages => pages.map {|p| p.split('/')[1]}.sort,
|
53
|
+
:namespaces => namespaces)
|
54
|
+
File.open(outfile, 'w') {|f| f.write html}
|
55
|
+
# puts "=> Writing #{outfile}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.make_pages(dir, namespaces)
|
59
|
+
`mkdir -p #{HTML_DIR}/#{dir}`
|
60
|
+
pages = Dir["#{dir}/*"].select {|file| wiki_page? file}
|
61
|
+
# make pages
|
62
|
+
pages.each do |file|
|
63
|
+
outfile = File.join(HTML_DIR, file + '.html')
|
64
|
+
html = Soywiki::Html.generate_page(File.read(file),
|
65
|
+
dir,
|
66
|
+
pages.map {|p| p.split('/')[1]}.sort,
|
67
|
+
namespaces)
|
68
|
+
File.open(outfile, 'w') {|f| f.write html}
|
69
|
+
# puts "Writing #{outfile}"
|
70
|
+
end
|
71
|
+
make_index_page(dir, pages, namespaces)
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.make_root_index_page(namespaces)
|
75
|
+
outfile = File.join(HTML_DIR, 'index.html')
|
76
|
+
html = Haml::Engine.new(INDEX_PAGE_TEMPLATE).render(nil,
|
77
|
+
:namespace => nil,
|
78
|
+
:pages => [],
|
79
|
+
:root => true,
|
80
|
+
:namespaces => namespaces)
|
81
|
+
File.open(outfile, 'w') {|f| f.write html}
|
82
|
+
# puts "=> Writing #{outfile}"
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.export
|
86
|
+
`rm -rf #{HTML_DIR}/*`
|
87
|
+
namespaces = Dir["*"].select {|f|
|
88
|
+
File.directory?(f) && f != HTML_DIR
|
89
|
+
}.map {|namespace|
|
90
|
+
count = Dir["#{namespace}/*"].select {|f| wiki_page?(f)}.size
|
91
|
+
[namespace, count]
|
92
|
+
}
|
93
|
+
namespaces.each do |namespace_dir, count|
|
94
|
+
make_pages namespace_dir, namespaces
|
95
|
+
end
|
96
|
+
# make root index page
|
97
|
+
make_root_index_page namespaces
|
98
|
+
puts "HTML files written to #{HTML_DIR}/"
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
data/lib/soywiki.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'string_ext'
|
2
2
|
|
3
3
|
module Soywiki
|
4
|
-
VERSION = '0.2.
|
4
|
+
VERSION = '0.2.3'
|
5
5
|
WIKI_WORD = /\b([a-z][\w_]+\.)?[A-Z][a-z]+[A-Z]\w*\b/
|
6
|
+
HYPERLINK = %r|\bhttps?://[^ >)\n\]]+|
|
6
7
|
|
7
8
|
def self.run
|
8
9
|
if %W( -v --version -h --help).include?(ARGV.first)
|
@@ -20,12 +21,23 @@ open the most recently modified wiki file.
|
|
20
21
|
---
|
21
22
|
END
|
22
23
|
exit
|
24
|
+
elsif ARGV.first == '--html'
|
25
|
+
self.html_export
|
26
|
+
exit
|
27
|
+
else
|
28
|
+
vim = ENV['SOYWIKI_VIM'] || 'vim'
|
29
|
+
vimscript = File.expand_path("../soywiki.vim", __FILE__)
|
30
|
+
vim_command = "#{vim} -S #{vimscript} #{ARGV.first}"
|
31
|
+
exec vim_command
|
23
32
|
end
|
33
|
+
end
|
24
34
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
exec vim_command
|
35
|
+
def self.html_export
|
36
|
+
require 'soywiki/html'
|
37
|
+
Html.export
|
29
38
|
end
|
30
39
|
end
|
31
40
|
|
41
|
+
if __FILE__ == $0
|
42
|
+
Soywiki.run
|
43
|
+
end
|
data/lib/soywiki.vim
CHANGED
@@ -4,8 +4,6 @@
|
|
4
4
|
|
5
5
|
" This regex matches namedspaced WikiWords and unqualified WikiWords
|
6
6
|
let s:wiki_link_pattern = '\C\m\<\([a-z][[:alnum:]_]\+\.\)\?[A-Z][a-z]\+[A-Z]\w*\>'
|
7
|
-
|
8
|
-
|
9
7
|
let s:http_link_pattern = 'https\?:[^ >)\]]\+'
|
10
8
|
let s:rename_links_command = 'soywiki-rename '
|
11
9
|
let s:find_pages_linking_in_command = 'soywiki-pages-linking-in '
|
data/soywiki.gemspec
CHANGED
@@ -47,7 +47,7 @@
|
|
47
47
|
<div class="also-by">
|
48
48
|
<h4>also by this developer</h4>
|
49
49
|
<ul class="cross-promo">
|
50
|
-
<li><a href="http://vmail.
|
50
|
+
<li><a href="http://danielchoi.com/software/vmail.html">vmail<a/></li>
|
51
51
|
<li><a href="http://instantwatcher.com">instantwatcher.com<a/></li>
|
52
52
|
<li><a href="http://openmbta.org">OpenMBTA<a/></li>
|
53
53
|
<li><a href="http://kindlefeeder.com">kindlefeeder.com<a/></li>
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 3
|
9
|
+
version: 0.2.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Choi
|
@@ -14,11 +14,11 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-13 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: haml
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
@@ -55,8 +55,11 @@ files:
|
|
55
55
|
- bin/soywiki-ls-t
|
56
56
|
- bin/soywiki-pages-linking-in
|
57
57
|
- bin/soywiki-rename
|
58
|
+
- lib/index_template.html.haml
|
59
|
+
- lib/page_template.html.haml
|
58
60
|
- lib/soywiki.rb
|
59
61
|
- lib/soywiki.vim
|
62
|
+
- lib/soywiki/html.rb
|
60
63
|
- lib/string_ext.rb
|
61
64
|
- soywiki.gemspec
|
62
65
|
- website/.gitignore
|