├── .gitignore ├── .rspec ├── .travis.yml ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── bin ├── console ├── setup └── silica ├── lib ├── silica.rb └── silica │ ├── cli.rb │ └── version.rb ├── silica.gemspec ├── spec ├── silica_spec.rb └── spec_helper.rb └── template └── project ├── Gemfile ├── Rakefile ├── app ├── application.rb └── controllers │ └── application_controller.rb ├── assets └── css │ └── application.scss ├── bin └── console ├── config.ru ├── config └── database.yml ├── server.rb └── views └── index.haml /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | /.bundle/ 3 | /.yardoc 4 | /Gemfile.lock 5 | /_yardoc/ 6 | /coverage/ 7 | /doc/ 8 | /pkg/ 9 | /spec/reports/ 10 | /tmp/ 11 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: ruby 3 | rvm: 4 | - 2.3.1 5 | before_install: gem install bundler -v 1.12.5 6 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 youchan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Silica 2 | 3 | This gem is a generator for [Opal](http://opalrb.org) app with [Hyalite](https://github.com/youchan/hyalite) and [Menilite](https://github.com/youchan/menilite). 4 | 5 | ## Installation 6 | 7 | Add this line to your application's Gemfile: 8 | 9 | ```ruby 10 | gem 'silica' 11 | ``` 12 | 13 | And then execute: 14 | 15 | $ bundle 16 | 17 | Or install it yourself as: 18 | 19 | $ gem install silica 20 | 21 | ## Create your app 22 | 23 | $ silica new your_app 24 | $ cd your_app 25 | $ bundle install 26 | 27 | ## Start app 28 | 29 | $ bundle exec rackup 30 | 31 | ## Contributing 32 | 33 | Bug reports and pull requests are welcome on GitHub at https://github.com/youchan/silica. 34 | 35 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rspec/core/rake_task" 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task :default => :spec 7 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "silica" 5 | 6 | # You can add fixtures and/or initialization code here to make experimenting 7 | # with your gem easier. You can also use a different console, if you like. 8 | 9 | # (If you use this, don't forget to add pry to your Gemfile!) 10 | # require "pry" 11 | # Pry.start 12 | 13 | require "irb" 14 | IRB.start 15 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /bin/silica: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.expand_path('../../lib/silica', __FILE__) 3 | 4 | Silica::Cli.start(ARGV) 5 | -------------------------------------------------------------------------------- /lib/silica.rb: -------------------------------------------------------------------------------- 1 | require_relative 'silica/version' 2 | require_relative 'silica/cli' 3 | 4 | module Silica 5 | end 6 | -------------------------------------------------------------------------------- /lib/silica/cli.rb: -------------------------------------------------------------------------------- 1 | require 'thor' 2 | require 'fileutils' 3 | require 'git' 4 | 5 | module Silica 6 | class Cli < Thor 7 | desc 'new', 'create new project' 8 | 9 | def new(name) 10 | puts "Create new project '#{name}'" 11 | 12 | Dir.exist?(name) or FileUtils.mkdir(name) 13 | dir = Dir.new(__dir__+'/../../template/project') 14 | dir.each do |file| 15 | next if file == '..' 16 | FileUtils.cp_r(dir.path + '/' + file, name) 17 | end 18 | 19 | FileUtils.cd name 20 | 21 | Git.init 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/silica/version.rb: -------------------------------------------------------------------------------- 1 | module Silica 2 | VERSION = '0.1.8' 3 | end 4 | -------------------------------------------------------------------------------- /silica.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'silica/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "silica" 8 | spec.version = Silica::VERSION 9 | spec.authors = ["youchan"] 10 | spec.email = ["youchan01@gmail.com"] 11 | 12 | spec.summary = %q{Web application framework spcialized for the single page applications using Opalrb.} 13 | spec.description = %q{Web application framework spcialized for the single page applications using Opalrb.} 14 | spec.homepage = "https://github.com/youchan/silica" 15 | 16 | spec.files = Dir['lib/**/*.rb'] + Dir['bin/*'] + Dir['template/**/*'] 17 | spec.bindir = "bin" 18 | spec.executables = "silica" 19 | spec.require_paths = ["lib"] 20 | 21 | spec.add_runtime_dependency "thor" 22 | spec.add_runtime_dependency "git" 23 | 24 | spec.add_development_dependency "bundler", "~> 1.12" 25 | spec.add_development_dependency "rake", "~> 10.0" 26 | spec.add_development_dependency "rspec", "~> 3.0" 27 | end 28 | -------------------------------------------------------------------------------- /spec/silica_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Silica do 4 | it 'has a version number' do 5 | expect(Silica::VERSION).not_to be nil 6 | end 7 | 8 | it 'does something useful' do 9 | expect(false).to eq(true) 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) 2 | require 'silica' 3 | -------------------------------------------------------------------------------- /template/project/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem 'sinatra' 4 | gem 'sinatra-contrib' 5 | gem 'thin' 6 | 7 | gem 'opal-haml' 8 | gem 'hyalite' 9 | gem 'menilite' 10 | 11 | gem 'rake' 12 | gem 'sqlite3' 13 | 14 | gem 'haml' 15 | gem 'sass' 16 | -------------------------------------------------------------------------------- /template/project/Rakefile: -------------------------------------------------------------------------------- 1 | require "sinatra/activerecord/rake" 2 | 3 | namespace :db do 4 | task :load_config do 5 | require "./server" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /template/project/app/application.rb: -------------------------------------------------------------------------------- 1 | require 'hyalite' 2 | #require 'menilite' 3 | 4 | class AppView 5 | include Hyalite::Component 6 | 7 | def render 8 | h2(nil, 'Welcome!!!') 9 | end 10 | end 11 | Hyalite.render(Hyalite.create_element(AppView), $document['.content']) 12 | -------------------------------------------------------------------------------- /template/project/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < Menilite::Controller 2 | end 3 | -------------------------------------------------------------------------------- /template/project/assets/css/application.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/youchan/silica/7965474055ef7ec16f5a2779257c65dd80ef597c/template/project/assets/css/application.scss -------------------------------------------------------------------------------- /template/project/bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | 5 | require 'menilite' 6 | require 'sinatra/activerecord' 7 | 8 | Dir[File.expand_path('../../app/models/', __FILE__) + '/**/*.rb'].each {|file| require(file) } 9 | Dir[File.expand_path('../../app/controllers/', __FILE__) + '/**/*.rb'].each {|file| require(file) } 10 | 11 | # You can add fixtures and/or initialization code here to make experimenting 12 | # with your gem easier. You can also use a different console, if you like. 13 | 14 | # (If you use this, don't forget to add pry to your Gemfile!) 15 | # require "pry" 16 | # Pry.start 17 | 18 | require "irb" 19 | IRB.start 20 | -------------------------------------------------------------------------------- /template/project/config.ru: -------------------------------------------------------------------------------- 1 | require 'bundler/setup' 2 | Bundler.require(:default) 3 | 4 | require 'menilite' 5 | require 'sinatra/activerecord' 6 | 7 | require_relative 'server' 8 | Dir[File.expand_path('../app/models/', __FILE__) + '/**/*.rb'].each {|file| require(file) } 9 | Dir[File.expand_path('../app/controllers/', __FILE__) + '/**/*.rb'].each {|file| require(file) } 10 | 11 | app = Rack::Builder.app do 12 | server = Server.new(host: 'localhost') 13 | 14 | map '/' do 15 | run server 16 | end 17 | 18 | map '/assets' do 19 | run Server::OPAL.sprockets 20 | end 21 | 22 | map '/api' do 23 | router = Menilite::Router.new 24 | run router.routes(server.settings) 25 | end 26 | end 27 | 28 | Rack::Server.start({ 29 | app: app, 30 | server: 'thin', 31 | Host: '0.0.0.0', 32 | Port: 9292, 33 | signals: false, 34 | }) 35 | -------------------------------------------------------------------------------- /template/project/config/database.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: sqlite3 3 | database: db/development.sqlite3 4 | 5 | production: 6 | adapter: sqlite3 7 | database: db/production.sqlite3 8 | 9 | test: 10 | adapter: sqlite3 11 | database: db/test.sqlite3 12 | -------------------------------------------------------------------------------- /template/project/server.rb: -------------------------------------------------------------------------------- 1 | require 'sinatra' 2 | require 'opal' 3 | require 'opal/sprockets' 4 | require 'sinatra/activerecord' 5 | 6 | if development? 7 | require 'sinatra/reloader' 8 | end 9 | 10 | class Server < Sinatra::Base 11 | OPAL = Opal::Server.new do |server| 12 | server.append_path 'app' 13 | server.append_path 'assets' 14 | Opal.use_gem 'hyalite' 15 | Opal.use_gem 'menilite' 16 | Opal.paths.each {|path| server.append_path path } 17 | 18 | server.main = 'application' 19 | end 20 | 21 | configure do 22 | set opal: OPAL 23 | enable :sessions 24 | set :protection, except: :json_csrf 25 | end 26 | 27 | get '/' do 28 | haml :index 29 | end 30 | 31 | get "/favicon.ico" do 32 | end 33 | end 34 | 35 | -------------------------------------------------------------------------------- /template/project/views/index.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html(lang="en" data-framework="hyalite") 3 | %head 4 | %link{rel:"stylesheet", href:"assets/css/application.css"} 5 | %body 6 | .content 7 | 8 | = ::Opal::Sprockets.javascript_include_tag('application', sprockets: settings.opal.sprockets, prefix: 'assets', debug: true) 9 | 10 | --------------------------------------------------------------------------------