[ Login and logout ]
This commit is contained in:
parent
551062f92e
commit
fb229b3950
4 changed files with 159 additions and 23 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
require 'gollum/app'
|
require 'gollum/app'
|
||||||
require 'warden'
|
require 'warden'
|
||||||
|
|
||||||
wiki_options = {universal_toc: false, math: :mathjax, css: true}
|
wiki_options = {universal_toc: false, math: :mathjax, css: true, template_dir: 'templates'}
|
||||||
Precious::App.set(:gollum_path, ENV['GOLLUM_WIKI'])
|
Precious::App.set(:gollum_path, ENV['GOLLUM_WIKI'])
|
||||||
Precious::App.set(:default_markup, :markdown)
|
Precious::App.set(:default_markup, :markdown)
|
||||||
Precious::App.set(:wiki_options, wiki_options)
|
Precious::App.set(:wiki_options, wiki_options)
|
||||||
|
|
|
||||||
21
templates/LICENSE
Normal file
21
templates/LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) Tom Preston-Werner, Rick Olson, Dawa Ometto, Bart Kamphorst
|
||||||
|
|
||||||
|
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.
|
||||||
133
templates/navbar.mustache
Normal file
133
templates/navbar.mustache
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
<nav class="TableObject
|
||||||
|
actions
|
||||||
|
border-bottom
|
||||||
|
border-md-0
|
||||||
|
p-2
|
||||||
|
pt-lg-4
|
||||||
|
px-lg-0
|
||||||
|
overflow-x-scroll">
|
||||||
|
<div class="TableObject-item hide-lg hide-xl">
|
||||||
|
{{>mobilenav}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="TableObject-item hide-sm hide-md">
|
||||||
|
<button class="btn btn-sm" id="minibutton-home"
|
||||||
|
onclick="window.location.href='{{page_route}}';"
|
||||||
|
>
|
||||||
|
{{tt.navbar.home_button}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="TableObject-item TableObject-item--primary px-2"
|
||||||
|
{{^search}}style="visibility:hidden"{{/search}}
|
||||||
|
>
|
||||||
|
{{>searchbar}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="TableObject-item hide-sm hide-md">
|
||||||
|
<div class="BtnGroup d-flex">
|
||||||
|
{{#overview}}
|
||||||
|
<button
|
||||||
|
class="btn BtnGroup-item btn-sm"
|
||||||
|
onclick="window.location.href='{{overview_path}}';"
|
||||||
|
id="minibutton-overview"
|
||||||
|
>
|
||||||
|
{{tt.navbar.overview_button}}
|
||||||
|
</button>
|
||||||
|
{{/overview}}
|
||||||
|
|
||||||
|
{{#latest_changes}}
|
||||||
|
<button
|
||||||
|
class="btn BtnGroup-item btn-sm"
|
||||||
|
onclick="window.location.href='{{latest_changes_path}}';"
|
||||||
|
id="minibutton-latest-changes"
|
||||||
|
>
|
||||||
|
{{tt.navbar.latest_changes_button}}
|
||||||
|
</button>
|
||||||
|
{{/latest_changes}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="TableObject-item px-2">
|
||||||
|
<div class="BtnGroup d-flex">
|
||||||
|
{{#history}}
|
||||||
|
<button
|
||||||
|
class="btn BtnGroup-item btn-sm hide-sm hide-md"
|
||||||
|
onclick="window.location.href='{{history_path}}/{{escaped_url_path}}/{{version}}';"
|
||||||
|
id="minibutton-history"
|
||||||
|
>
|
||||||
|
{{tt.navbar.history_button}}
|
||||||
|
</button>
|
||||||
|
{{/history}}
|
||||||
|
|
||||||
|
{{#allow_editing}}
|
||||||
|
{{#allow_uploads}}
|
||||||
|
<button
|
||||||
|
class="btn BtnGroup-item btn-sm hide-sm hide-md minibutton-upload-page"
|
||||||
|
>
|
||||||
|
{{tt.navbar.upload_button}}
|
||||||
|
</button>
|
||||||
|
{{/allow_uploads}}
|
||||||
|
|
||||||
|
{{#editable}}
|
||||||
|
<button
|
||||||
|
class="btn BtnGroup-item btn-sm hide-sm hide-md minibutton-rename-page"
|
||||||
|
>
|
||||||
|
{{tt.navbar.rename_button}}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="btn BtnGroup-item btn-sm hide-sm hide-md"
|
||||||
|
onclick="window.location.href='{{edit_path}}/{{escaped_url_path}}';"
|
||||||
|
id="minibutton-edit-page"
|
||||||
|
>
|
||||||
|
{{tt.navbar.edit_button}}
|
||||||
|
</button>
|
||||||
|
{{/editable}}
|
||||||
|
{{/allow_editing}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{#allow_editing}}
|
||||||
|
{{#editable}}
|
||||||
|
<div class="TableObject-item">
|
||||||
|
<button class="btn btn-primary btn-sm minibutton-new-page">
|
||||||
|
{{tt.navbar.new_button}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{{/editable}}
|
||||||
|
|
||||||
|
{{^editable}}
|
||||||
|
{{#newable}}
|
||||||
|
<div class="TableObject-item">
|
||||||
|
<button class="btn btn-primary btn-sm minibutton-new-page">
|
||||||
|
{{tt.navbar.new_button}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{{/newable}}
|
||||||
|
{{/editable}}
|
||||||
|
{{/allow_editing}}
|
||||||
|
|
||||||
|
{{#allow_editing}}
|
||||||
|
<div class="TableObject-item px-2">
|
||||||
|
<div class="BtnGroup d-flex">
|
||||||
|
<button
|
||||||
|
class="btn btn-primary btn-sm minibutton-logout"
|
||||||
|
onclick="window.location.href='/logout';">
|
||||||
|
Logout {{!tt.navbar.logout_button}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/allow_editing}}
|
||||||
|
|
||||||
|
{{^allow_editing}}
|
||||||
|
<div class="TableObject-item px-2">
|
||||||
|
<button
|
||||||
|
class="btn btn-primary btn-sm minibutton-login"
|
||||||
|
onclick="window.location.href='/login';"
|
||||||
|
>
|
||||||
|
Login {{!tt.navbar.login_button}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{{/allow_editing}}
|
||||||
|
</nav>
|
||||||
26
tonton.rb
26
tonton.rb
|
|
@ -98,31 +98,13 @@ class TonTon::App < Precious::App
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
public_patterns = [
|
if not env['warden'].authenticated?
|
||||||
'/',
|
@allow_editing = false
|
||||||
'/*',
|
else
|
||||||
'/login',
|
@allow_editing = true
|
||||||
'/logout',
|
|
||||||
'/unauthenticated',
|
|
||||||
'/gollum/*',
|
|
||||||
'/gollum/history/**',
|
|
||||||
'/gollum/latest_changes',
|
|
||||||
'/gollum/commit/**'
|
|
||||||
]
|
|
||||||
|
|
||||||
request_path = Pathname.new(request.path_info)
|
|
||||||
|
|
||||||
looks_public = false
|
|
||||||
|
|
||||||
for pattern in public_patterns
|
|
||||||
if request_path.fnmatch(pattern, File::FNM_PATHNAME)
|
|
||||||
looks_public = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not looks_public then check_authentication end
|
|
||||||
end
|
|
||||||
|
|
||||||
post '/unauthenticated' do
|
post '/unauthenticated' do
|
||||||
session['warden.return_to'] = env['warden.options'][:attempted_path]
|
session['warden.return_to'] = env['warden.options'][:attempted_path]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue