Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge '0robustus1/master' into danchoi/master.

  • Loading branch information...
commit 317eb6aec14e1a0a146072d9244c9d962589d0f5 2 parents d4ed946 + 7d3811e
@0robustus1 0robustus1 authored
Showing with 54 additions and 16 deletions.
  1. +20 −12 lib/soywiki.rb
  2. +24 −4 lib/soywiki.vim
  3. +10 −0 soywiki.gemspec
View
32 lib/soywiki.rb
@@ -1,7 +1,7 @@
require 'string_ext'
module Template_Substitution; end
module Soywiki
- VERSION = '0.9.3'
+ VERSION = '0.9.5'
WIKI_WORD = /\b([a-z0-9][\w_]+\.)?[A-Z][a-z]+[A-Z0-9]\w*\b/
HYPERLINK = %r|\bhttps?://[^ >)\n\]]+|
@@ -13,15 +13,17 @@ def self.run
[ '--version', '-v', GetoptLong::NO_ARGUMENT],
[ '--html', GetoptLong::NO_ARGUMENT],
[ '--markdown', GetoptLong::NO_ARGUMENT],
+ [ '--install-plugin', GetoptLong::NO_ARGUMENT],
[ '--page', GetoptLong::REQUIRED_ARGUMENT],
[ '--index', GetoptLong::REQUIRED_ARGUMENT],
)
- usage =-> do
+ usage =->(version_only=false) do
puts "soywiki #{Soywiki::VERSION}"
puts "by Daniel Choi dhchoi@gmail.com"
+ exit if version_only
puts
- puts <<END
+ puts <<-END
---
Usage: soywiki
@@ -31,15 +33,21 @@ def self.run
called main/HomePage.
Parse to html:
--- html
- assume that wiki-files are in markdown syntax:
- --markdown
- replace default haml-page-template with the one supplied:
- --page template-file
- replace default haml-index-template with the one supplied:
- --index template-file
+ --html
+ assume that wiki-files are in markdown syntax:
+ --markdown
+ replace default haml-page-template with the one supplied:
+ --page template-file
+ replace default haml-index-template with the one supplied:
+ --index template-file
+Install the soywiki vim plugin:
+ --install-plugin
+Show this help:
+ [--help, -h]
+Show version info:
+ [--version, -v]
---
-END
+ END
exit
end
install_plugin = false
@@ -49,7 +57,7 @@ def self.run
opts.each do |opt, arg|
case opt
when '--help' then usage[]
- when '--version' then usage[]
+ when '--version' then usage[true]
when '--html' then html = true
when '--markdown' then md = true
when '--install-plugin' then install_plugin = true
View
28 lib/soywiki.vim
@@ -5,6 +5,7 @@
if exists("g:SoyWikiLoaded") || &cp || version < 700
finish
endif
+
let g:SoyWikiLoaded = 1
let mapleader = ','
@@ -26,7 +27,15 @@ func! s:trimString(string)
endfunc
func! s:page_title()
- return substitute(bufname(''), '\/', '.', '')
+ let path = s:wiki_root()
+ let raw_title = substitute(expand('%:p'), path, '', '')
+ let page_title = substitute(raw_title, '\/', '.', '')
+ return page_title
+endfunc
+
+func! s:wiki_root()
+ let root_path = split(system("git rev-parse --show-toplevel"), "\n")[0] . '/'
+ return root_path
endfunc
func! s:display_missing_namespace_error(num_segments, page_title)
@@ -52,6 +61,12 @@ func! s:namespace_of_title(page_title)
endif
endfunc
+func! s:namespace_path_of_title(page_title)
+ let namespace = s:namespace_of_title(a:page_title)
+ let root_path = s:wiki_root()
+ return root_path . namespace
+endfunc
+
func! s:page_namespace()
return s:namespace_of_title(s:page_title())
endfunc
@@ -89,11 +104,15 @@ func! s:is_wiki_page()
endfunc
func! s:pagetitle2file(page)
- return substitute(a:page, '\.', '/', 'g')
+ let path = s:wiki_root()
+ let filepath = path . substitute(a:page, '\.', '/', 'g')
+ return filepath
endfunc
func! s:filename2pagetitle(page)
- return substitute(a:page, '/', '.', 'g')
+ let path = s:wiki_root()
+ let title = substitute(substitute(a:page, path, '', 'g'), '/', '.', 'g')
+ return title
endfunc
func! s:list_pages()
@@ -201,7 +220,8 @@ func! s:load_page(page, split)
if namespace == ""
return
end
- call system("mkdir -p " . namespace)
+ let namespace_path = s:namespace_path_of_title(a:page)
+ call system("mkdir -p " . namespace_path)
call writefile([title, '', ''], file)
endif
if (a:split == 2)
View
10 soywiki.gemspec
@@ -19,6 +19,16 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
+ additional_info = <<-INFO
+For optional compilation of the wiki to html you will need:
+ - haml
+and for markdown support:
+ - rdiscount
+ INFO
+
+ s.requirements = additional_info
+ s.post_install_message = additional_info
+
#s.add_dependency 'haml'
#s.add_dependency 'rdiscount'
end
Please sign in to comment.
Something went wrong with that request. Please try again.