From a0b37977a900954d41e21637e3911edabff9abc5 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 29 Jul 2015 17:26:04 +0300 Subject: [PATCH] volt new overlay --- .gitignore | 47 ++------- Gemfile | 26 +++-- Gemfile.lock | 78 +++++++------- app/main/assets/css/app.css.scss | 1 + app/main/config/dependencies.rb | 11 ++ app/main/config/initializers/boot.rb | 10 ++ app/main/config/routes.rb | 14 +++ app/main/controllers/main_controller.rb | 27 +++++ app/main/models/user.rb | 12 +++ app/main/views/main/about.html | 7 ++ app/main/views/main/index.html | 6 ++ app/main/views/main/main.html | 29 ++++++ config.ru | 46 +-------- config/app.rb | 132 ++++++++++++++++++++++++ config/base/index.html | 20 ++++ 15 files changed, 338 insertions(+), 128 deletions(-) create mode 100644 app/main/assets/css/app.css.scss create mode 100644 app/main/config/dependencies.rb create mode 100644 app/main/config/initializers/boot.rb create mode 100644 app/main/config/routes.rb create mode 100644 app/main/controllers/main_controller.rb create mode 100644 app/main/models/user.rb create mode 100644 app/main/views/main/about.html create mode 100644 app/main/views/main/index.html create mode 100644 app/main/views/main/main.html create mode 100644 config/app.rb create mode 100644 config/base/index.html diff --git a/.gitignore b/.gitignore index 6793344..b5346ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,42 +1,9 @@ -# database -db - -# rdoc generated -rdoc - -# yard generated -doc -.yardoc - -# bundler .bundle -*.gem - -# jeweler generated -pkg - -# -# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line) -# -# For MacOS: -# +.config +.yardoc +tmp +.idea +.yardoc +.sass-cache .DS_Store - -# For TextMate -#*.tmproj -#tmtags - -# For emacs: -#*~ -#\#* -#.\#* - -# For vim: -#*.swp - - -# Object files -*.o -log - -tmp/ +compiled \ No newline at end of file diff --git a/Gemfile b/Gemfile index 414d782..343a39d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'volt', :path => "../volt" +gem 'volt', '0.9.4' # volt uses mongo as the default data store. gem 'volt-mongo', '~> 0.1.0' @@ -9,16 +9,28 @@ gem 'volt-mongo', '~> 0.1.0' # Twitter bootstrap gem 'volt-bootstrap', '~> 0.0.10' +# Simple theme for bootstrap, remove to theme yourself. +gem 'volt-bootstrap_jumbotron_theme', '~> 0.1.0' + +# User templates for login, signup, and logout menu. +gem 'volt-user_templates', '~> 0.4.0' + +# Add ability to send e-mail from apps. +gem 'volt-mailer', '~> 0.1.0' + +# Use rbnacl for message bus encrpytion +# (optional, if you don't need encryption, disable in app.rb and remove) +# +# Message Bus encryption is not supported on Windows at the moment. +platform :ruby, :jruby do + gem 'rbnacl', require: false + gem 'rbnacl-libsodium', require: false +end + # Asset compilation gems, they will be required when needed. gem 'csso-rails', '~> 0.3.4', require: false gem 'uglifier', '>= 2.4.0', require: false -gem "parslet" , path: "../parslet" -#gem "salama" , path: "../salama" -gem "salama-reader" , path: "../salama-reader" -gem "salama-object-file" , path: "../salama-object-file" - - group :test do # Testing dependencies gem 'rspec', '~> 3.2.0' diff --git a/Gemfile.lock b/Gemfile.lock index 157b044..090270c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,36 +1,3 @@ -PATH - remote: ../parslet - specs: - parslet (1.7.0) - -PATH - remote: ../salama-object-file - specs: - salama-object-file (0.2.0) - -PATH - remote: ../salama-reader - specs: - salama-reader (0.2.0) - parslet (~> 1.7.0) - -PATH - remote: ../volt - specs: - volt (0.9.4) - bcrypt (~> 3.1.9) - bundler (>= 1.5) - concurrent-ruby (= 0.8.0) - configurations (~> 2.0.0.pre) - faye-websocket (~> 0.9.2) - listen (~> 3.0.1) - opal (~> 0.7.2) - pry (~> 0.10.1) - rack (~> 1.5.0) - sass (~> 3.2.5) - sprockets-sass (~> 1.0.0) - thor (~> 0.19.0) - GEM remote: https://rubygems.org/ specs: @@ -67,9 +34,11 @@ GEM ffi (1.9.10) hike (1.2.3) json (1.8.3) - listen (3.0.2) + listen (3.0.3) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) + mail (2.6.3) + mime-types (>= 1.16, < 3) method_source (0.8.2) mime-types (2.6.1) mini_portile (0.6.2) @@ -90,6 +59,8 @@ GEM cliver (~> 0.3.1) multi_json (~> 1.0) websocket-driver (>= 0.2.0) + pony (1.11) + mail (>= 2.0) pry (0.10.1) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -100,6 +71,10 @@ GEM rb-fsevent (0.9.5) rb-inotify (0.9.5) ffi (>= 0.5.0) + rbnacl (3.2.0) + ffi + rbnacl-libsodium (1.0.3) + rbnacl (~> 3.0, >= 3.0.1) ref (1.0.5) rspec (3.2.0) rspec-core (~> 3.2.0) @@ -140,11 +115,31 @@ GEM uglifier (2.7.1) execjs (>= 0.3.0) json (>= 1.8.0) + volt (0.9.4) + bcrypt (~> 3.1.9) + bundler (>= 1.5) + concurrent-ruby (= 0.8.0) + configurations (~> 2.0.0.pre) + faye-websocket (~> 0.9.2) + listen (~> 3.0.1) + opal (~> 0.7.2) + pry (~> 0.10.1) + rack (~> 1.5.0) + sass (~> 3.2.5) + sprockets-sass (~> 1.0.0) + thor (~> 0.19.0) volt-bootstrap (0.0.10) + volt-bootstrap_jumbotron_theme (0.1.0) + volt-fields (0.1.3) + volt-mailer (0.1.0) + pony (~> 1.11) volt-mongo (0.1.1) mongo (~> 1.9.0) + volt-user_templates (0.4.0) + volt-fields (~> 0.1.0) + volt-mailer (~> 0.1.0) websocket (1.2.2) - websocket-driver (0.5.4) + websocket-driver (0.6.2) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) xpath (2.0.0) @@ -160,14 +155,19 @@ DEPENDENCIES concurrent-ruby-ext (~> 0.8.0) csso-rails (~> 0.3.4) opal-rspec (~> 0.4.2) - parslet! poltergeist (~> 1.5.0) + rbnacl + rbnacl-libsodium rspec (~> 3.2.0) - salama-object-file! - salama-reader! selenium-webdriver (~> 2.43.0) thin (~> 1.6.0) uglifier (>= 2.4.0) - volt! + volt (= 0.9.4) volt-bootstrap (~> 0.0.10) + volt-bootstrap_jumbotron_theme (~> 0.1.0) + volt-mailer (~> 0.1.0) volt-mongo (~> 0.1.0) + volt-user_templates (~> 0.4.0) + +BUNDLED WITH + 1.10.5 diff --git a/app/main/assets/css/app.css.scss b/app/main/assets/css/app.css.scss new file mode 100644 index 0000000..f64375c --- /dev/null +++ b/app/main/assets/css/app.css.scss @@ -0,0 +1 @@ +// Place your apps css here \ No newline at end of file diff --git a/app/main/config/dependencies.rb b/app/main/config/dependencies.rb new file mode 100644 index 0000000..c43f808 --- /dev/null +++ b/app/main/config/dependencies.rb @@ -0,0 +1,11 @@ +# Specify which components you wish to include when +# the "home" component loads. + +# bootstrap css framework +component 'bootstrap' + +# a default theme for the bootstrap framework +component 'bootstrap_jumbotron_theme' + +# provides templates for login, signup, and logout +component 'user_templates' diff --git a/app/main/config/initializers/boot.rb b/app/main/config/initializers/boot.rb new file mode 100644 index 0000000..a4bbae3 --- /dev/null +++ b/app/main/config/initializers/boot.rb @@ -0,0 +1,10 @@ +# Place any code you want to run when the component is included on the client +# or server. + +# To include code only on the client use: +# if RUBY_PLATFORM == 'opal' +# +# To include code only on the server, use: +# unless RUBY_PLATFORM == 'opal' +# ^^ this will not send compile in code in the conditional to the client. +# ^^ this include code required in the conditional. \ No newline at end of file diff --git a/app/main/config/routes.rb b/app/main/config/routes.rb new file mode 100644 index 0000000..6cfa548 --- /dev/null +++ b/app/main/config/routes.rb @@ -0,0 +1,14 @@ +# See https://github.com/voltrb/volt#routes for more info on routes + +client '/about', action: 'about' + +# Routes for login and signup, provided by user_templates component gem +client '/signup', component: 'user_templates', controller: 'signup' +client '/login', component: 'user_templates', controller: 'login', action: 'index' +client '/password_reset', component: 'user_templates', controller: 'password_reset', action: 'index' +client '/forgot', component: 'user_templates', controller: 'login', action: 'forgot' +client '/account', component: 'user_templates', controller: 'account', action: 'index' + +# The main route, this should be last. It will match any params not +# previously matched. +client '/', {} diff --git a/app/main/controllers/main_controller.rb b/app/main/controllers/main_controller.rb new file mode 100644 index 0000000..41ff0ca --- /dev/null +++ b/app/main/controllers/main_controller.rb @@ -0,0 +1,27 @@ +# By default Volt generates this controller for your Main component +module Main + class MainController < Volt::ModelController + def index + # Add code for when the index view is loaded + end + + def about + # Add code for when the about view is loaded + end + + private + + # The main template contains a #template binding that shows another + # template. This is the path to that template. It may change based + # on the params._component, params._controller, and params._action values. + def main_path + "#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}" + end + + # Determine if the current nav component is the active one by looking + # at the first part of the url against the href attribute. + def active_tab? + url.path.split('/')[1] == attrs.href.split('/')[1] + end + end +end diff --git a/app/main/models/user.rb b/app/main/models/user.rb new file mode 100644 index 0000000..1dbf70a --- /dev/null +++ b/app/main/models/user.rb @@ -0,0 +1,12 @@ +# By default Volt generates this User model which inherits from Volt::User, +# you can rename this if you want. +class User < Volt::User + # login_field is set to :email by default and can be changed to :username + # in config/app.rb + field login_field + field :name + + validate login_field, unique: true, length: 8 + validate :email, email: true + +end diff --git a/app/main/views/main/about.html b/app/main/views/main/about.html new file mode 100644 index 0000000..7720e4c --- /dev/null +++ b/app/main/views/main/about.html @@ -0,0 +1,7 @@ +<:Title> + About + +<:Body> +

About

+ +

About page...

diff --git a/app/main/views/main/index.html b/app/main/views/main/index.html new file mode 100644 index 0000000..8838ea1 --- /dev/null +++ b/app/main/views/main/index.html @@ -0,0 +1,6 @@ +<:Title> + Home + +<:Body> +

Home

+ diff --git a/app/main/views/main/main.html b/app/main/views/main/main.html new file mode 100644 index 0000000..0e02644 --- /dev/null +++ b/app/main/views/main/main.html @@ -0,0 +1,29 @@ +<:Title> + {{ view main_path, "title", {controller_group: 'main'} }} + +<:Body> +
+
+ +

salama-debugger

+
+ + <:volt:notices /> + + {{ view main_path, 'body', {controller_group: 'main'} }} + + + +
+ +<:Nav> +
  • + {{ yield }} +
  • + diff --git a/config.ru b/config.ru index 8392656..38c084f 100644 --- a/config.ru +++ b/config.ru @@ -1,42 +1,4 @@ -# config.ru -require 'bundler' -Bundler.require - -Opal.use_gem "salama" -Opal.use_gem "salama-arm" - -require "tilt/erb" -require "susy" -require "json" -require "react/source" - -class DebugServer < Opal::Server - - def parse(num) - string_input = '"Hello again".putstring()' - parser = Parser::Salama.new - out = parser.parse(string_input) - parts = Parser::Transform.new.apply(out) - parts.to_basic - end - - - def call(env) - if env['PATH_INFO'].include? "/parse.json" - parse_out = parse(1).to_s - [200, { 'Content-Type' => 'text/json' }, [parse_out]] - else - super - end - end - -end -run DebugServer.new {|s| - s.append_path 'app' - s.append_path 'lib' - s.append_path File.dirname(::React::Source.bundled_path_for("react-with-addons.js")) - s.main = 'main' - s.debug = false - s.source_map = true - s.index_path = "index.html.erb" -} +# Run via rack server +require 'bundler/setup' +require 'volt/server' +run Volt::Server.new.app diff --git a/config/app.rb b/config/app.rb new file mode 100644 index 0000000..df4bede --- /dev/null +++ b/config/app.rb @@ -0,0 +1,132 @@ +# app.rb is used to configure your app. This code is only run on the server, +# then any config options in config.public are passed to the client as well. + +Volt.configure do |config| + # Setup your global app config here. + + ####################################### + # Basic App Info (stuff you should set) + ####################################### + config.domain = 'salama-debugger.com' + config.app_name = 'Salama-debugger' + config.mailer.from = 'Salama-debugger ' + + ############ + # App Secret + ############ + # Your app secret is used for signing things like the user cookie so it can't + # be tampered with. A random value is generated on new projects that will work + # without the need to customize. Make sure this value doesn't leave your server. + # + # For added security we recommend moving the app secret into an environment. You can + # setup that like so: + # + # config.app_secret = ENV['APP_SECRET'] + # + config.app_secret = 'qwSEmWdixdHgwOgXiLdGJt87b9TxMq009gbJWn0fOTygfIk6fAIlgHO9tAPbA4vaKgY' + + ############### + # Log Filtering + ############### + # Data updates from the client come in via Tasks. The task dispatcher logs all calls to tasks. + # By default hashes in the arguments can be filtered based on keys. So any hash with a key of + # password will be filtered. You can add more fields to filter below: + config.filter_keys = [:password] + + ########## + # Database + ########## + # Database config all start with db_ and can be set either in the config + # file or with an environment variable (DB_NAME for example). + + # config.db_driver = 'mongo' + # config.db_name = (config.app_name + '_' + Volt.env.to_s) + # config.db_host = 'localhost' + # config.db_port = 27017 + + ##################### + # Compression options + ##################### + # If you are not running behind something like nginx in production, you can + # have rack deflate all files. + # config.deflate = true + + ####################### + # Public configurations + ####################### + # Anything under config.public will be sent to the client as well as the server, + # so be sure no private data ends up under public + + # Use username instead of email as the login + # config.public.auth.use_username = true + + ##################### + # Compression Options + ##################### + # Disable or enable css/js compression. Default is to only run in production. + # if Volt.env.production? + # config.compress_javascript = true + # config.compress_css = true + # end + + ################ + # Mailer options + ################ + # The volt-mailer gem uses pony (https://github.com/benprew/pony) to deliver e-mail. Any + # options you would pass to pony can be setup below. + # NOTE: The from address is setup at the top + + # Normally pony uses /usr/sbin/sendmail if one is installed. You can specify smtp below: + # config.mailer.via = :smtp + # config.mailer.via_options = { + # :address => 'smtp.yourserver.com', + # :port => '25', + # :user_name => 'user', + # :password => 'password', + # :authentication => :plain, # :plain, :login, :cram_md5, no auth by default + # :domain => "localhost.localdomain" # the HELO domain provided by the client to the server + # } + + ############# + # Message Bus + ############# + # Volt provides a "Message Bus" out of the box. The message bus provides + # a pub/sub service between any volt instance (server, client, runner, etc..) + # that share the same database. The message bus can be used by app code. It + # is also used internally to push data to any listening clients. + # + # The default message bus (called "peer_to_peer") uses the database to sync + # socket ip's/ports. + # config.message_bus.bus_name = 'peer_to_peer' + # + # Encrypt message bus - messages on the message bus are encrypted by default + # using rbnacl. + # config.message_bus.disable_encryption = true + # + # ## MessageBus Server -- the message bus binds to a port and ip which the + # other volt instances need to be able to connect to. You can customize + # the server below: + # + # Port range - you can specify a range of ports that an instance can bind the + # message bus on. You can specify a range, an array of Integers, or an array + # of ranges. + # config.message_bus.bind_port_ranges = (58000..61000) + # + # Bind Ip - specifies the ip address the message bus server should bind on. + # config.message_bus.bind_ip = '127.0.0.1' + + ############# + # Concurrency + ############# + # Volt provides a thread worker pool for incoming task requests (and all + # database requests, since those use tasks to do their work.) The following + # lets you control the size of the worker pool. Threads are only created as + # needed, and are removed after a certain amount of inactivity. + # config.min_worker_threads = 1 + # config.max_worker_threads = 10 + # + # You can also specify the amount of time a Task should run for before it + # timeout's. Setting this to short can cause unexpected results, currently + # we recomend it be at least 10 seconds. + # config.worker_timeout = 60 +end diff --git a/config/base/index.html b/config/base/index.html new file mode 100644 index 0000000..3b3e895 --- /dev/null +++ b/config/base/index.html @@ -0,0 +1,20 @@ + + + <%# IMPORTANT: Please read before changing! %> + <%# This file is rendered on the server using ERB, so it does NOT use Volt's %> + <%# normal template system. You can add to it, but keep in mind the template %> + <%# language difference. This file handles auto-loading all JS/Opal and CSS. %> + + + <% javascript_files.each do |javascript_file| %> + + <% end %> + + <% css_files.each do |css_file| %> + + <% end %> + + + + +