nekonote-framework 1.0.0.pre.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +49 -0
  4. data/bin/nekonote +45 -0
  5. data/data/structure/Gemfile +25 -0
  6. data/data/structure/config.ru +14 -0
  7. data/data/structure/handler/base.rb +21 -0
  8. data/data/structure/handler/error.rb +35 -0
  9. data/data/structure/handler/welcome.rb +11 -0
  10. data/data/structure/lib/.gitkeep +0 -0
  11. data/data/structure/preference/development/logger.yml +62 -0
  12. data/data/structure/preference/development/middlewares.rb +152 -0
  13. data/data/structure/preference/development/public.yml +29 -0
  14. data/data/structure/preference/development/route.yml +30 -0
  15. data/data/structure/preference/development/route_error.yml +28 -0
  16. data/data/structure/preference/development/route_include.yml +22 -0
  17. data/data/structure/preference/development/server/puma.rb +63 -0
  18. data/data/structure/preference/development/setting/example.yml +40 -0
  19. data/data/structure/preference/development/setting/site.yml +3 -0
  20. data/data/structure/preference/development/setting/welcome.yml +7 -0
  21. data/data/structure/public/css/layout/common.css +11 -0
  22. data/data/structure/public/css/layout/default.css +3 -0
  23. data/data/structure/public/css/layout/error.css +3 -0
  24. data/data/structure/public/css/welcome.css +47 -0
  25. data/data/structure/public/favicon.ico +0 -0
  26. data/data/structure/public/img/.gitkeep +0 -0
  27. data/data/structure/public/img/logo.png +0 -0
  28. data/data/structure/public/js/.gitkeep +0 -0
  29. data/data/structure/static/layout/default.tpl +19 -0
  30. data/data/structure/static/layout/error.tpl +15 -0
  31. data/data/structure/static/sass/welcome.scss +52 -0
  32. data/data/structure/static/template/error.tpl +4 -0
  33. data/data/structure/static/template/welcome/index.tpl +26 -0
  34. data/data/structure/tmp/pids/.gitkeep +0 -0
  35. data/lib/loader.rb +83 -0
  36. data/lib/nekonote.rb +9 -0
  37. data/lib/nekonote/cli.rb +702 -0
  38. data/lib/nekonote/cmd_parser.rb +55 -0
  39. data/lib/nekonote/core.rb +116 -0
  40. data/lib/nekonote/env.rb +56 -0
  41. data/lib/nekonote/exception/cli_error.rb +34 -0
  42. data/lib/nekonote/exception/error.rb +75 -0
  43. data/lib/nekonote/exception/handler_error.rb +5 -0
  44. data/lib/nekonote/exception/logger_error.rb +8 -0
  45. data/lib/nekonote/exception/page_cache_error.rb +6 -0
  46. data/lib/nekonote/exception/preference_error.rb +11 -0
  47. data/lib/nekonote/exception/view_error.rb +7 -0
  48. data/lib/nekonote/handler.rb +274 -0
  49. data/lib/nekonote/handler/protected_methods.rb +119 -0
  50. data/lib/nekonote/liquid/tag_env_get.rb +12 -0
  51. data/lib/nekonote/liquid/tag_setting_get.rb +12 -0
  52. data/lib/nekonote/logger.rb +135 -0
  53. data/lib/nekonote/page_cache.rb +111 -0
  54. data/lib/nekonote/preference.rb +215 -0
  55. data/lib/nekonote/puma.rb +131 -0
  56. data/lib/nekonote/rack/rack_static.rb +17 -0
  57. data/lib/nekonote/rack/rack_static_file.rb +19 -0
  58. data/lib/nekonote/rack/url_mapper.rb +193 -0
  59. data/lib/nekonote/rackup.rb +319 -0
  60. data/lib/nekonote/request.rb +295 -0
  61. data/lib/nekonote/setting.rb +59 -0
  62. data/lib/nekonote/spec.rb +22 -0
  63. data/lib/nekonote/util/filer.rb +69 -0
  64. data/lib/nekonote/util/process.rb +43 -0
  65. data/lib/nekonote/view.rb +398 -0
  66. data/lib/nekonote/yaml_access.rb +60 -0
  67. metadata +144 -0
@@ -0,0 +1,29 @@
1
+ # Publishing Static Files
2
+
3
+ # Sets directories to publish
4
+ # Files under the directory are published recursively
5
+ published_directory:
6
+ - css # public/css/* will be published recursively
7
+ - js # public/js/* will be published recursively
8
+ - img # public/img/* will be published recursively
9
+
10
+ # Sets files to publish
11
+ published_file:
12
+ - favicon.ico # public/favicon.ico will be published
13
+
14
+ # Sets headers to add published static files
15
+ custom_header:
16
+ # Sets HTTP headers to all files located in the ‘public’ directory.
17
+ all:
18
+
19
+ # Sets HTTP headers to files located under a specific directory.
20
+ directory:
21
+
22
+ # Sets HTTP headers to files with a specific file name extension
23
+ extension:
24
+
25
+ # Sets HTTP headers to files matched a specific regular expression.
26
+ regexp:
27
+
28
+ # Sets HTTP headers to most common web font formats.
29
+ fonts:
@@ -0,0 +1,30 @@
1
+ # Routes Configuration
2
+ #
3
+ # e.g.
4
+ # FooHandler:
5
+ # path: /foo # This is required. The following directives are optional.
6
+ # execute: foo # It says FooHandler#foo method is called when route matches.
7
+ # method: GET, POST # It says GET or POST requests are accepted.
8
+ # params: foo=int, bar=string, baz=array, qux=float, quux=bool # The listed parameters are accepted and are coverted to its expected types.
9
+ # content: json # It says Content-Type: application/json is set to response.
10
+ # template: foo # static/template/foo.tpl is rendered.
11
+ # layout: common # static/layout/common.tpl is rendered
12
+ # # page_cache_time: 3600 # if you need page caching this route, need to comment out it.
13
+ # custom: some value # unknown fields are not directive. It will be assigned into your templates.
14
+
15
+ # ----------------------
16
+ # Route Options
17
+ # ----------------------
18
+ preference:
19
+ path_as_regexp: false
20
+ allow_dup_slash: false
21
+
22
+ # ----------------------
23
+ # Routes
24
+ # ----------------------
25
+ WelcomeHandler:
26
+ path: /
27
+ execute: index
28
+ template: welcome/index
29
+ css: /css/welcome.css
30
+ page-title: Welcome
@@ -0,0 +1,28 @@
1
+ # Routing for Error Pages
2
+
3
+ # This route is used when any route does not match a URL.
4
+ # You must set “path_as_regexp” directive to “true” which in route.yml to use this route.
5
+ missing_route:
6
+ handler: ErrorHandler
7
+ execute: missing_route
8
+ layout: error
9
+
10
+ # This route is used when some value is set to “method” directive in route.y
11
+ # and a request HTTP method is not declared in that value.
12
+ wrong_http_method:
13
+ handler: ErrorHandler
14
+ execute: wrong_http_method
15
+ layout: error
16
+
17
+ # This route is used when a fatal error raised in program.
18
+ # The exception object is set to a property called @error in a Handler you specified.
19
+ fatal:
20
+ handler: ErrorHandler
21
+ execute: fatal
22
+ layout: error
23
+
24
+ # This route is used when a requested file dosen’t exist under the “public” directo
25
+ not_found:
26
+ handler: ErrorHandler
27
+ execute: not_found
28
+ layout: error
@@ -0,0 +1,22 @@
1
+ # This file is supposed to configure a group of some common preferences to configure routes in route.yml.
2
+ # You may specify common preferences set here by 'include' directive in route.yml.
3
+ #
4
+ # e.g.
5
+ # common:
6
+ # method: GET
7
+ # params: id=int
8
+ # content: json
9
+ # template: false
10
+ # layoute: false
11
+ #
12
+ # In order to set the above preferences you must write 'include' directive like:
13
+ #
14
+ # FooHandler:
15
+ # path: /foo
16
+ # method: foo
17
+ # include: common
18
+ #
19
+ # BarHandler:
20
+ # path: /bar
21
+ # method: bar
22
+ # include: common
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env puma
2
+ # Configuration for puma web server.
3
+ # Please check the reference manual of Puma to get more information.
4
+
5
+ # document root
6
+ # It's supposed to be set absolute path to application root.
7
+ _app_root = 'REPLACE_ME_TO_APP_ROOT'
8
+
9
+ # host address to bind
10
+ _host = '0.0.0.0'
11
+
12
+ # listen port
13
+ _port = '2002'
14
+
15
+ # the directory to oparate out of
16
+ directory _app_root
17
+
18
+ # where bind to
19
+ # e.g. bind 'unix:///var/run/puma.sock'
20
+ # e.g. bind 'unix:///var/run/puma.sock?umask=0111'
21
+ # e.g. bind "ssl://#{_host}:#{_port}?key=path_to_key&cert=path_to_cert"
22
+ bind "tcp://#{_host}:#{_port}"
23
+
24
+ # for SSL you may use this instead of 'bind'
25
+ # ssl_bind _host, _port, {
26
+ # key: path_to_key,
27
+ # cert: path_to_cert
28
+ # }
29
+
30
+ # Minimum to maximum number of threads to answer.
31
+ threads 0, 16
32
+
33
+ # The environment in which the rack's app will run.
34
+ environment 'none'
35
+
36
+ # true to server is daemonize
37
+ daemonize true
38
+
39
+ # PID and state for puma web server
40
+ pidfile "#{_app_root}/tmp/pids/puma.pid"
41
+ state_path "#{_app_root}/tmp/pids/puma.state"
42
+
43
+ # log messages redrect to
44
+ stdout_redirect "#{_app_root}/log/puma.stdout.log", "#{_app_root}/log/puma.stderr.log"
45
+ # If you prefer to that output is appended, please pass true to the third parameter.
46
+ #stdout_redirect "#{_app_root}/log/puma.stdout.log", "#{_app_root}/log/puma.stderr.log", true
47
+
48
+ # Commented out to disable request logging.
49
+ # quiet
50
+
51
+ # -------------
52
+ # Cluster mode
53
+ # -------------
54
+ # How many worker precesses to run?
55
+ # The default is 0. It's not clusterized.
56
+ # workers 2
57
+
58
+ # Worker processes will be restarted when worker processes couldn't resond within this time.
59
+ # It's not request time out. It's used for detecting malfunctional woker processes.
60
+ # worker_timeout 60
61
+
62
+ # Woker processes' timeout for booting
63
+ # worker_boot_timeout 60
@@ -0,0 +1,40 @@
1
+ # User Configuration Files
2
+ #
3
+ # You may configure some constant values here.
4
+ # ====================
5
+ # for example:
6
+ # --------------------
7
+ # foo:
8
+ # a: 1
9
+ # b: hello
10
+ # c: true
11
+ # d: 0.1
12
+ # e:
13
+ # - FOO
14
+ # - BAR
15
+ # - BAZ
16
+ # --------------------
17
+ # It's possible to reference them from Handler classes:
18
+ # __setting_get :foo #=> {"a"=>1, "b"=>"hello", "c"=>true, "d"=>0.1, "e"=>["FOO", "BAR", "BAZ"]}
19
+ # __setting_get :foo, :a #=> 1
20
+ # __setting_get :foo, :b #=> "hello"
21
+ # __setting_get :foo, :c #=> true
22
+ # __setting_get :foo, :d #=> 0.1
23
+ # __setting_get :foo, :e #=> ["FOO", "BAR", "BAZ"]
24
+ #
25
+ # Returns nil in the following cases,
26
+ # __setting_get #=> no given anything
27
+ # __setting_get :bar #=> no such field
28
+ # __setting_get :foo, :f #=> no such field in foo:
29
+ #
30
+ # In templates, You must use 'setting_get' tag like: {% setting_get foo, a %}
31
+ # ====================
32
+ foo:
33
+ a: 1
34
+ b: hello
35
+ c: true
36
+ d: 0.1
37
+ e:
38
+ - FOO
39
+ - BAR
40
+ - BAZ
@@ -0,0 +1,3 @@
1
+ # site setting
2
+ site:
3
+ title: Site Title
@@ -0,0 +1,7 @@
1
+ # constant values for the welcome page
2
+ url:
3
+ document: https://nekonote-framework.github.io/document
4
+ gem: https://rubygems.org/gems/nekonote-framework
5
+ github: https://github.com/khotta/Nekonote-Framework
6
+ contribute: https://nekonote-framework.github.io/contribute
7
+ license: https://github.com/khotta/Nekonote-Framework/blob/master/LICENSE
@@ -0,0 +1,11 @@
1
+ body {
2
+ padding: 0em;
3
+ margin: 0em;
4
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
5
+ }
6
+ #header-line {
7
+ height: 1em;
8
+ }
9
+ #content {
10
+ margin-left: 0.4em;
11
+ }
@@ -0,0 +1,3 @@
1
+ #header-line {
2
+ background-color: #ff0066;
3
+ }
@@ -0,0 +1,3 @@
1
+ #header-line {
2
+ background-color: red;
3
+ }
@@ -0,0 +1,47 @@
1
+ body {
2
+ background-color: #f0f0f5;
3
+ }
4
+
5
+ #content {
6
+ margin-left: 0.6em;
7
+ font-family: helvetica, arial, sans-serif;
8
+ }
9
+ #content h3 {
10
+ color: #e6005c;
11
+ font-family: 'Open Sans', sans-serif;
12
+ letter-spacing: 0.1em;
13
+ }
14
+ #content h4 {
15
+ color: #ff1a1a;
16
+ font-family: 'Open Sans', sans-serif;
17
+ letter-spacing: 0.1em;
18
+ font-weight: normal;
19
+ margin-top: 2em;
20
+ margin-bottom: 0.6em;
21
+ }
22
+ #content .description {
23
+ text-indent: 2em;
24
+ }
25
+ #content em {
26
+ color: #ff0066;
27
+ }
28
+ #content a {
29
+ color: #737373;
30
+ text-decoration: none;
31
+ }
32
+ #content a:hover {
33
+ color: #ff8566;
34
+ text-decoration: underline;
35
+ }
36
+ #content #footer-logo {
37
+ position: fixed;
38
+ bottom: 5%;
39
+ right: 5%;
40
+ background-image: url("/img/logo.png");
41
+ background-repeat: no-repeat;
42
+ background-size: 15em 5em;
43
+ height: 5em;
44
+ width: 15em;
45
+ }
46
+
47
+ /*# sourceMappingURL=welcome.css.map */
File without changes
File without changes
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <head>
3
+ <meta charset="UTF-8" />
4
+ <link rel="stylesheet" type="text/css" href="/css/layout/common.css?1.0.0" />
5
+ <link rel="stylesheet" type="text/css" href="/css/layout/default.css?1.0.0" />
6
+ {% if css %}<link rel="stylesheet" type="text/css" href="{{css}}" />{% endif %}
7
+ {% if title %}<title>{{title}}</title>{% endif %}
8
+ </head>
9
+ <body>
10
+ <div id="header-line"></div>
11
+
12
+ <div id="content">
13
+ {{content}}
14
+ </div>
15
+ {% comment %}
16
+ Note: {{content}} is magical. Your template is rendered there.
17
+ {% endcomment %}
18
+ </body>
19
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <head>
3
+ <meta charset="UTF-8" />
4
+ <link rel="stylesheet" type="text/css" href="/css/layout/common.css?1.0.0" />
5
+ <link rel="stylesheet" type="text/css" href="/css/layout/error.css?1.0.0" />
6
+ {% if css %}<link rel="stylesheet" type="text/css" href="{{css}}" />{% endif %}
7
+ </head>
8
+ <body>
9
+ <div id="header-line"></div>
10
+
11
+ <div id="content">
12
+ {{content}}
13
+ </div>
14
+
15
+ </html>
@@ -0,0 +1,52 @@
1
+ @mixin stylish-font {
2
+ font-family: 'Open Sans', sans-serif;
3
+ letter-spacing: 0.1em;
4
+ }
5
+
6
+ body {
7
+ background-color: #f0f0f5;
8
+ }
9
+
10
+ #content {
11
+ margin-left: 0.6em;
12
+ font-family: helvetica, arial, sans-serif;
13
+ h3 {
14
+ color: #e6005c;
15
+ @include stylish-font;
16
+ }
17
+ h4 {
18
+ color: #ff1a1a;
19
+ @include stylish-font;
20
+ font-weight: normal;
21
+ margin-top: 2em;
22
+ margin-bottom: 0.6em;
23
+ }
24
+ .description {
25
+ text-indent: 2em;
26
+ }
27
+ em {
28
+ color: #ff0066;
29
+ }
30
+ a {
31
+ color: #737373;
32
+ text-decoration: none;
33
+ &:link {
34
+ }
35
+ &:visited {
36
+ }
37
+ &:hover {
38
+ color: #ff8566;
39
+ text-decoration: underline;
40
+ }
41
+ }
42
+ #footer-logo {
43
+ position: fixed;
44
+ bottom: 5%;
45
+ right: 5%;
46
+ background-image: url("/img/logo.png");
47
+ background-repeat: no-repeat;
48
+ background-size: 15em 5em;
49
+ height: 5em;
50
+ width: 15em;
51
+ }
52
+ }
@@ -0,0 +1,4 @@
1
+ <h3 style="color: red;">{{subject}} =(-x-;=</h3>
2
+ <div style="margin-left: 1em;">
3
+ <p style="color: crimson;">{{msg}}{% if detail %}: {{detail}}{% endif %}</p>
4
+ </div>
@@ -0,0 +1,26 @@
1
+ <div id="content">
2
+ <h3>Welcome to Nekonote Framework!</h3>
3
+ <p class="description">{{description}}</p>
4
+
5
+ <h4>Information</h4>
6
+ <ul>
7
+ <li>The version is <em>{{version}}</em></li>
8
+ <li>Current Environment: <em>{{env}}</em></li>
9
+ <li>The Application Root: <em>{{root}}</em></li>
10
+ </ul>
11
+
12
+ <h4>Do you need help?</h4>
13
+ <ul>
14
+ <li>Reference Manual <a href="{% setting_get url, document %}">{% setting_get url, document %}</a></li>
15
+ <li>Contribute <a href="{% setting_get url, contribute %}">{% setting_get url, contribute %}</a></li>
16
+ </ul>
17
+
18
+ <h4>Nekonote Framework is open-source software</h4>
19
+ <ul>
20
+ <li>License <a href="{% setting_get url, license %}">{% setting_get url, license %}</a></li>
21
+ <li>GitHub <a href="{% setting_get url, github %}">{% setting_get url, github %}</a></li>
22
+ <li>Repository <a href="{% setting_get url, gem %}">{% setting_get url, gem %}</a></li>
23
+ </ul>
24
+
25
+ <div id="footer-logo"></div>
26
+ </div>
File without changes
@@ -0,0 +1,83 @@
1
+ # for bundler
2
+ require 'bundler'
3
+ require 'bundler/setup'
4
+
5
+ # ========================================
6
+ # auto loading standard and gem libraries
7
+ # ========================================
8
+ # standard libraries
9
+ # TODO need namespace for avoiding declaration
10
+ autoload :Psych, 'yaml'
11
+ autoload :YAML, 'yaml'
12
+ autoload :Singleton, 'singleton'
13
+ autoload :FileUtils, 'fileutils'
14
+ autoload :URI, 'uri'
15
+
16
+ # dependent gem libraries
17
+ autoload :Rack, 'rack'
18
+ autoload :Liquid, 'liquid'
19
+ autoload :Puma, 'puma/control_cli'
20
+ autoload :SimpleRotate, 'simple_rotate'
21
+
22
+ # optional gem libraries
23
+ autoload :ConnectionPool, 'connection_pool'
24
+ # for Dalli
25
+ autoload :Dalli, 'dalli'
26
+ begin
27
+ module Rack
28
+ module Session
29
+ autoload :Dalli, 'rack/session/dalli'
30
+ end
31
+ end
32
+ rescue LoadError
33
+ # ignore LoadError in case the set-up hasn't completed yet
34
+ end
35
+
36
+ # ==============================
37
+ # auto loading internal files
38
+ # ==============================
39
+ module Nekonote
40
+ @@lib_root_path = File.expand_path(File.dirname(__FILE__)) + '/nekonote/'
41
+ def self.get_lib_root_path
42
+ return @@lib_root_path
43
+ end
44
+
45
+ # extends Nekonote module
46
+ require Nekonote.get_lib_root_path + 'spec'
47
+ require Nekonote.get_lib_root_path + 'core'
48
+
49
+ module Util
50
+ autoload :Filer, Nekonote.get_lib_root_path + 'util/filer'
51
+ autoload :Process, Nekonote.get_lib_root_path + 'util/process'
52
+ end
53
+
54
+ [
55
+ {:class => :Error, :file => 'exception/error'},
56
+ {:class => :PageCacheError, :file => 'exception/page_cache_error'},
57
+ {:class => :PreferenceError, :file => 'exception/preference_error'},
58
+ {:class => :ViewError, :file => 'exception/view_error'},
59
+ {:class => :CLIError, :file => 'exception/cli_error'},
60
+ {:class => :HandlerError, :file => 'exception/handler_error'},
61
+ {:class => :LoggerError, :file => 'exception/logger_error'},
62
+ {:class => :YamlAccess, :file => 'yaml_access'},
63
+ {:class => :Env, :file => 'env'},
64
+ {:class => :Preference, :file => 'preference'},
65
+ {:class => :Setting, :file => 'setting'},
66
+ {:class => :PageCache, :file => 'page_cache'},
67
+ {:class => :View, :file => 'view'},
68
+ {:class => :TagEnvGet, :file => 'liquid/tag_env_get'},
69
+ {:class => :TagSettingGet, :file => 'liquid/tag_setting_get'},
70
+ {:class => :Request, :file => 'request'},
71
+ {:class => :Handler, :file => 'handler.rb'},
72
+ {:class => :Rackup, :file => 'rackup'},
73
+ {:class => :Cli, :file => 'cli'},
74
+ {:class => :CmdParser, :file => 'cmd_parser'},
75
+ {:class => :Puma, :file => 'puma'},
76
+ {:class => :RackStaticFile , :file => 'rack/rack_static_file'},
77
+ {:class => :RackStatic, :file => 'rack/rack_static'},
78
+ {:class => :URLMapper, :file => 'rack/url_mapper'},
79
+ {:class => :Logger, :file => 'logger'}
80
+ ].each do |data|
81
+ autoload data[:class], Nekonote.get_lib_root_path + data[:file]
82
+ end
83
+ end