Permalink
Browse files

Merge branch 'frontend'

  • Loading branch information...
mojombo committed Jul 13, 2010
2 parents e2403bf + baaa7c6 commit 96be504069214b08fc8e63b0cce2a12ae6987051
Showing with 1,319 additions and 55 deletions.
  1. +7 −2 README.md
  2. +4 −0 gollum.gemspec
  3. +41 −1 lib/gollum.rb
  4. +110 −0 lib/gollum/frontend/app.rb
  5. +123 −0 lib/gollum/frontend/public/css/global.css
  6. +55 −0 lib/gollum/frontend/public/css/gollum.css
  7. +345 −0 lib/gollum/frontend/public/css/screen.css
  8. +60 −0 lib/gollum/frontend/public/css/syntax.css
  9. +154 −0 lib/gollum/frontend/public/javascript/jquery-1.4.2.min.js
  10. +18 −0 lib/gollum/frontend/templates/create.mustache
  11. +14 −0 lib/gollum/frontend/templates/edit.mustache
  12. +22 −0 lib/gollum/frontend/templates/layout.mustache
  13. +33 −0 lib/gollum/frontend/templates/page.mustache
  14. +11 −0 lib/gollum/frontend/views/create.rb
  15. +11 −0 lib/gollum/frontend/views/edit.rb
  16. +14 −0 lib/gollum/frontend/views/layout.rb
  17. +35 −0 lib/gollum/frontend/views/page.rb
  18. +36 −24 lib/gollum/markup.rb
  19. +4 −1 lib/gollum/page.rb
  20. +17 −2 lib/gollum/wiki.rb
  21. +92 −0 templates/formatting.html
  22. BIN test/examples/lotr.git/objects/01/676dc56d35c1999c6fe9043fe8b78d52a0e797
  23. BIN test/examples/lotr.git/objects/07/9a5887755dc6fbacfdb672abc168b0cce698fa
  24. BIN test/examples/lotr.git/objects/11/5bbf9fe8004aa6a06274b44ab93a84a06e3204
  25. BIN test/examples/lotr.git/objects/14/78ebf7ad4dc6a06c76cdb4aca0eba7f78796aa
  26. BIN test/examples/lotr.git/objects/1e/716a3178a76fe39ee7b88f0cf2dc4a447566f6
  27. BIN test/examples/lotr.git/objects/28/bb2f40d2e4c82a4ae62ef619a80a4b555e23ee
  28. BIN test/examples/lotr.git/objects/2c/b9156ad383914561a8502fc70f5a1d887e48ad
  29. BIN test/examples/lotr.git/objects/37/fcc52509fb09142cafccaada0252f3de81873c
  30. BIN test/examples/lotr.git/objects/4c/770a352f1e86071b680f879a89874bf59008fa
  31. +3 −0 test/examples/lotr.git/objects/4f/de706c7c8d3b30b6caec8c82ff4c01261350f2
  32. BIN test/examples/lotr.git/objects/71/4323c104239440a5c66ab12a67ed07a83c404f
  33. +1 −0 test/examples/lotr.git/objects/79/8f6564abb42d7ed34621d53595cbbe84638949
  34. BIN test/examples/lotr.git/objects/7c/7251d713278633fbe506e1b74aba6c91ddd562
  35. BIN test/examples/lotr.git/objects/93/633112529b0d0bdf25c2206682e59e9f5572e5
  36. BIN test/examples/lotr.git/objects/a3/46f056d6d8e89f034489e403b3924fbc95f201
  37. +2 −0 test/examples/lotr.git/objects/af/e2034d400ba21e13361f38f74900c51dbc7fde
  38. BIN test/examples/lotr.git/objects/b0/d108328459e44fff4a76cd19b10ddc34adce4b
  39. BIN test/examples/lotr.git/objects/b3/14b19c56ee272a7c9dc379996d9a32f5c463d7
  40. +2 −0 test/examples/lotr.git/objects/bc/d5c99495011915971b2c9e38da8e5aacfe875d
  41. BIN test/examples/lotr.git/objects/d9/e379fdea55b6ff3b71c110b3d2d7b55bbfd5ee
  42. BIN test/examples/lotr.git/objects/e3/415337d9ae2c0b4b00054a93727f4a7d3c3ca5
  43. +2 −0 test/examples/lotr.git/objects/f2/5eccd98e9b667f9e22946f3e2f945378b8a72d
  44. +1 −0 test/examples/lotr.git/objects/f4/46205ac9df5b6a40c00785f06827f4a4dbd727
  45. +3 −0 test/examples/lotr.git/objects/fa/e7ef5344202bba4129abdc13060d9297d99465
  46. +1 −1 test/examples/lotr.git/refs/heads/master
  47. +88 −16 test/test_markup.rb
  48. +1 −1 test/test_page.rb
  49. +9 −7 test/test_wiki.rb
View
@@ -30,6 +30,7 @@ formats and allowed extensions is:
* Textile: .textile
* RDoc: .rdoc
* Org Mode: .org
+ * Creole: .creole
* ReStructured Text: .rest.txt, .rst.txt, .rest, .rst
* ASCIIDoc: .asciidoc
* POD: .pod
@@ -69,10 +70,10 @@ or JavaScript. These tags will be stripped from the converted HTML.
To link to another Gollum wiki page, use the Gollum Page Link Tag.
- [[Frodo]]
+ [[Frodo Baggins]]
The above tag will create a link to the corresponding page file named
-`Frodo.ext` where `ext` may be any of the allowed extension types. The
+`Frodo-Baggins.ext` where `ext` may be any of the allowed extension types. The
conversion is as follows:
1. Replace any spaces (U+0020) with dashes (U+002D)
@@ -230,6 +231,10 @@ Initialize the Gollum::Repo object:
wiki = Gollum::Wiki.new("my-gollum-repo.git")
# => <Gollum::Wiki>
+By default, internal wiki links are all absolute from the root. To specify a different base path, you can send specify the `:base_path` option:
+
+ wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
+
Get the latest version of the given human or canonical page name:
page = wiki.page('page-name')
View
@@ -24,7 +24,11 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = %w[README.md LICENSE]
s.add_dependency('grit', [">= 2.0.0", "< 3.0.0"])
+ s.add_dependency('github-markup', [">= 0.4.0", "< 1.0.0"])
s.add_dependency('albino', "~> 1.0.0")
+ s.add_dependency('sinatra', "~> 1.0.0")
+ s.add_dependency('mustache', [">= 0.11.2", "< 1.0.0"])
+ s.add_dependency('sanitize', "~> 1.0.0")
s.add_development_dependency('shoulda')
s.add_development_dependency('mocha')
View
@@ -1,6 +1,7 @@
# external
require 'grit'
require 'github/markup'
+require 'sanitize'
# internal
require 'gollum/pagination'
@@ -12,4 +13,43 @@
module Gollum
VERSION = '0.0.1'
-end
+
+ SANITIZATION_OPTIONS = {
+ :elements => [
+ 'a', 'abbr', 'acronym', 'address', 'area', 'b', 'big',
+ 'blockquote', 'br', 'button', 'caption', 'center', 'cite',
+ 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dir',
+ 'div', 'dl', 'dt', 'em', 'fieldset', 'font', 'form', 'h1',
+ 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'input',
+ 'ins', 'kbd', 'label', 'legend', 'li', 'map', 'menu',
+ 'ol', 'optgroup', 'option', 'p', 'pre', 'q', 's', 'samp',
+ 'select', 'small', 'span', 'strike', 'strong', 'sub',
+ 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th',
+ 'thead', 'tr', 'tt', 'u', 'ul', 'var'
+ ],
+ :attributes => {
+ :all => ['abbr', 'accept', 'accept-charset',
+ 'accesskey', 'action', 'align', 'alt', 'axis',
+ 'border', 'cellpadding', 'cellspacing', 'char',
+ 'charoff', 'charset', 'checked', 'cite',
+ 'class', 'clear', 'cols', 'colspan', 'color',
+ 'compact', 'coords', 'datetime', 'dir',
+ 'disabled', 'enctype', 'for', 'frame',
+ 'headers', 'height', 'href', 'hreflang',
+ 'hspace', 'id', 'ismap', 'label', 'lang',
+ 'longdesc', 'maxlength', 'media', 'method',
+ 'multiple', 'name', 'nohref', 'noshade',
+ 'nowrap', 'prompt', 'readonly', 'rel', 'rev',
+ 'rows', 'rowspan', 'rules', 'scope',
+ 'selected', 'shape', 'size', 'span', 'src',
+ 'start', 'summary', 'tabindex', 'target',
+ 'title', 'type', 'usemap', 'valign', 'value',
+ 'vspace', 'width']
+ },
+ :protocols => {
+ 'a' => {'href' => ['http', 'https', 'mailto', :relative]},
+ 'img' => {'href' => ['http', 'https', :relative]}
+ }
+ }
+end
+
View
@@ -0,0 +1,110 @@
+require 'rubygems'
+
+require 'sinatra'
+require 'gollum'
+require 'mustache/sinatra'
+
+require 'gollum/frontend/views/layout'
+
+$path = "~/dev/sandbox/lotr2"
+
+module Precious
+ class App < Sinatra::Base
+ register Mustache::Sinatra
+
+ dir = File.dirname(File.expand_path(__FILE__))
+
+ # We want to serve public assets for now
+ set :public, "#{dir}/public"
+ set :static, true
+
+ set :mustache, {
+ # Tell mustache where the Views constant lives
+ :namespace => Precious,
+
+ # Mustache templates live here
+ :templates => "#{dir}/templates",
+
+ # Tell mustache where the views are
+ :views => "#{dir}/views"
+ }
+
+ # Sinatra error handling
+ configure :development, :staging do
+ set :raise_errors, false
+ set :show_exceptions, true
+ set :dump_errors, true
+ set :clean_trace, false
+ end
+
+ get '/' do
+ show_page_or_file('Home')
+ end
+
+ get '/edit/:name' do
+ @name = params[:name]
+ wiki = Gollum::Wiki.new($path)
+ if page = wiki.page(@name)
+ @content = page.raw_data
+ mustache :edit
+ else
+ mustache :create
+ end
+ end
+
+ post '/edit/:name' do
+ name = params[:name]
+ wiki = Gollum::Wiki.new($path)
+ page = wiki.page(name)
+ commit = { :message => 'commit message',
+ :name => 'Tom Preston-Werner',
+ :email => 'tom@github.com' }
+ wiki.update_page(page, params[:content], commit)
+ redirect "/#{name}"
+ end
+
+ post '/create/:page' do
+ page = params[:page]
+ wiki = Gollum::Wiki.new($path)
+ commit = { :message => 'commit message',
+ :name => 'Tom Preston-Werner',
+ :email => 'tom@github.com' }
+ wiki.write_page(page, :markdown, params[:content], commit)
+ redirect "/#{page}"
+ end
+
+ get %r{/(.+?)/([0-9a-f]{40})} do
+ name = params[:captures][0]
+ wiki = Gollum::Wiki.new($path)
+ if page = wiki.page(name, params[:captures][1])
+ @page = page
+ @name = name
+ @content = page.formatted_data
+ mustache :page
+ else
+ halt 404
+ end
+ end
+
+ get '/*' do
+ show_page_or_file(params[:splat].first)
+ end
+
+ def show_page_or_file(name)
+ wiki = Gollum::Wiki.new($path)
+ if page = wiki.page(name)
+ @page = page
+ @name = name
+ @content = page.formatted_data
+ mustache :page
+ elsif file = wiki.file(name)
+ file.raw_data
+ else
+ @name = name
+ mustache :create
+ end
+ end
+ end
+end
+
+Precious::App.run!
@@ -0,0 +1,123 @@
+h1, h2, h3, h4, h5, h6 {
+ color: #f90;
+ font-weight: bold;
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+}
+
+h1 {
+ font-size: 36pt;
+}
+
+h2 {
+ font-size: 32pt;
+}
+
+h3 {
+ font-size: 28pt;
+}
+
+h4 {
+ font-size: 24pt;
+}
+
+h5 {
+ font-size: 20pt;
+}
+
+h6 {
+ font-size: 16pt;
+}
+
+p {
+ font-family: Georgia, serif;
+ font-size: 14pt;
+ line-height: 22pt;
+}
+
+.highlight {
+ border: 1px solid #eee;
+ padding: 0;
+ margin: 0;
+ font-size: 12pt;
+}
+
+.highlight pre {
+ background-color: #f8f8ff;
+ margin: 0;
+ padding: .5em;
+}
+
+#nav {
+ width: 60em;
+ margin: 0 auto;
+ color: #666;
+}
+
+#content {
+ width: 60em;
+ margin: 0 auto;
+ color: #666;
+}
+
+a.absent {
+ color: #a00;
+}
+
+/* Forms */
+
+textarea {
+ width: 100%;
+ height: 20em;
+}
+
+/* Images */
+
+.frame {
+ margin: 1em 0;
+ display: inline-block;
+}
+
+.frame img {
+ display: block;
+}
+
+.frame > span {
+ display: block;
+ border: 1px solid #aaa;
+ padding: 4px;
+}
+
+.frame span span {
+ display: block;
+ font-size: 10pt;
+ margin: 0;
+ padding: 4px 0 2px 0;
+ text-align: center;
+ line-height: 10pt;
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+}
+
+.float-left {
+ float: left;
+ padding: .5em 1em .25em 0;
+}
+
+.float-right {
+ float: right;
+ padding: .5em 0 .25em 1em;
+}
+
+.align-left {
+ display: block;
+ text-align: left;
+}
+
+.align-center {
+ display: block;
+ text-align: center;
+}
+
+.align-right {
+ display: block;
+ text-align: right;
+}
@@ -0,0 +1,55 @@
+a.absent {
+ color: #a00;
+}
+
+/* Images */
+
+.frame {
+ margin: 0;
+ display: inline-block;
+}
+
+.frame img {
+ display: block;
+}
+
+.frame > span {
+ display: block;
+ border: 1px solid #aaa;
+ padding: 4px;
+}
+
+.frame span span {
+ display: block;
+ font-size: 10pt;
+ margin: 0;
+ padding: 4px 0 2px 0;
+ text-align: center;
+ line-height: 10pt;
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+}
+
+.float-left {
+ float: left;
+ padding: .5em 1em .25em 0;
+}
+
+.float-right {
+ float: right;
+ padding: .5em 0 .25em 1em;
+}
+
+.align-left {
+ display: block;
+ text-align: left;
+}
+
+.align-center {
+ display: block;
+ text-align: center;
+}
+
+.align-right {
+ display: block;
+ text-align: right;
+}
Oops, something went wrong.

0 comments on commit 96be504

Please sign in to comment.