Initial Sinatra project structure

This commit is contained in:
Gregory Ballantine 2022-12-10 01:59:30 -05:00
parent 7bc5ef2e82
commit bdc316ba9e
11 changed files with 158 additions and 0 deletions

7
Gemfile Normal file
View File

@ -0,0 +1,7 @@
source 'https://rubygems.org'
gem 'sinatra', '~> 3.0'
gem 'puma', '~> 6.0'
gem 'rerun'

38
Gemfile.lock Normal file
View File

@ -0,0 +1,38 @@
GEM
remote: https://rubygems.org/
specs:
ffi (1.15.5)
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.8)
puma (6.0.0)
nio4r (~> 2.0)
rack (2.2.4)
rack-protection (3.0.4)
rack
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rerun (0.13.1)
listen (~> 3.0)
ruby2_keywords (0.0.5)
sinatra (3.0.4)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.0.4)
tilt (~> 2.0)
tilt (2.0.11)
PLATFORMS
x86_64-linux
DEPENDENCIES
puma (~> 6.0)
rerun
sinatra (~> 3.0)
BUNDLED WITH
2.3.5

11
Rakefile Normal file
View File

@ -0,0 +1,11 @@
require 'bundler/setup'
namespace :server do
task :dev do
%x{puma -C puma.rb}
end
task :reload do
%x{rerun --no-notify 'puma -C puma.rb'}
end
end

9
app/controllers/auth.rb Normal file
View File

@ -0,0 +1,9 @@
class AuthController < Sinatra::Base
get '/login' do
erb :'auth/login', :locals => {
:title => 'Login to your account'
}
end
end

9
app/controllers/index.rb Normal file
View File

@ -0,0 +1,9 @@
class IndexController < Sinatra::Base
get '/' do
erb :index, :locals => {
:title => 'Home'
}
end
end

10
app/settings.rb Normal file
View File

@ -0,0 +1,10 @@
class Sinatra::Base
configure do
enable :sessions
set :views, './views'
set :public_folder, './public'
end
end

15
config.ru Normal file
View File

@ -0,0 +1,15 @@
require 'rubygems'
require 'sinatra/base'
require_relative 'app/settings.rb'
require_relative 'app/controllers/index.rb'
require_relative 'app/controllers/auth.rb'
map "/" do
run IndexController
end
map "/auth" do
run AuthController
end

8
puma.rb Normal file
View File

@ -0,0 +1,8 @@
root = Dir.getwd.to_s
bind 'tcp://0.0.0.0:3108'
pidfile '/tmp/puma.pid'
state_path '/tmp/puma.state'
rackup root.to_s + '/config.ru'
threads 4, 8

30
views/auth/login.erb Normal file
View File

@ -0,0 +1,30 @@
<div class="row">
<div class="twelve columns">
<form action="/auth/login" method="POST" class="u-full-width">
<div class="row">
<div class="three columns"><p></p></div>
<div class="six columns">
<label for="auth_username">Username:</label>
<input id="auth_username" class="u-full-width" type="text" name="auth_username" required>
</div>
</div>
<div class="row">
<div class="three columns"><p></p></div>
<div class="six columns">
<label for="auth_password">Password:</label>
<input id="auth_password" class="u-full-width" type="text" name="auth_password" required>
</div>
</div>
<div class="row">
<div class="three columns"><p></p></div>
<div class="six columns">
<input class="button button-primary u-full-width" type="submit" value="Login!">
</div>
</div>
</form>
</div>
</div>

6
views/index.erb Normal file
View File

@ -0,0 +1,6 @@
<div class="row">
<div class="twelve columns">
<h1>Welcome to Webdap!</h1>
<p>You can use this site to manage your network account. <a href="/auth/login">Click here</a> to login.</p>
</div>
</div>

15
views/layout.erb Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= title %> | Webdap</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
</head>
<body>
<div id="main-wrapper" class="container">
<%= yield %>
</div>
</body>
</html>