stoor 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZmU2OTA0ZjI4ZjY4MWZlZWI1MTQ0OWE2YTI0MGIyYWQxNDk1Mjk4Ng==
5
+ data.tar.gz: !binary |-
6
+ YzVhZWM1MGU5Y2NhMGZkNGJiYmM5OGVhMGVhYzZkODYxYWY0ODQxNA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDJmMDE1YjcyY2E4Yzc4MTEyZmE5MTUwMTg5ZmNjNzVhOWEwZmQyZDcxOGJk
10
+ M2E5NzVjZWMwM2VhOTRiZTZmNDkwNTIxOTQ2Mzc4MGIyMTNiMzJjODM1MDRi
11
+ MmQ3YTE4MGRmZTNkZmVkZjk2MDg4NGZiY2FhNTdlOGU3NGM5ZTg=
12
+ data.tar.gz: !binary |-
13
+ MTIwNzc0NGJhNzRkYWI5MjMzNDEzYmQ2MWY4N2NkOTgxNjgzMTNlNThlNDVl
14
+ NzI3NTBmMWYxMWYwYjJiNzljNmNiYmQ1Yzc1N2U0ZjZiNjkzMTNlYzIwYTgx
15
+ MDYwODRlYTU1ZWFlZWFkNTlkOTNkMDRhMWMxZjM5NTIzMjIwNTM=
data/README.md CHANGED
@@ -106,6 +106,11 @@ If the user is not a member of the specified team, they aren't allowed access.
106
106
 
107
107
  STOOR_WIDE=y # Main wiki content will take 90% of browser width; widens tables as well
108
108
 
109
+ ### Read-only
110
+
111
+ STOOR_READONLY=y # Create, New, Delete buttons and links hidden;
112
+ # /create/*, /delete/*, POST, and PUT requests redirected to "sorry" page
113
+
109
114
  ## How I run it
110
115
 
111
116
  I like having my own personal wiki. Since Apache is ubiquitous on Macs, I run the Wiki with configuration in `/etc/apache2/httpd.conf`,
@@ -145,3 +150,39 @@ and finally:
145
150
 
146
151
  Now browse your wiki at <http://wiki.local>
147
152
 
153
+ ## Links in the Wiki
154
+
155
+ A bit of advice: Use the MediaWiki format for links internal to your wiki. This style is recommended by GitHub (see <https://help.github.com/articles/how-do-i-add-links-to-my-wiki>).
156
+
157
+ For example, if you have a secondary page called `foo.md`, and want a link that displays "This is my foo page", write
158
+ your page link like this
159
+
160
+ ```
161
+ [[This is my foo page|foo]]
162
+ ```
163
+
164
+ Notice that the Gollum docs say "The page file may exist anywhere in the directory structure of the repository. Gollum does a breadth first search and uses the first match that it finds" -- So
165
+ keep your page names unique.
166
+
167
+ If you want to use relative links of the form `[Display text](wiki/other)`, don't. The wikis on GitHub do some wrangling with the base path
168
+ that are not compatible with local wikis managed by Gollum. If you peruse the Gollum documentation at <https://github.com/gollum/gollum/wiki#page-links>, you
169
+ will see that they don't describe the Markdown format at all.
170
+
171
+ (Within a Rack Builder, even if you set the Gollum `base_path` and wrap Gollum in a `map` with the same `base_path` you will find that
172
+ the displayed paths prefix URLs with an extra `base_path`.)
173
+
174
+ ## Things left out
175
+
176
+ * No support for changing the "base path."
177
+ * No support for changing Gollum options - all the default options are taken
178
+
179
+ ## Testing
180
+
181
+ To run the specs, create an application per "GitHub Authorization" above, and take note of the client id and client secret.
182
+
183
+ Then set up Stoor so that you are running with GitHub authorization. Authorize.
184
+
185
+ Now run the specs like so:
186
+
187
+ STOOR_GITHUB_CLIENT_ID=780ec06a331b4f61a345 STOOR_GITHUB_CLIENT_SECRET=f1e5439aff166c34f707747120acbf66ef233fc2 bundle exec rspec
188
+
data/config.ru CHANGED
@@ -87,6 +87,19 @@ if repo_exists
87
87
  regexp: /<body>/,
88
88
  after: '<style type="text/css">#wiki-wrapper { width: 90%; } .markdown-body table { width: 100%; }</style>'
89
89
  end
90
+ if ENV['STOOR_READONLY']
91
+ use Stoor::ReadOnly, '/sorry'
92
+ use Stoor::TransformContent,
93
+ regexp: /<body>/,
94
+ after: <<-STYLE
95
+ <style type="text/css">
96
+ #minibutton-new-page { display: none; }
97
+ #minibutton-rename-page { display: none; }
98
+ a.action-edit-page { display: none; }
99
+ #delete-link { display: none; }
100
+ </style>
101
+ STYLE
102
+ end
90
103
 
91
104
  Precious::App.set(:gollum_path, gollum_path)
92
105
  Precious::App.set(:default_markup, :markdown)
@@ -1,9 +1,11 @@
1
1
  require 'stoor/logger'
2
2
  require 'stoor/github_auth'
3
3
  require 'stoor/git_config'
4
+ require 'stoor/read_only'
4
5
  require 'stoor/transform_content'
5
6
  require 'stoor/views/layout'
6
7
  require 'stoor/views/logout'
8
+ require 'stoor/views/sorry'
7
9
 
8
10
  # In at least gollum 2.4.13 and later:
9
11
  # https://github.com/gollum/gollum/blob/master/lib/gollum/uri_encode_component.rb#L36
@@ -4,17 +4,15 @@ module Stoor
4
4
  register Sinatra::Auth::Github
5
5
  register Mustache::Sinatra
6
6
 
7
- # def initialize(*)
8
- # @github_options = {}
9
- # @stoor_options = {}
10
- # super
11
- # end
12
-
13
7
  get '/logout' do
14
8
  logout!
15
9
  mustache :logout
16
10
  end
17
11
 
12
+ get '/sorry' do
13
+ mustache :sorry
14
+ end
15
+
18
16
  get '/*' do
19
17
  session['stoor.github.authorized'] = nil
20
18
 
@@ -0,0 +1,19 @@
1
+ module Stoor
2
+ class ReadOnly
3
+ include Rack::Utils
4
+
5
+ def initialize(app, path)
6
+ @app, @path = app, path
7
+ end
8
+
9
+ def call(env)
10
+ request = Rack::Request.new(env)
11
+
12
+ if request.path_info =~ /\A\/(create|delete)/ || request.post? || request.put?
13
+ return [302, { 'Location' => @path }, []]
14
+ end
15
+
16
+ @app.call(env)
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Stoor
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
@@ -0,0 +1,5 @@
1
+ <div id="wiki-wrapper" class="page">
2
+ <div class="markdown-body">
3
+ <p>Hey, sorry, this Wiki is read-only.</p>
4
+ </div>
5
+ </div>
@@ -0,0 +1,9 @@
1
+ class Stoor::GithubAuth
2
+ module Views
3
+ class Sorry < Layout
4
+ def self.template_file
5
+ @template_file ||= File.join(File.dirname(__FILE__), 'sorry.mustache')
6
+ end
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stoor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
5
- prerelease:
4
+ version: 0.1.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - John G. Norman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-05 00:00:00.000000000 Z
11
+ date: 2013-11-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thin
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: gollum
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: sinatra_auth_github
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: json
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: grit
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: warden-github
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rack-test
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: rspec
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - ~>
132
116
  - !ruby/object:Gem::Version
@@ -134,7 +118,6 @@ dependencies:
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - ~>
140
123
  - !ruby/object:Gem::Version
@@ -157,11 +140,14 @@ files:
157
140
  - lib/stoor/git_config.rb
158
141
  - lib/stoor/github_auth.rb
159
142
  - lib/stoor/logger.rb
143
+ - lib/stoor/read_only.rb
160
144
  - lib/stoor/transform_content.rb
161
145
  - lib/stoor/version.rb
162
146
  - lib/stoor/views/layout.rb
163
147
  - lib/stoor/views/logout.mustache
164
148
  - lib/stoor/views/logout.rb
149
+ - lib/stoor/views/sorry.mustache
150
+ - lib/stoor/views/sorry.rb
165
151
  - log/.gitignore
166
152
  - public/.gitignore
167
153
  - spec/lib/stoor/git_config_spec.rb
@@ -173,28 +159,27 @@ files:
173
159
  homepage: https://github.com/jgn/stoor
174
160
  licenses:
175
161
  - MIT
162
+ metadata: {}
176
163
  post_install_message:
177
164
  rdoc_options:
178
165
  - --charset=UTF-8
179
166
  require_paths:
180
167
  - lib
181
168
  required_ruby_version: !ruby/object:Gem::Requirement
182
- none: false
183
169
  requirements:
184
170
  - - ! '>='
185
171
  - !ruby/object:Gem::Version
186
172
  version: '0'
187
173
  required_rubygems_version: !ruby/object:Gem::Requirement
188
- none: false
189
174
  requirements:
190
175
  - - ! '>='
191
176
  - !ruby/object:Gem::Version
192
177
  version: '0'
193
178
  requirements: []
194
179
  rubyforge_project:
195
- rubygems_version: 1.8.23
180
+ rubygems_version: 2.1.10
196
181
  signing_key:
197
- specification_version: 3
182
+ specification_version: 4
198
183
  summary: Front-end for Gollum
199
184
  test_files:
200
185
  - spec/lib/stoor/git_config_spec.rb