Skip to content

Commit

Permalink
LICENSE, AUTHORS added, README updated, made dependencies more optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Mendler committed Feb 10, 2009
1 parent dfac4a0 commit 4fb60d8
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 17 deletions.
9 changes: 9 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Originally by Simon Rozet (http://atonie.org/2008/02/git-wiki)

Modified by:
- Jesse Newland (http://jnewland.com/) - http auth
- Alex Payne (http://www.al3x.net)
- Jesse Andrews (http://www.overstimulate.com)
- Timoni Grone (http://www.timoni.org) - stylesheet and design aid
- Scott Chacon (http://jointheconversation.org) - ruby-git migration
- Daniel Mendler - code restructuring, support for hierarchical repositories, multiple render engines
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License

Copyright (c) 2009 Daniel Mendler

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

40 changes: 39 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
README
======

WARNING: This is an fork of the original git-wiki by [SR](http://github.com/sr/git-wiki). It is currently undocumented and not yet usable.
Git-Wiki is a a wiki that stores pages in a git repository.

Installation
------------

Run with `./run.ru -sthin -p4567` and point your browser at <http://localhost:4567>.
It automatically creates a repository in the directory '.wiki'.

Dependencies
------------

- [Sinatra][]
- [ruby-git][]
- [HAML][]
- [RubyPants][]

Optional Dependencies
---------------------

- [RubyPants][] to fix puncation
- [Pygments][] for syntax highlighting

Dependencies for page rendering
-------------------------------

- [creole][] for creole wikitext rendering
- [RDiscount][] for markdown rendering
- [RedCloth][] for textile rendering

At least one of the renderers should be installed.

[Sinatra]: http://www.sinatrarb.com
[ruby-git]: http://github.com/schacon/ruby-git
[HAML]: http://haml.hamptoncatlin.com
[RDiscount]: http://github.com/rtomayko/rdiscount
[RedCloth]: http://whytheluckystiff.net/ruby/redcloth/
[RubyPants]: http://chneukirchen.org/blog/static/projects/rubypants.html
[creole]: http://github.com/larsch/creole
[pygments]: http://pygments.org/

43 changes: 27 additions & 16 deletions wiki.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%w(rubygems sinatra_ext git haml
sass rubypants mime logger open3
sass mime logger open3
yaml/store digest cgi).each { |dep| require dep }

class Object
Expand Down Expand Up @@ -71,7 +71,15 @@ def /(name)
end

module Highlighter
`pygmentize -V 2>&1 > /dev/null`
@installed = $? == 0

def self.installed?
@installed
end

def self.text(text, format)
return CGI::escapeHTML(text) if !installed?
content = Open3.popen3("pygmentize -O linenos=table -f html -l '#{format}'") { |stdin, stdout, stderr|
stdin << text
stdin.close
Expand Down Expand Up @@ -167,7 +175,6 @@ def self.child?(child, parent)
add('text/x-markdown', %w(markdown md mdown mkdn mdown), %w(text/plain))
end


class Entry
class ConcurrentModificationError < RuntimeError; end

Expand Down Expand Up @@ -245,6 +252,13 @@ def forbid(conds)
raise MessageError.new(failed) if !failed.empty?
end

def safe_require(name)
require(name)
true
rescue LoadError
false
end

module Wiki
PATH_PATTERN = '[\w.+\-_\/](?:[\w.+\-_\/ ]+[\w.+\-_\/])?'
SHA_PATTERN = '[A-Fa-f0-9]{40}'
Expand Down Expand Up @@ -511,6 +525,10 @@ def action?(name)
request.path_info.ends_with? '/' + name.to_s
end
end

def fix_punctuation(text)
safe_require('rubypants') ? RubyPants.new(text).to_html : text
end
end

class Engine
Expand Down Expand Up @@ -559,9 +577,8 @@ def self.mime(&block)
ENGINES =
[
Engine.create(:creole, true) {
accepts {|page| page.mime == 'text/x-creole' }
accepts {|page| page.mime == 'text/x-creole' && safe_require('creole') }
output {|page|
require 'creole'
creole = Creole::CreoleParser.new
class << creole
def make_image_link(url)
Expand All @@ -571,25 +588,19 @@ def make_link(url)
escape_url(url).urlpath
end
end
RubyPants.new(creole.parse(page.content)).to_html
fix_punctuation(creole.parse(page.content))
}
},
Engine.create(:markdown, true) {
accepts {|page| page.mime == 'text/x-markdown' }
output {|page|
require 'rdiscount'
RubyPants.new(RDiscount.new(page.content).to_html).to_html
}
accepts {|page| page.mime == 'text/x-markdown' && safe_require('rdiscount') }
output {|page| RDiscount.new(page.content).to_html }
},
Engine.create(:textile, true) {
accepts {|page| page.mime == 'text/x-textile' }
output {|page|
require 'redcloth'
RubyPants.new(RedCloth.new(page.content).to_html).to_html
}
accepts {|page| page.mime == 'text/x-textile' && safe_require('redcloth') }
output {|page| fix_punctuation(RedCloth.new(page.content).to_html) }
},
Engine.create(:code, true) {
accepts {|page| Highlighter.supports?(page.name) }
accepts {|page| Highlighter.installed? && Highlighter.supports?(page.name) }
output {|page| Highlighter.file(page.content, page.name) }
},
Engine.create(:image, true) {
Expand Down

0 comments on commit 4fb60d8

Please sign in to comment.