Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'nyara', '<%= nyara_version %>' | ||
gem 'tilt' | ||
gem 'erubis' | ||
gem 'nyara', '<%= Nyara::VERSION %>' | ||
gem 'mongoid', '3.1.4' |
3 changes: 3 additions & 0 deletions
3
lib/nyara/templates/app/controllers/application_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class ApplicationController < Nyara::Controller | ||
set_default_layout 'layouts/application' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class WelcomeController < ApplicationController | ||
get '/' do | ||
render 'welcome/index' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | ||
<title><%= app_name %></title> | ||
</head> | ||
<body> | ||
<%%= yield %> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Welcome to use Nyara. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require "nyara" | ||
require "erubis" | ||
require 'bundler' and Bundler.setup(:default) | ||
require 'mongoid' | ||
|
||
NYARA_ENV = (ENV['NYARA_ENV'] || 'development').downcase.strip | ||
app_root = File.join(File.dirname(__FILE__),"../") | ||
|
||
# load controllers, models | ||
Dir.glob(File.join("app/controllers/**/*")).each do |fname| | ||
require_relative File.join("..",fname) | ||
end | ||
Dir.glob(File.join("app/models/**/*")).each do |fname| | ||
require_relative File.join("..",fname) | ||
end | ||
|
||
# Configure Mongoid | ||
Mongoid.load!(File.join(app_root,'config/database.yml'), NYARA_ENV) | ||
|
||
configure do | ||
set :env, NYARA_ENV | ||
set :views, 'app/views' | ||
set :session, :name, '_aaa' | ||
set :session, :secure, true | ||
set :session, :expires, 30 * 60 | ||
|
||
map '/', 'welcome' | ||
end | ||
|
||
# TODO: 此处不用会报 Nyara::SimpleController: no action defined (RuntimeError) | ||
get '/' do | ||
send_string '' | ||
end | ||
|
||
# require_relative NYARA_ENV | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
configure do | ||
set :port, 3000 # set listening port number | ||
set :workers, 4 # set number of worker process | ||
# if not set, will estimate best n by CPU count | ||
|
||
set :logger, true # equivalent to no setting | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
configure do | ||
set :port, 3000 # set listening port number | ||
set :workers, 4 # set number of worker process | ||
# if not set, will estimate best n by CPU count | ||
|
||
set :logger, true # equivalent to no setting | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
configure do | ||
set :port, 3000 # set listening port number | ||
set :workers, 1 # set number of worker process | ||
# if not set, will estimate best n by CPU count | ||
|
||
set :logger, true # equivalent to no setting | ||
end |