soywiki 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0d1d5102e2bf2eb59f9c54cf9343c9667ec8039c
4
+ data.tar.gz: e4c1daeaffa441119b6d1326ace05f04c92ad20b
5
+ SHA512:
6
+ metadata.gz: f5587968c6a7d5bed8efd78d282c98fc95ac3841b14a403ff8427fb0228c54252875d85d6b44d23df463e8f9a099792adcbe4aedf288085d77e657c72c951cf3
7
+ data.tar.gz: 294dce3c0cc16a3bac73b9c9f226be1ea9f5d8e961cfaaefef4f55774919c1ae5032759339087fbe1810690068e9ec8f802f02d3887f4b57b6157c248e0a29ac
data/lib/soywiki.rb CHANGED
@@ -1,12 +1,23 @@
1
1
  require 'string_ext'
2
-
2
+ module Template_Substitution; end
3
3
  module Soywiki
4
- VERSION = '0.9.2'
4
+ VERSION = '0.9.3'
5
5
  WIKI_WORD = /\b([a-z0-9][\w_]+\.)?[A-Z][a-z]+[A-Z0-9]\w*\b/
6
6
  HYPERLINK = %r|\bhttps?://[^ >)\n\]]+|
7
7
 
8
8
  def self.run
9
- if %W( -v --version -h --help).include?(ARGV.first)
9
+ require 'getoptlong'
10
+
11
+ opts = GetoptLong.new(
12
+ [ '--help', '-h', GetoptLong::NO_ARGUMENT],
13
+ [ '--version', '-v', GetoptLong::NO_ARGUMENT],
14
+ [ '--html', GetoptLong::NO_ARGUMENT],
15
+ [ '--markdown', GetoptLong::NO_ARGUMENT],
16
+ [ '--page', GetoptLong::REQUIRED_ARGUMENT],
17
+ [ '--index', GetoptLong::REQUIRED_ARGUMENT],
18
+ )
19
+
20
+ usage =-> do
10
21
  puts "soywiki #{Soywiki::VERSION}"
11
22
  puts "by Daniel Choi dhchoi@gmail.com"
12
23
  puts
@@ -18,19 +29,38 @@ Run the command in a directory you've made to contain soywiki files.
18
29
 
19
30
  Soywiki will open the most recently modified wiki file or create a file
20
31
  called main/HomePage.
32
+
33
+ Parse to html:
34
+ -- html
35
+ assume that wiki-files are in markdown syntax:
36
+ --markdown
37
+ replace default haml-page-template with the one supplied:
38
+ --page template-file
39
+ replace default haml-index-template with the one supplied:
40
+ --index template-file
21
41
  ---
22
42
  END
23
43
  exit
24
- elsif ARGV.first == '--html'
25
- if ARGV[1] == '--markdown'
26
- puts "Exporting html using markdown"
27
- self.html_export(true)
28
- else
29
- puts "Exporting html"
30
- self.html_export
44
+ end
45
+ install_plugin = false
46
+ html = false
47
+ md = false
48
+ index = page = nil
49
+ opts.each do |opt, arg|
50
+ case opt
51
+ when '--help' then usage[]
52
+ when '--version' then usage[]
53
+ when '--html' then html = true
54
+ when '--markdown' then md = true
55
+ when '--install-plugin' then install_plugin = true
56
+ when '--page' then page = arg
57
+ when '--index' then index = arg
31
58
  end
32
- exit
33
- elsif ARGV.first == '--install-plugin'
59
+ end
60
+ self.set_substitute %{INDEX_PAGE_TEMPLATE_SUB}.to_sym, index if index
61
+ self.set_substitute %{PAGE_TEMPLATE_SUB}.to_sym, page if page
62
+ self.html_export md if html
63
+ if install_plugin
34
64
  require 'erb'
35
65
  plugin_template = File.read(File.join(File.dirname(__FILE__), 'plugin.erb'))
36
66
  vimscript_file = File.join(File.dirname(__FILE__), 'soywiki.vim')
@@ -42,13 +72,18 @@ END
42
72
  vimscript = File.expand_path("../soywiki.vim", __FILE__)
43
73
  vim_command = "#{vim} -S #{vimscript}"
44
74
  exec vim_command
45
- end
75
+ end unless html
46
76
  end
47
77
 
48
78
  def self.html_export(markdown=false)
49
79
  require 'soywiki/html'
50
80
  Html.export(markdown)
51
81
  end
82
+
83
+ def self.set_substitute const, substitute_path
84
+ substitute = File.read(substitute_path)
85
+ Template_Substitution.const_set const.to_sym, substitute
86
+ end
52
87
  end
53
88
 
54
89
  if __FILE__ == $0
data/lib/soywiki.vim CHANGED
@@ -574,7 +574,8 @@ func! s:expand(seamless, vertical)
574
574
  endfunc
575
575
  "------------------------------------------------------------------------
576
576
  func! s:open_href_under_cursor()
577
- let href = expand("<cWORD>")
577
+ let word = expand("<cWORD>")
578
+ let href = matchstr(word, s:http_link_pattern)
578
579
  let command = g:SoyWiki#browser_command . " '" . href . "' "
579
580
  call system(command)
580
581
  echom command
data/lib/soywiki/html.rb CHANGED
@@ -2,6 +2,7 @@ require 'haml'
2
2
  require 'rdiscount'
3
3
  module Soywiki
4
4
  module Html
5
+ include Template_Substitution
5
6
 
6
7
  HTML_DIR = 'html-export'
7
8
  INDEX_PAGE_TEMPLATE = File.read(File.join(File.dirname(__FILE__), '..', 'index_template.html.haml'))
@@ -42,7 +43,12 @@ module Soywiki
42
43
  process(text.join("\n").strip)
43
44
  end
44
45
 
45
- Haml::Engine.new(PAGE_TEMPLATE).render(nil, :body => body,
46
+ page_template = if defined?(PAGE_TEMPLATE_SUB)
47
+ PAGE_TEMPLATE_SUB
48
+ else
49
+ PAGE_TEMPLATE
50
+ end
51
+ Haml::Engine.new(page_template).render(nil, :body => body,
46
52
  :title => title,
47
53
  :namespace => namespace,
48
54
  :namespaces => namespaces,
@@ -57,8 +63,13 @@ module Soywiki
57
63
  end
58
64
 
59
65
  def self.make_index_page(dir, pages, namespaces)
66
+ index_page_template = if defined?(INDEX_PAGE_TEMPLATE_SUB)
67
+ INDEX_PAGE_TEMPLATE_SUB
68
+ else
69
+ INDEX_PAGE_TEMPLATE
70
+ end
60
71
  outfile = File.join(HTML_DIR, dir, 'index.html')
61
- html = Haml::Engine.new(INDEX_PAGE_TEMPLATE).render(nil,
72
+ html = Haml::Engine.new(index_page_template).render(nil,
62
73
  :namespace => dir,
63
74
  :root => false,
64
75
  :pages => pages.map {|p| p.split('/')[1]}.sort,
@@ -85,7 +96,12 @@ module Soywiki
85
96
 
86
97
  def self.make_root_index_page(namespaces)
87
98
  outfile = File.join(HTML_DIR, 'index.html')
88
- html = Haml::Engine.new(INDEX_PAGE_TEMPLATE).render(nil,
99
+ index_page_template = if defined?(INDEX_PAGE_TEMPLATE_SUB)
100
+ INDEX_PAGE_TEMPLATE_SUB
101
+ else
102
+ INDEX_PAGE_TEMPLATE
103
+ end
104
+ html = Haml::Engine.new(index_page_template).render(nil,
89
105
  :namespace => nil,
90
106
  :pages => [],
91
107
  :root => true,
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soywiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
5
- prerelease:
4
+ version: 0.9.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Daniel Choi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-27 00:00:00.000000000 Z
11
+ date: 2013-07-25 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: A personal and collaborative wiki for Vim users
15
14
  email:
@@ -45,26 +44,25 @@ files:
45
44
  - soywiki.gemspec
46
45
  homepage: http://danielchoi.com/software/soywiki.html
47
46
  licenses: []
47
+ metadata: {}
48
48
  post_install_message:
49
49
  rdoc_options: []
50
50
  require_paths:
51
51
  - lib
52
52
  required_ruby_version: !ruby/object:Gem::Requirement
53
- none: false
54
53
  requirements:
55
- - - ! '>='
54
+ - - '>='
56
55
  - !ruby/object:Gem::Version
57
56
  version: '0'
58
57
  required_rubygems_version: !ruby/object:Gem::Requirement
59
- none: false
60
58
  requirements:
61
- - - ! '>='
59
+ - - '>='
62
60
  - !ruby/object:Gem::Version
63
61
  version: '0'
64
62
  requirements: []
65
63
  rubyforge_project: soywiki
66
- rubygems_version: 1.8.23
64
+ rubygems_version: 2.0.3
67
65
  signing_key:
68
- specification_version: 3
66
+ specification_version: 4
69
67
  summary: Wiki with Vim interface and Git repo
70
68
  test_files: []