Initial project structure with some barebones layout, CSS and JS from game-data
This commit is contained in:
12
.gitignore
vendored
12
.gitignore
vendored
@@ -56,3 +56,15 @@ build-iPhoneSimulator/
|
|||||||
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
||||||
# .rubocop-https?--*
|
# .rubocop-https?--*
|
||||||
|
|
||||||
|
# Ignore local data
|
||||||
|
data/
|
||||||
|
|
||||||
|
# Node modules
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Compiled assets
|
||||||
|
public/*/
|
||||||
|
|
||||||
|
# Ignore production configuration files to protect against credential leaks
|
||||||
|
config/production.yaml
|
||||||
|
|
||||||
|
18
Dockerfile.dev
Normal file
18
Dockerfile.dev
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
FROM ruby:3.4
|
||||||
|
|
||||||
|
RUN gem install bundler
|
||||||
|
|
||||||
|
WORKDIR /usr/src/muldap
|
||||||
|
|
||||||
|
COPY Gemfile Gemfile.l*ck ./
|
||||||
|
|
||||||
|
RUN bundle check || bundle install
|
||||||
|
|
||||||
|
RUN gem install rake
|
||||||
|
|
||||||
|
COPY . ./
|
||||||
|
|
||||||
|
ENV RACK_ENV=development
|
||||||
|
|
||||||
|
ENTRYPOINT ["bundle", "exec", "puma"]
|
||||||
|
|
13
Dockerfile.gulp
Normal file
13
Dockerfile.gulp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Node.js runtime
|
||||||
|
FROM node:24
|
||||||
|
|
||||||
|
WORKDIR /usr/src/muldap/
|
||||||
|
|
||||||
|
COPY package.* /usr/src/muldap/
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
VOLUME /usr/src/muldap/node_modules/
|
||||||
|
|
||||||
|
# Run the app
|
||||||
|
CMD [ "npm", "run", "gulp" ]
|
21
Gemfile
Normal file
21
Gemfile
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
|
gem 'sinatra', '~> 4.1'
|
||||||
|
gem 'sinatra-contrib', '~> 4.1'
|
||||||
|
gem 'puma', '~> 6.6'
|
||||||
|
|
||||||
|
gem 'logger'
|
||||||
|
|
||||||
|
group :development, :test do
|
||||||
|
gem 'rerun'
|
||||||
|
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
|
||||||
|
|
||||||
|
# rubocop and extensions for code style
|
||||||
|
gem 'rubocop'
|
||||||
|
gem 'rubocop-rspec'
|
||||||
|
end
|
||||||
|
|
||||||
|
group :test do
|
||||||
|
gem 'rspec'
|
||||||
|
gem 'rack-test'
|
||||||
|
end
|
129
Gemfile.lock
Normal file
129
Gemfile.lock
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
GEM
|
||||||
|
remote: https://rubygems.org/
|
||||||
|
specs:
|
||||||
|
ast (2.4.3)
|
||||||
|
base64 (0.3.0)
|
||||||
|
diff-lcs (1.6.2)
|
||||||
|
ffi (1.17.2)
|
||||||
|
ffi (1.17.2-aarch64-linux-gnu)
|
||||||
|
ffi (1.17.2-aarch64-linux-musl)
|
||||||
|
ffi (1.17.2-arm-linux-gnu)
|
||||||
|
ffi (1.17.2-arm-linux-musl)
|
||||||
|
ffi (1.17.2-arm64-darwin)
|
||||||
|
ffi (1.17.2-x86-linux-gnu)
|
||||||
|
ffi (1.17.2-x86-linux-musl)
|
||||||
|
ffi (1.17.2-x86_64-darwin)
|
||||||
|
ffi (1.17.2-x86_64-linux-gnu)
|
||||||
|
ffi (1.17.2-x86_64-linux-musl)
|
||||||
|
json (2.13.2)
|
||||||
|
language_server-protocol (3.17.0.5)
|
||||||
|
lint_roller (1.1.0)
|
||||||
|
listen (3.9.0)
|
||||||
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||||
|
rb-inotify (~> 0.9, >= 0.9.10)
|
||||||
|
logger (1.7.0)
|
||||||
|
multi_json (1.17.0)
|
||||||
|
mustermann (3.0.4)
|
||||||
|
ruby2_keywords (~> 0.0.1)
|
||||||
|
nio4r (2.7.4)
|
||||||
|
parallel (1.27.0)
|
||||||
|
parser (3.3.9.0)
|
||||||
|
ast (~> 2.4.1)
|
||||||
|
racc
|
||||||
|
prism (1.4.0)
|
||||||
|
puma (6.6.1)
|
||||||
|
nio4r (~> 2.0)
|
||||||
|
racc (1.8.1)
|
||||||
|
rack (3.2.0)
|
||||||
|
rack-protection (4.1.1)
|
||||||
|
base64 (>= 0.1.0)
|
||||||
|
logger (>= 1.6.0)
|
||||||
|
rack (>= 3.0.0, < 4)
|
||||||
|
rack-session (2.1.1)
|
||||||
|
base64 (>= 0.1.0)
|
||||||
|
rack (>= 3.0.0)
|
||||||
|
rack-test (2.2.0)
|
||||||
|
rack (>= 1.3)
|
||||||
|
rainbow (3.1.1)
|
||||||
|
rb-fsevent (0.11.2)
|
||||||
|
rb-inotify (0.11.1)
|
||||||
|
ffi (~> 1.0)
|
||||||
|
regexp_parser (2.11.2)
|
||||||
|
rerun (0.14.0)
|
||||||
|
listen (~> 3.0)
|
||||||
|
rspec (3.13.1)
|
||||||
|
rspec-core (~> 3.13.0)
|
||||||
|
rspec-expectations (~> 3.13.0)
|
||||||
|
rspec-mocks (~> 3.13.0)
|
||||||
|
rspec-core (3.13.5)
|
||||||
|
rspec-support (~> 3.13.0)
|
||||||
|
rspec-expectations (3.13.5)
|
||||||
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
|
rspec-support (~> 3.13.0)
|
||||||
|
rspec-mocks (3.13.5)
|
||||||
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
|
rspec-support (~> 3.13.0)
|
||||||
|
rspec-support (3.13.5)
|
||||||
|
rubocop (1.80.1)
|
||||||
|
json (~> 2.3)
|
||||||
|
language_server-protocol (~> 3.17.0.2)
|
||||||
|
lint_roller (~> 1.1.0)
|
||||||
|
parallel (~> 1.10)
|
||||||
|
parser (>= 3.3.0.2)
|
||||||
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
|
regexp_parser (>= 2.9.3, < 3.0)
|
||||||
|
rubocop-ast (>= 1.46.0, < 2.0)
|
||||||
|
ruby-progressbar (~> 1.7)
|
||||||
|
unicode-display_width (>= 2.4.0, < 4.0)
|
||||||
|
rubocop-ast (1.46.0)
|
||||||
|
parser (>= 3.3.7.2)
|
||||||
|
prism (~> 1.4)
|
||||||
|
rubocop-rspec (3.6.0)
|
||||||
|
lint_roller (~> 1.1)
|
||||||
|
rubocop (~> 1.72, >= 1.72.1)
|
||||||
|
ruby-progressbar (1.13.0)
|
||||||
|
ruby2_keywords (0.0.5)
|
||||||
|
sinatra (4.1.1)
|
||||||
|
logger (>= 1.6.0)
|
||||||
|
mustermann (~> 3.0)
|
||||||
|
rack (>= 3.0.0, < 4)
|
||||||
|
rack-protection (= 4.1.1)
|
||||||
|
rack-session (>= 2.0.0, < 3)
|
||||||
|
tilt (~> 2.0)
|
||||||
|
sinatra-contrib (4.1.1)
|
||||||
|
multi_json (>= 0.0.2)
|
||||||
|
mustermann (~> 3.0)
|
||||||
|
rack-protection (= 4.1.1)
|
||||||
|
sinatra (= 4.1.1)
|
||||||
|
tilt (~> 2.0)
|
||||||
|
tilt (2.6.1)
|
||||||
|
unicode-display_width (3.1.5)
|
||||||
|
unicode-emoji (~> 4.0, >= 4.0.4)
|
||||||
|
unicode-emoji (4.0.4)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
aarch64-linux-gnu
|
||||||
|
aarch64-linux-musl
|
||||||
|
arm-linux-gnu
|
||||||
|
arm-linux-musl
|
||||||
|
arm64-darwin
|
||||||
|
ruby
|
||||||
|
x86-linux-gnu
|
||||||
|
x86-linux-musl
|
||||||
|
x86_64-darwin
|
||||||
|
x86_64-linux-gnu
|
||||||
|
x86_64-linux-musl
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
logger
|
||||||
|
puma (~> 6.6)
|
||||||
|
rack-test
|
||||||
|
rerun
|
||||||
|
rspec
|
||||||
|
rubocop
|
||||||
|
rubocop-rspec
|
||||||
|
sinatra (~> 4.1)
|
||||||
|
sinatra-contrib (~> 4.1)
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
2.6.9
|
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2025 gballan.
|
Copyright (c) 2025 Metaunix.net.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
23
Rakefile
Normal file
23
Rakefile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
require 'bundler/setup'
|
||||||
|
|
||||||
|
namespace :server do
|
||||||
|
task :start do
|
||||||
|
ENV['RACK_ENV'] = 'production'
|
||||||
|
system("puma")
|
||||||
|
end
|
||||||
|
|
||||||
|
task :dev do
|
||||||
|
system('rerun --no-notify --dir="src/" puma')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
namespace :test do
|
||||||
|
task :unit do
|
||||||
|
ENV['RACK_ENV'] = 'testing'
|
||||||
|
system("rspec")
|
||||||
|
end
|
||||||
|
|
||||||
|
task :lint do
|
||||||
|
system("rubocop src/ spec/")
|
||||||
|
end
|
||||||
|
end
|
3
assets/scripts/tirannwn.coffee
Normal file
3
assets/scripts/tirannwn.coffee
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
$ ->
|
||||||
|
# let us know when javascript is running.
|
||||||
|
console.log('Ready.')
|
33
assets/styles/lletya.sass
Normal file
33
assets/styles/lletya.sass
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
@use "sass:color"
|
||||||
|
|
||||||
|
//$primary-color: #3399ff
|
||||||
|
$primary-color: orangered
|
||||||
|
$primary-color-highlight: color.adjust($primary-color, $lightness: -10%)
|
||||||
|
|
||||||
|
html
|
||||||
|
width: 100%
|
||||||
|
height: 100%
|
||||||
|
|
||||||
|
body
|
||||||
|
background: rgb(240, 235, 248)
|
||||||
|
|
||||||
|
table
|
||||||
|
border: 1px solid #666
|
||||||
|
|
||||||
|
a
|
||||||
|
transition: color 220ms ease-in-out
|
||||||
|
|
||||||
|
#wrapper
|
||||||
|
background: white
|
||||||
|
padding: 1.5rem 2rem
|
||||||
|
border: 1px solid #bbb
|
||||||
|
border-radius: 8px
|
||||||
|
|
||||||
|
#main-nav
|
||||||
|
li
|
||||||
|
a
|
||||||
|
font-size: 1.25rem
|
||||||
|
|
||||||
|
#site-title
|
||||||
|
img
|
||||||
|
max-height: 40px
|
2
bin/docker-build.bat
Normal file
2
bin/docker-build.bat
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
docker build -t muldap -f Dockerfile.dev .
|
||||||
|
docker build -t muldap-gulp -f Dockerfile.gulp .
|
5
bin/docker-build.sh
Executable file
5
bin/docker-build.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
docker build -t muldap -f Dockerfile.dev .
|
||||||
|
docker build -t muldap-gulp -f Dockerfile.gulp .
|
||||||
|
|
1
bin/docker-rake.bat
Normal file
1
bin/docker-rake.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
docker exec muldap rake %*
|
3
bin/docker-rake.sh
Executable file
3
bin/docker-rake.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
docker exec muldap rake "$@"
|
2
bin/docker-run.bat
Normal file
2
bin/docker-run.bat
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
docker run --rm -d -t -v "%cd%:/usr/src/muldap" -p 9300:9300 --name muldap muldap
|
||||||
|
docker run --rm -d -t -v "%cd%:/usr/src/muldap" --name muldap-gulp muldap-gulp npm run gulp watch
|
5
bin/docker-run.sh
Executable file
5
bin/docker-run.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
docker run --rm -d -t -v "$(pwd):/usr/src/muldap" -p 9300:9300 --name muldap muldap
|
||||||
|
docker run --rm -d -t -v "$(pwd):/usr/src/muldap" --name muldap-gulp muldap-gulp npm run gulp watch
|
||||||
|
|
6
bin/setup-dev.sh
Executable file
6
bin/setup-dev.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Configure bundler to use local vendor path
|
||||||
|
bundle config set --local path 'vendor/bundle'
|
||||||
|
# Install gems
|
||||||
|
bundle install
|
5
config.ru
Normal file
5
config.ru
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Load application config
|
||||||
|
|
||||||
|
root = ::File.dirname(__FILE__)
|
||||||
|
require ::File.join( root, 'src', 'server' )
|
||||||
|
run GameData.new
|
3
config/defaults.yaml
Normal file
3
config/defaults.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
server:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: '9300'
|
11
config/puma.rb
Normal file
11
config/puma.rb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
app_dir = File.expand_path('..', __dir__)
|
||||||
|
directory app_dir
|
||||||
|
|
||||||
|
environment ENV.fetch('RACK_ENV', 'development')
|
||||||
|
|
||||||
|
require_relative '../src/config'
|
||||||
|
conf = Config.new()
|
||||||
|
|
||||||
|
bind "tcp://#{conf.get('server.host')}:#{conf.get('server.port')}"
|
||||||
|
workers 2
|
||||||
|
threads 1, 5
|
0
data/.gitkeep
Normal file
0
data/.gitkeep
Normal file
57
gulpfile.js
Normal file
57
gulpfile.js
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
const gulp = require('gulp');
|
||||||
|
const sass = require('gulp-sass')(require('sass'));
|
||||||
|
const coffee = require('gulp-coffee');
|
||||||
|
const sourcemaps = require('gulp-sourcemaps');
|
||||||
|
const plumber = require('gulp-plumber');
|
||||||
|
|
||||||
|
// Compile .sass files to compressed CSS
|
||||||
|
function compileSass() {
|
||||||
|
return gulp.src('assets/styles/**/*.sass')
|
||||||
|
.pipe(plumber())
|
||||||
|
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
|
||||||
|
.pipe(gulp.dest('public/css'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compile .coffee files to JavaScript with source maps
|
||||||
|
function compileCoffee() {
|
||||||
|
return gulp.src('assets/scripts/**/*.coffee', { sourcemaps: true })
|
||||||
|
.pipe(plumber())
|
||||||
|
.pipe(coffee({ bare: true }))
|
||||||
|
.pipe(gulp.dest('public/js', { sourcemaps: '.' }));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy image files to public/img/
|
||||||
|
function copyImages() {
|
||||||
|
return gulp.src('assets/img/**/*', {encoding: false})
|
||||||
|
.pipe(gulp.dest('public/img/'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch files for changes
|
||||||
|
function watchFiles(cb) {
|
||||||
|
gulp.watch('assets/styles/**/*.sass', compileSass);
|
||||||
|
gulp.watch('assets/scripts/**/*.coffee', compileCoffee);
|
||||||
|
gulp.watch('assets/img/**/*', copyImages)
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Chain all asset builds together
|
||||||
|
function buildAssets() {
|
||||||
|
return gulp.parallel(compileSass, compileCoffee, copyImages);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform initial build then watch
|
||||||
|
function buildAndWatch() {
|
||||||
|
return gulp.series(
|
||||||
|
buildAssets(),
|
||||||
|
watchFiles
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// one-time build
|
||||||
|
exports.build = buildAssets();
|
||||||
|
|
||||||
|
// start builds with file watching
|
||||||
|
exports.watch = buildAndWatch();
|
||||||
|
|
||||||
|
// Define default task (defaults to watch)
|
||||||
|
exports.default = exports.watch;
|
28
package.json
Normal file
28
package.json
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "muldap",
|
||||||
|
"description": "Self-service frontend for LDAP users.",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"main": "src/server.rb",
|
||||||
|
"scripts": {
|
||||||
|
"gulp": "gulp"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.metaunix.net/Metaunix/muldap"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"ldap",
|
||||||
|
"user",
|
||||||
|
"account"
|
||||||
|
],
|
||||||
|
"author": "Gregory Ballantine <gballantine@metaunix.net>",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"devDependencies": {
|
||||||
|
"gulp": "^5.0.1",
|
||||||
|
"gulp-coffee": "^3.0.3",
|
||||||
|
"gulp-plumber": "^1.2.1",
|
||||||
|
"gulp-sass": "^6.0.1",
|
||||||
|
"gulp-sourcemaps": "^3.0.0",
|
||||||
|
"sass": "^1.89.2"
|
||||||
|
}
|
||||||
|
}
|
0
public/.gitkeep
Normal file
0
public/.gitkeep
Normal file
7
src/appinfo.rb
Normal file
7
src/appinfo.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module AppInfo
|
||||||
|
|
||||||
|
VERSION = '0.1.0'
|
||||||
|
|
||||||
|
end
|
29
src/config.rb
Normal file
29
src/config.rb
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'yaml'
|
||||||
|
|
||||||
|
# Config - loads and manages the app's configuration
|
||||||
|
class Config
|
||||||
|
|
||||||
|
DEFAULT_CONFIG = 'config/defaults.yaml'
|
||||||
|
ENVIRONMENT_CONFIG = ENV.fetch('RACK_ENV', 'development')
|
||||||
|
|
||||||
|
def initialize(config_path = "config/#{ENVIRONMENT_CONFIG}.yaml")
|
||||||
|
@data = YAML.load_file(DEFAULT_CONFIG)
|
||||||
|
|
||||||
|
# merge in user-defined configuration if it exists
|
||||||
|
@data.merge!(YAML.load_file(config_path)) if File.exist?(config_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get(key)
|
||||||
|
bits = key.split('.')
|
||||||
|
value = @data
|
||||||
|
|
||||||
|
bits.each do |bit|
|
||||||
|
value = value[bit]
|
||||||
|
end
|
||||||
|
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
15
src/controllers/base_controller.rb
Normal file
15
src/controllers/base_controller.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'sinatra/base'
|
||||||
|
|
||||||
|
# BaseController - base modular Sinatra app class
|
||||||
|
class BaseController < Sinatra::Base
|
||||||
|
|
||||||
|
# Register view helpers
|
||||||
|
require_relative '../helpers'
|
||||||
|
helpers Helpers
|
||||||
|
|
||||||
|
# Set up our view engine
|
||||||
|
set :views, File.join(settings.root, '/../../views')
|
||||||
|
|
||||||
|
end
|
14
src/controllers/index.rb
Normal file
14
src/controllers/index.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require_relative 'base_controller'
|
||||||
|
|
||||||
|
# / (top-level) routes
|
||||||
|
class IndexController < BaseController
|
||||||
|
|
||||||
|
get '/' do
|
||||||
|
erb :'toplevel/dashboard', locals: {
|
||||||
|
title: 'Dashboard'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
31
src/helpers.rb
Normal file
31
src/helpers.rb
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require_relative 'appinfo'
|
||||||
|
|
||||||
|
# Helpers - view helper functions
|
||||||
|
module Helpers
|
||||||
|
|
||||||
|
def ruby_version
|
||||||
|
return RUBY_VERSION
|
||||||
|
end
|
||||||
|
|
||||||
|
def app_version
|
||||||
|
return AppInfo::VERSION
|
||||||
|
end
|
||||||
|
|
||||||
|
def date_format(date)
|
||||||
|
dt = date.to_datetime
|
||||||
|
return dt.strftime('%B %d, %Y @ %I:%M:%S %p %Z')
|
||||||
|
end
|
||||||
|
|
||||||
|
def average_array(arr, decimals = 1)
|
||||||
|
sum = 0
|
||||||
|
|
||||||
|
arr.each do |i|
|
||||||
|
sum += i
|
||||||
|
end
|
||||||
|
|
||||||
|
return (sum / arr.length).round(decimals)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
27
src/server.rb
Normal file
27
src/server.rb
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'sinatra/base'
|
||||||
|
|
||||||
|
require_relative 'config'
|
||||||
|
|
||||||
|
# Load configuration from environment config file
|
||||||
|
$conf = Config.new()
|
||||||
|
|
||||||
|
# Load in routes
|
||||||
|
require_relative 'controllers/index'
|
||||||
|
|
||||||
|
# GameData - main app that gets launched
|
||||||
|
# - inherits from Sinatra::Base to instantiate the server
|
||||||
|
# - sets up some base app configuration
|
||||||
|
# - registers route classes with the base app
|
||||||
|
class GameData < Sinatra::Base
|
||||||
|
|
||||||
|
enable :sessions
|
||||||
|
|
||||||
|
# Set up static file serving
|
||||||
|
enable :static
|
||||||
|
set :public_folder, File.join(__dir__, '/../public')
|
||||||
|
|
||||||
|
use IndexController
|
||||||
|
|
||||||
|
end
|
29
views/layout.erb
Normal file
29
views/layout.erb
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<!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">
|
||||||
|
<link rel="shortcut icon" href="/img/favicon.png">
|
||||||
|
<title><%= title %> | MULDAP</title>
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.7/css/bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="/css/lletya.css">
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" charset="utf-8"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.7/js/bootstrap.min.js" charset="utf-8"></script>
|
||||||
|
<script src="/js/tirannwn.js" charset="utf-8"></script>
|
||||||
|
</head>
|
||||||
|
<body class="d-flex flex-column min-vh-100">
|
||||||
|
<!-- main navigation -->
|
||||||
|
<%= erb :'partials/navbar', :locals => locals %>
|
||||||
|
|
||||||
|
<!-- main content -->
|
||||||
|
<main class="flex-grow-1 py-4">
|
||||||
|
<div id="wrapper" class="container mb-4">
|
||||||
|
<%= yield %>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<!-- site footer -->
|
||||||
|
<%= erb :'partials/footer', :locals => locals %>
|
||||||
|
</body>
|
||||||
|
</html>
|
10
views/partials/footer.erb
Normal file
10
views/partials/footer.erb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<footer id="main-footer" class="bg-light border-top py-3 text-center">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<p>MULDAP version v<%= app_version() %></p>
|
||||||
|
<p class="mb-0">Running Ruby version v<%= ruby_version() %></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
20
views/partials/navbar.erb
Normal file
20
views/partials/navbar.erb
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<div id="main-nav" class="navbar navbar-expand-md bg-dark border-bottom border-body mb-3" data-bs-theme="dark">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a id="site-title" class="navbar-brand mb-0 h1" href="#">
|
||||||
|
MULDAP
|
||||||
|
<img src="/img/app-logo.png" alt="">
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
|
<ul class="navbar-nav me-auto mb-2 mb-md-0">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/">Dashboard</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
1
views/toplevel/dashboard.erb
Normal file
1
views/toplevel/dashboard.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<p>This is the MULDAP dashboard.</p>
|
Reference in New Issue
Block a user