From fb229b39502506c8b4c8204f28036f6f26cb7f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateus=20Cez=C3=A1rio=20Barreto?= Date: Sun, 2 Nov 2025 17:36:00 -0300 Subject: [PATCH] [ Login and logout ] --- config.ru | 2 +- templates/LICENSE | 21 ++++++ templates/navbar.mustache | 133 ++++++++++++++++++++++++++++++++++++++ tonton.rb | 26 ++------ 4 files changed, 159 insertions(+), 23 deletions(-) create mode 100644 templates/LICENSE create mode 100644 templates/navbar.mustache diff --git a/config.ru b/config.ru index 6b45665..100b3eb 100644 --- a/config.ru +++ b/config.ru @@ -1,7 +1,7 @@ require 'gollum/app' 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(:default_markup, :markdown) Precious::App.set(:wiki_options, wiki_options) diff --git a/templates/LICENSE b/templates/LICENSE new file mode 100644 index 0000000..6c84153 --- /dev/null +++ b/templates/LICENSE @@ -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. \ No newline at end of file diff --git a/templates/navbar.mustache b/templates/navbar.mustache new file mode 100644 index 0000000..8640086 --- /dev/null +++ b/templates/navbar.mustache @@ -0,0 +1,133 @@ + diff --git a/tonton.rb b/tonton.rb index 6ea7092..41d0dbf 100644 --- a/tonton.rb +++ b/tonton.rb @@ -98,29 +98,11 @@ class TonTon::App < Precious::App end before do - public_patterns = [ - '/', - '/*', - '/login', - '/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 + if not env['warden'].authenticated? + @allow_editing = false + else + @allow_editing = true end - - if not looks_public then check_authentication end end post '/unauthenticated' do