Added some more scaffolding to the project to get going; added Foundation css to start with styles

This commit is contained in:
Gregory Ballantine 2023-07-03 23:02:25 -04:00
parent b376bf3a79
commit 6f680e72e5
12 changed files with 121 additions and 12 deletions

View File

@ -4,3 +4,8 @@ gem 'sinatra', '~> 3.0'
gem 'sinatra-contrib', '~> 3.0'
gem 'puma', '~> 6.3'
group :development, :test do
gem 'rerun'
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
end

View File

@ -1,6 +1,10 @@
GEM
remote: https://rubygems.org/
specs:
ffi (1.15.5)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
multi_json (1.15.0)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
@ -10,6 +14,11 @@ GEM
rack (2.2.7)
rack-protection (3.0.6)
rack
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rerun (0.14.0)
listen (~> 3.0)
ruby2_keywords (0.0.5)
sinatra (3.0.6)
mustermann (~> 3.0)
@ -29,6 +38,7 @@ PLATFORMS
DEPENDENCIES
puma (~> 6.3)
rerun
sinatra (~> 3.0)
sinatra-contrib (~> 3.0)

View File

@ -1,8 +1,19 @@
require 'bundler/setup'
task :setup do
# Set bundle to install gems to local vendor path
system("bundle config set --local path 'vendor/bundle'")
# Install gems
system("bundle install")
end
namespace :server do
task :start do
ENV['APP_ENV'] = 'production'
system("puma")
end
end
task :dev do
system('rerun --quiet --dir="src/" puma')
end
end

View File

@ -1,3 +1,3 @@
root = ::File.dirname(__FILE__)
require ::File.join( root, 'server' )
require ::File.join( root, 'src', 'server' )
run GameData.new

View File

@ -0,0 +1,3 @@
#main-nav{
margin-bottom: 15px;
}

5
public/js/edgeville.js Normal file
View File

@ -0,0 +1,5 @@
$(document).ready(function() {
$(document).foundation();
});

View File

@ -1,9 +0,0 @@
require 'sinatra/base'
# Base app
class GameData < Sinatra::Base
enable :sessions
end
# Load routes
require_relative 'src/routes/init'

View File

@ -1,6 +1,9 @@
class GameData < Sinatra::Base
get '/' do
return 'Test.'
erb :'index/index', locals: {
title: 'Test!!!',
results: []
}
end
# more routes...

16
src/server.rb Executable file
View File

@ -0,0 +1,16 @@
require 'sinatra/base'
# Base app
class GameData < Sinatra::Base
enable :sessions
# Set up static file serving
enable :static
set :public_folder, File.join(__dir__, '/../public')
# Set up our view engine
set :views, File.join(settings.root, '/../views')
end
# Load routes
require_relative 'routes/init'

31
views/index/index.erb Normal file
View File

@ -0,0 +1,31 @@
<div class="grid-x grid-margin-x">
<% if results.length > 0 %>
<div class="cell small-12">
<h2>Latest benchmark results:</h2>
</div>
<div class="cell small-12">
<table>
<thead>
<tr>
<th width="200">Hardware tested</th>
<th width="200">Benchmark used</th>
<th>Score</th>
</tr>
</thead>
<tbody>
<% results.each do |r| %>
<tr>
<td><%= r.hardware %></td>
<td><%= r.benchmark %></td>
<td><%= r.formatted_score() %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<div class="cell small-12">
<p>I'm sorry, there don't appear to be any benchmark results logged yet. Check again later!</p>
</div>
<% end %>
</div>

23
views/layout.erb Normal file
View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title><%= title %> | Game Data</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.7.5/css/foundation.min.css">
<link rel="stylesheet" href="/css/remmington.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.7.5/js/foundation.min.js" charset="utf-8"></script>
<script src="/js/edgeville.js" charset="utf-8"></script>
</head>
<body>
<!-- main navigation -->
<%= erb :'partials/navbar', :locals => locals %>
<!-- main content -->
<div class="grid-container">
<%= yield %>
</div>
</body>
</html>

11
views/partials/navbar.erb Normal file
View File

@ -0,0 +1,11 @@
<div id="main-nav" class="top-bar">
<div class="top-bar-left">
<ul class="menu">
<li><a href="/">Dashboard</a></li>
<li><a href="/hardware">Hardware</a></li>
<li><a href="/benchmarks">Benchmarks</a></li>
<li><a href="/comparisons">Comparisons</a></li>
<li><a href="/results">Results</a></li>
</ul>
</div>
</div>