nekonote-framework 1.0.0.pre.beta → 1.0.0.pre.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +4 -0
- data/data/structure/config.ru +8 -3
- data/data/structure/handler/error.rb +1 -1
- data/data/structure/preference/development/server/puma.rb +2 -2
- data/data/structure/{static → public}/sass/welcome.scss +0 -0
- data/data/structure/{static/template → template}/error.tpl +0 -0
- data/data/structure/{static → template}/layout/default.tpl +0 -0
- data/data/structure/{static → template}/layout/error.tpl +0 -0
- data/data/structure/{static/template → template}/welcome/index.tpl +0 -0
- data/lib/nekonote.rb +1 -5
- data/lib/nekonote/cli.rb +1 -1
- data/lib/nekonote/exception/error.rb +5 -5
- data/lib/nekonote/exception/preference_error.rb +1 -1
- data/lib/nekonote/handler/protected_methods.rb +17 -0
- data/lib/nekonote/puma.rb +2 -2
- data/lib/nekonote/rackup.rb +1 -1
- data/lib/nekonote/spec.rb +4 -4
- data/lib/nekonote/view.rb +74 -31
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0a343528a091a4bfe3b21f2594fbc199f2953b4a9bc563a5b25bc426b06177e4
|
4
|
+
data.tar.gz: 453e2a25ed4ebbf0283f73b5b6d7b3bca39eb27e07b5a3ae3074cf9d265d9840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1380fd33c592621e1168d17a429014a7a235df3f9182942d7d543ab6a0fad95f4d6f1a5500312fc33bab6c23335054eeca00fff80c29b6d3ac8c25d75b6c099a
|
7
|
+
data.tar.gz: 61de9d860e68b232e3969c6504bb770ab8ada5df13814f8b289103664a0ed3f50085c2b0f82302a11c357fa70850a632db73869aad532b98b71541d1745fdb03
|
data/README.md
CHANGED
@@ -44,6 +44,10 @@ Liquid is a well-known powerful template engine. Templates are rendered by Liqui
|
|
44
44
|
|
45
45
|
Please see [Getting Started](https://nekonote-framework.github.io/document/1.0.0-beta/getting-started.html) on the reference manual.
|
46
46
|
|
47
|
+
You need to use `--pre` option when install pre-beta version like:
|
48
|
+
|
49
|
+
$ gem install nekonote-framework --pre
|
50
|
+
|
47
51
|
## License
|
48
52
|
|
49
53
|
Nekonote Framework is friendly license and is released under the [MIT License](https://opensource.org/licenses/MIT).
|
data/data/structure/config.ru
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
# This is a configuration file about Rack which created automatically.
|
2
2
|
# You must NOT delete this file.
|
3
3
|
|
4
|
-
# for starting web server
|
4
|
+
# for starting web server without 'nekonote server'
|
5
5
|
if !defined? Nekonote
|
6
|
-
|
7
|
-
|
6
|
+
begin
|
7
|
+
require 'nekonote'
|
8
|
+
rescue LoadError
|
9
|
+
# installed via bundler? change LOAD_PATH to bundler's
|
10
|
+
require 'bundler/setup'
|
11
|
+
require 'nekonote'
|
12
|
+
end
|
8
13
|
end
|
9
14
|
|
10
15
|
# set-up your application
|
@@ -2,7 +2,7 @@ class ErrorHandler < BaseHandler
|
|
2
2
|
def missing_route
|
3
3
|
@subject = 'Invalid URL'
|
4
4
|
@msg = 'The URL does not match any route'
|
5
|
-
@detail = %('#{Nekonote::Env.get :REQUEST_URI}'
|
5
|
+
@detail = %('#{Nekonote::Env.get :REQUEST_URI}' is not valid URL.)
|
6
6
|
end
|
7
7
|
|
8
8
|
def wrong_http_method
|
@@ -10,7 +10,7 @@ _app_root = 'REPLACE_ME_TO_APP_ROOT'
|
|
10
10
|
_host = '0.0.0.0'
|
11
11
|
|
12
12
|
# listen port
|
13
|
-
_port =
|
13
|
+
_port = 2002
|
14
14
|
|
15
15
|
# the directory to oparate out of
|
16
16
|
directory _app_root
|
@@ -34,7 +34,7 @@ threads 0, 16
|
|
34
34
|
environment 'none'
|
35
35
|
|
36
36
|
# true to server is daemonize
|
37
|
-
daemonize
|
37
|
+
daemonize false
|
38
38
|
|
39
39
|
# PID and state for puma web server
|
40
40
|
pidfile "#{_app_root}/tmp/pids/puma.pid"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/nekonote.rb
CHANGED
data/lib/nekonote/cli.rb
CHANGED
@@ -369,7 +369,7 @@ EOS
|
|
369
369
|
# generate files and directories
|
370
370
|
cp_from = @path_structure + '/'
|
371
371
|
files = ['Gemfile', 'config.ru']
|
372
|
-
dirs = ['handler', 'lib', 'preference', 'public', '
|
372
|
+
dirs = ['handler', 'lib', 'preference', 'public', 'template', 'tmp']
|
373
373
|
free_dirs_to_make = ['cache', 'log']
|
374
374
|
|
375
375
|
# copy files
|
@@ -3,18 +3,18 @@ module Nekonote
|
|
3
3
|
class Error < StandardError
|
4
4
|
SPACE = ' '
|
5
5
|
MSG_MISSING_ENV = %(Environment variable NEKONOTE_ENV is empty or invalid environment name is set.)
|
6
|
-
MSG_MISSING_ROOT = %(
|
7
|
-
MSG_NOT_DEFINED_ROOT = %(Application root
|
6
|
+
MSG_MISSING_ROOT = %(Not found a root directory to the application structure.)
|
7
|
+
MSG_NOT_DEFINED_ROOT = %(Application root has not set yet.)
|
8
8
|
MSG_MISSING_FILE = %(No such file '%s' or can't read it.)
|
9
9
|
MSG_MISSING_DIR = %(No such directory '%s' or can't read it.)
|
10
|
-
MSG_MISSING_RACKUP = %(
|
10
|
+
MSG_MISSING_RACKUP = %(No found config.ru under '%s' or can't read it.)
|
11
11
|
MSG_LACK_FIELD_IN_YAML = %(Lack of the required field '%s'. Please check if '%s' is set properly.)
|
12
12
|
MSG_EMPTY_YAML = %('%s' is empty. You must configure something.)
|
13
13
|
MSG_WRONG_ROOT = %(You'd better run the command at the application root, or --root option will solve the problem.)
|
14
|
-
MSG_WRONG_TYPE = %(
|
14
|
+
MSG_WRONG_TYPE = %([%s] is invalid type. It must be passed [%s].)
|
15
15
|
MSG_MISSING_FIELD = %(The required field '%s' was not found in '%s'.)
|
16
16
|
MSG_INVALID_FIELD = %(Invalid format field '%s' in '%s'.)
|
17
|
-
MSG_MISSING_CONST = %(
|
17
|
+
MSG_MISSING_CONST = %(Not found such class or module or contant -> '%s'.)
|
18
18
|
MSG_EMPTY_FILE_NOT_EMPTY = %('%s' is not empty. Failed to create an empty file.)
|
19
19
|
|
20
20
|
# write message as warning to log file if logging is enabled
|
@@ -4,8 +4,8 @@ module Nekonote
|
|
4
4
|
MSG_WRONG_YAML_SYNTAX = %(The yaml file '%s' is invalid syntax.)
|
5
5
|
MSG_MISSING_INCLUDE = %(No such field '%s' in %s.)
|
6
6
|
MSG_INVALID_HANDLER_NAME = %(Handler class name '%s' is invalid.)
|
7
|
-
MSG_NO_SUCH_HANDLER = %(No such handler class '%s'. You must make it at first.)
|
8
7
|
MSG_DUPLICATE_PATH = %(There is the duplicate path in %s. Values of 'path' directive are supposed to be uniq.)
|
9
8
|
MSG_EVAL_MIDDLEWARES = %(Unable to evaluate '%s' because there's something wrong.)
|
9
|
+
MSG_FAILED_INI_HANDLER = %(Failed to make a %s class object.)
|
10
10
|
end
|
11
11
|
end
|
@@ -94,6 +94,23 @@ module Nekonote
|
|
94
94
|
return Nekonote::Env.keys
|
95
95
|
end
|
96
96
|
|
97
|
+
# @param string path
|
98
|
+
protected
|
99
|
+
def __set_template(path)
|
100
|
+
@view.set_template path
|
101
|
+
end
|
102
|
+
|
103
|
+
# @param string path
|
104
|
+
protected
|
105
|
+
def __set_layout(path)
|
106
|
+
@view.set_layout path
|
107
|
+
end
|
108
|
+
|
109
|
+
# @return string
|
110
|
+
protected
|
111
|
+
def __root
|
112
|
+
return Nekonote::Env.root
|
113
|
+
end
|
97
114
|
|
98
115
|
# @param string dest
|
99
116
|
# @param int code
|
data/lib/nekonote/puma.rb
CHANGED
@@ -59,7 +59,7 @@ module Nekonote
|
|
59
59
|
case cmd
|
60
60
|
when :start
|
61
61
|
if pid != nil
|
62
|
-
puts %(Already started
|
62
|
+
puts %(Already started -> pid #{pid})
|
63
63
|
nothing_to_do = true
|
64
64
|
end
|
65
65
|
|
@@ -67,7 +67,7 @@ module Nekonote
|
|
67
67
|
if pid == nil
|
68
68
|
puts %(Server is stopped)
|
69
69
|
else
|
70
|
-
puts %(Server is running
|
70
|
+
puts %(Server is running -> pid #{pid})
|
71
71
|
end
|
72
72
|
nothing_to_do = true
|
73
73
|
|
data/lib/nekonote/rackup.rb
CHANGED
@@ -301,7 +301,7 @@ EOS
|
|
301
301
|
begin
|
302
302
|
routes[info[Preference::FIELD_ROUTE_PATH].strip] = Object.const_get(handler).new(info)
|
303
303
|
rescue NameError
|
304
|
-
raise PreferenceError, PreferenceError::
|
304
|
+
raise PreferenceError, PreferenceError::MSG_FAILED_INI_HANDLER% info[Preference::FIELD_ROUTE_HANDLER]
|
305
305
|
end
|
306
306
|
|
307
307
|
paths << path
|
data/lib/nekonote/spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Nekonote
|
2
2
|
LIBS_NAME = %(nekonote-framework).freeze
|
3
|
-
VERSION = %(1.0.0-
|
3
|
+
VERSION = %(1.0.0-beta2).freeze
|
4
4
|
HOMEPAGE = %(https://nekonote-framework.github.io).freeze
|
5
5
|
SUMMARY = %(Simple and Lightweight Ruby Framework for Web Development).freeze
|
6
6
|
DESCRIPTION = %(Nekonote Framework is a small web application framework that helps your web development.).freeze
|
@@ -9,9 +9,9 @@ module Nekonote
|
|
9
9
|
.*・゜゚・*:.。..。.:・Thanks installing Nekonote Framework .*・゜゚・*:.。..。.:*・
|
10
10
|
|
11
11
|
^___^
|
12
|
-
(=^x^=) < meow
|
13
|
-
|
14
|
-
.
|
12
|
+
(=^x^=) < meow
|
13
|
+
~ / ) !
|
14
|
+
. \( h h . . . . . . =(**=)~~
|
15
15
|
|
16
16
|
Note:
|
17
17
|
Installing dependent libraries is not completed yet.
|
data/lib/nekonote/view.rb
CHANGED
@@ -6,8 +6,8 @@ module Nekonote
|
|
6
6
|
class View
|
7
7
|
NO_USING_NAME = 'none'
|
8
8
|
DEFAULT_LAYOUT_NAME = 'default'
|
9
|
-
PATH_TO_TEMPLATE = '
|
10
|
-
PATH_TO_LAYOUT = '
|
9
|
+
PATH_TO_TEMPLATE = 'template'
|
10
|
+
PATH_TO_LAYOUT = 'template/layout'
|
11
11
|
|
12
12
|
# accessor
|
13
13
|
attr_accessor :is_redirect
|
@@ -49,33 +49,9 @@ module Nekonote
|
|
49
49
|
@is_error_route = false
|
50
50
|
end
|
51
51
|
|
52
|
-
#
|
53
|
-
|
54
|
-
|
55
|
-
@template_path = Nekonote.get_root_path + PATH_TO_TEMPLATE + '/' + @info_template + '.tpl'
|
56
|
-
elsif @info_template == nil
|
57
|
-
# set default if no template is specified
|
58
|
-
@template_path = get_default_template_path handler_name
|
59
|
-
else
|
60
|
-
# no template with response
|
61
|
-
@template_path = nil
|
62
|
-
end
|
63
|
-
|
64
|
-
# set layout
|
65
|
-
if @info_layout.is_a? String
|
66
|
-
# use layout described in route.yml
|
67
|
-
@layout_path = Nekonote.get_root_path + PATH_TO_LAYOUT + '/' + @info_layout + '.tpl'
|
68
|
-
elsif @info_layout == nil
|
69
|
-
# if no layout is specified, try to use default layout
|
70
|
-
@layout_path = Nekonote.get_root_path + PATH_TO_LAYOUT + '/' + DEFAULT_LAYOUT_NAME + '.tpl'
|
71
|
-
if !Util::Filer.available_file? @layout_path
|
72
|
-
# but if it's not available, no layout with response
|
73
|
-
@layout_path = nil
|
74
|
-
end
|
75
|
-
else
|
76
|
-
# no layout with response
|
77
|
-
@layout_path = nil
|
78
|
-
end
|
52
|
+
# initialize template and layout
|
53
|
+
init_template handler_name
|
54
|
+
init_layout
|
79
55
|
|
80
56
|
# assign extra fields into templates
|
81
57
|
assign_custom_fields info
|
@@ -263,6 +239,22 @@ module Nekonote
|
|
263
239
|
end
|
264
240
|
end
|
265
241
|
|
242
|
+
# Need reload after method was called and commented out it because view object will alive
|
243
|
+
# @param string path relative path from app root to template file
|
244
|
+
public
|
245
|
+
def set_template(path)
|
246
|
+
@info_template = path
|
247
|
+
init_template
|
248
|
+
end
|
249
|
+
|
250
|
+
# Need reload after method was called and commented out it because view object will alive
|
251
|
+
# @param string path relative path from app root to layout file
|
252
|
+
public
|
253
|
+
def set_layout(path)
|
254
|
+
@info_layout = path
|
255
|
+
init_layout
|
256
|
+
end
|
257
|
+
|
266
258
|
# @param hash info
|
267
259
|
private
|
268
260
|
def register_info_properies(info)
|
@@ -283,6 +275,54 @@ module Nekonote
|
|
283
275
|
@is_redirect = false
|
284
276
|
end
|
285
277
|
|
278
|
+
# initialize conf about template by @info_template
|
279
|
+
# @param string|nil handler_name
|
280
|
+
private
|
281
|
+
def init_template(handler_name = nil)
|
282
|
+
if @info_template.is_a? String
|
283
|
+
# check exists later
|
284
|
+
@template_path = get_template_path @info_template
|
285
|
+
elsif @info_template == nil && handler_name.is_a?(String)
|
286
|
+
# try to set a default template
|
287
|
+
@template_path = get_default_template_path handler_name
|
288
|
+
else
|
289
|
+
# no use template
|
290
|
+
@template_path = nil
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
# initialize conf about layout by @info_layout
|
295
|
+
private
|
296
|
+
def init_layout
|
297
|
+
if @info_layout.is_a? String
|
298
|
+
# check exists later
|
299
|
+
@layout_path = get_layout_path @info_layout
|
300
|
+
elsif @info_layout == nil
|
301
|
+
# try to set a default layout
|
302
|
+
@layout_path = get_layout_path DEFAULT_LAYOUT_NAME
|
303
|
+
if !Util::Filer.available_file? @layout_path
|
304
|
+
@layout_path = nil
|
305
|
+
end
|
306
|
+
else
|
307
|
+
# no use layout
|
308
|
+
@layout_path = nil
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
# @param string template relative path to template file
|
313
|
+
# @return string absolute path
|
314
|
+
private
|
315
|
+
def get_template_path(template)
|
316
|
+
return Nekonote.get_root_path + PATH_TO_TEMPLATE + '/' + template + '.tpl'
|
317
|
+
end
|
318
|
+
|
319
|
+
# @param string layout relative path to layout file
|
320
|
+
# @return string absolute path
|
321
|
+
private
|
322
|
+
def get_layout_path(layout)
|
323
|
+
return Nekonote.get_root_path + PATH_TO_LAYOUT + '/' + layout + '.tpl'
|
324
|
+
end
|
325
|
+
|
286
326
|
# Returns template path for the default when it was found and available
|
287
327
|
# @param string|nil
|
288
328
|
private
|
@@ -296,10 +336,13 @@ module Nekonote
|
|
296
336
|
template = nil
|
297
337
|
end
|
298
338
|
|
299
|
-
# invalid template
|
339
|
+
# return nil if invalid template name
|
300
340
|
return nil if (template.nil? || template == '')
|
301
341
|
|
302
|
-
|
342
|
+
# get absolute path
|
343
|
+
template_path = get_template_path template
|
344
|
+
|
345
|
+
# set if available
|
303
346
|
if Util::Filer.available_file? template_path
|
304
347
|
template_path = template_path
|
305
348
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nekonote-framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.
|
4
|
+
version: 1.0.0.pre.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khotta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: color_echo
|
@@ -66,11 +66,11 @@ files:
|
|
66
66
|
- data/structure/public/img/.gitkeep
|
67
67
|
- data/structure/public/img/logo.png
|
68
68
|
- data/structure/public/js/.gitkeep
|
69
|
-
- data/structure/
|
70
|
-
- data/structure/
|
71
|
-
- data/structure/
|
72
|
-
- data/structure/
|
73
|
-
- data/structure/
|
69
|
+
- data/structure/public/sass/welcome.scss
|
70
|
+
- data/structure/template/error.tpl
|
71
|
+
- data/structure/template/layout/default.tpl
|
72
|
+
- data/structure/template/layout/error.tpl
|
73
|
+
- data/structure/template/welcome/index.tpl
|
74
74
|
- data/structure/tmp/pids/.gitkeep
|
75
75
|
- lib/loader.rb
|
76
76
|
- lib/nekonote.rb
|
@@ -113,9 +113,9 @@ post_install_message: |2+
|
|
113
113
|
.*・゜゚・*:.。..。.:・Thanks installing Nekonote Framework .*・゜゚・*:.。..。.:*・
|
114
114
|
|
115
115
|
^___^
|
116
|
-
(=^x^=) < meow
|
117
|
-
|
118
|
-
.
|
116
|
+
(=^x^=) < meow
|
117
|
+
~ / ) !
|
118
|
+
. ( h h . . . . . . =(**=)~~
|
119
119
|
|
120
120
|
Note:
|
121
121
|
Installing dependent libraries is not completed yet.
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: 1.3.1
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.6
|
140
|
+
rubygems_version: 2.7.6
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Simple and Lightweight Ruby Framework for Web Development
|