decko 0.11.0 → 0.11.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/body-bg.bmp +0 -0
- data/app/assets/images/body-bg.png +0 -0
- data/app/assets/images/external_link.png +0 -0
- data/app/assets/images/smoothness/animated-overlay.gif +0 -0
- data/app/assets/images/smoothness/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/images/smoothness/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/app/assets/images/smoothness/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/app/assets/images/smoothness/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/app/assets/images/smoothness/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/app/assets/images/smoothness/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/app/assets/images/smoothness/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/app/assets/images/smoothness/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/app/assets/images/smoothness/ui-icons_222222_256x240.png +0 -0
- data/app/assets/images/smoothness/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/images/smoothness/ui-icons_454545_256x240.png +0 -0
- data/app/assets/images/smoothness/ui-icons_888888_256x240.png +0 -0
- data/app/assets/images/smoothness/ui-icons_cd0a0a_256x240.png +0 -0
- data/bin/decko +2 -2
- data/lib/card_controller.rb +25 -0
- data/lib/card_controller/errors.rb +36 -0
- data/lib/card_controller/mark.rb +66 -0
- data/lib/{decko → card_controller}/response.rb +7 -63
- data/lib/card_controller/rest.rb +105 -0
- data/lib/decko.rb +1 -2
- data/lib/decko/application.rb +4 -1
- data/lib/decko/cli.rb +1 -1
- data/lib/decko/commands.rb +9 -9
- data/lib/decko/commands/application.rb +1 -1
- data/lib/decko/commands/cucumber_command.rb +2 -2
- data/lib/decko/commands/cucumber_command/parser.rb +28 -24
- data/lib/decko/commands/rake_command.rb +3 -2
- data/lib/decko/commands/rake_command/parser.rb +2 -1
- data/lib/decko/commands/rspec_command.rb +2 -2
- data/lib/decko/commands/rspec_command/parser.rb +1 -0
- data/lib/decko/config/environments/cucumber.rb +1 -0
- data/lib/decko/config/environments/development.rb +1 -1
- data/lib/decko/config/environments/production.rb +6 -1
- data/lib/decko/config/environments/profile.rb +1 -0
- data/lib/decko/config/environments/test.rb +1 -0
- data/lib/decko/config/initializers/secret_token.rb +1 -0
- data/lib/decko/config/initializers/sedate_parser.rb +3 -2
- data/lib/decko/engine.rb +0 -2
- data/lib/decko/generators/deck/deck_generator.rb +3 -1
- data/lib/decko/generators/deck/deck_generator/deck_helper.rb +1 -1
- data/lib/decko/generators/deck/deck_generator/interactive.rb +4 -4
- data/lib/decko/generators/deck/templates/Rakefile.erb +1 -2
- data/lib/decko/generators/deck/templates/config.ru.erb +3 -3
- data/lib/decko/generators/deck/templates/config/application.rb.erb +13 -13
- data/lib/decko/generators/deck/templates/config/boot.rb.erb +4 -4
- data/lib/decko/generators/deck/templates/config/environment.rb.erb +1 -1
- data/lib/decko/generators/deck/templates/config/storage.yml +0 -0
- data/lib/decko/generators/deck/templates/rspec.erb +1 -1
- data/lib/decko/generators/deck/templates/script/decko +3 -3
- data/lib/decko/script_decko_loader.rb +32 -17
- data/lib/decko/tasks/alias.rb +4 -5
- data/lib/decko/tasks/cucumber.rake +52 -44
- data/lib/decko/tasks/db.rake +9 -2
- data/lib/decko/tasks/decko.rake +6 -4
- data/lib/decko/tasks/decko/seed.rake +4 -1
- data/rails/application-routes.rb +3 -0
- data/rails/assets/external_link.png +0 -0
- data/rails/assets/jasmine/404.html +27 -0
- data/rails/assets/jasmine/500.html +28 -0
- data/rails/assets/jasmine/card_form.html +13 -0
- data/rails/assets/jquery.min.map +1 -0
- data/rails/engine-routes.rb +53 -0
- data/script/autospec +4 -0
- data/script/decko +6 -0
- data/script/rails +6 -0
- metadata +47 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c726ee70f0d8daba2891b23aab64090c43d088cc3300290a52eddee922dc7d0
|
4
|
+
data.tar.gz: c3e610b82510c510d2dfb16ecd1c408fe0be17c7e0b1d1209ce92432d52513e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c18ed07879923d174cea1cc75a860406a5f6548dfbc56dfe4d27610ee64d29ce0df3cbfdd500362b2ce2780948d48f2e54aac487d437141e0b91c29a78d9935
|
7
|
+
data.tar.gz: a76d39182e7d95ac2192a4a90017dd337f07d786379379dc3a5166765a2f7241b3abc8b025ae8a7210aa0dd7431552dab7c1ce877acc4c394801d4cd410e2250
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/bin/decko
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
git_path = File.expand_path("
|
3
|
+
git_path = File.expand_path("../../.git", __dir__)
|
4
4
|
|
5
5
|
if File.exist?(git_path)
|
6
|
-
railties_path = File.expand_path("
|
6
|
+
railties_path = File.expand_path("../lib", __dir__)
|
7
7
|
$LOAD_PATH.unshift(railties_path)
|
8
8
|
end
|
9
9
|
require "decko/cli"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
# Decko's only controller.
|
4
|
+
class CardController < ActionController::Base
|
5
|
+
include Mark
|
6
|
+
include Rest
|
7
|
+
include Response
|
8
|
+
include Errors
|
9
|
+
|
10
|
+
# NOTE: including Card::Env::Location triggers card loading, which triggers mod loading,
|
11
|
+
# which can include initializers that add to the CardController class.
|
12
|
+
# It's important that it come *after* the modules above, so that mod modules
|
13
|
+
# can override them.
|
14
|
+
include ::Card::Env::Location
|
15
|
+
|
16
|
+
layout nil
|
17
|
+
attr_reader :card
|
18
|
+
|
19
|
+
before_action :setup, except: [:asset]
|
20
|
+
before_action :authenticate, except: [:asset]
|
21
|
+
before_action :load_mark, only: [:read]
|
22
|
+
before_action :load_card, except: [:asset]
|
23
|
+
before_action :load_action, only: [:read]
|
24
|
+
before_action :refresh_card, only: %i[create update delete]
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Decko's only controller.
|
2
|
+
class CardController
|
3
|
+
class << self
|
4
|
+
def rescue_from_class *klasses
|
5
|
+
klasses.each do |klass|
|
6
|
+
rescue_from(klass) { |exception| handle_exception exception }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def rescue_all?
|
11
|
+
Cardio.config.rescue_all_in_controller
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# controller error handling
|
16
|
+
module Errors
|
17
|
+
def handle_exception exception
|
18
|
+
raise exception if debug_exception?(exception)
|
19
|
+
|
20
|
+
@card ||= Card.new
|
21
|
+
error = Card::Error.report exception, card
|
22
|
+
show error.class.view, error.class.status_code
|
23
|
+
end
|
24
|
+
|
25
|
+
# TODO: move to exception object
|
26
|
+
def debug_exception? e
|
27
|
+
!e.is_a?(Card::Error::UserError) &&
|
28
|
+
!e.is_a?(ActiveRecord::RecordInvalid) &&
|
29
|
+
Card::Codename[:debugger] &&
|
30
|
+
Card[:debugger]&.content =~ /on/ # && !Card::Env.ajax?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
rescue_from_class(*Card::Error::UserError.user_error_classes)
|
35
|
+
rescue_from_class StandardError if rescue_all?
|
36
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class CardController
|
2
|
+
# methods for interpretation of card marks requested
|
3
|
+
module Mark
|
4
|
+
private
|
5
|
+
|
6
|
+
def load_mark
|
7
|
+
params[:mark] = interpret_mark params[:mark]
|
8
|
+
end
|
9
|
+
|
10
|
+
def interpret_mark mark
|
11
|
+
case mark
|
12
|
+
when "*previous"
|
13
|
+
# Why support this? It's only needed in Success, right? Deprecate?
|
14
|
+
hard_redirect Card::Env.previous_location
|
15
|
+
when nil
|
16
|
+
implicit_mark
|
17
|
+
else
|
18
|
+
explicit_mark mark
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def explicit_mark mark
|
23
|
+
# we should find the place where we produce these bad urls
|
24
|
+
mark.valid_encoding? ? mark : mark.force_encoding("ISO-8859-1").encode("UTF-8")
|
25
|
+
end
|
26
|
+
|
27
|
+
def implicit_mark
|
28
|
+
case
|
29
|
+
when initial_setup
|
30
|
+
""
|
31
|
+
when (name = mark_from_card_hash)
|
32
|
+
name
|
33
|
+
when view_does_not_require_name?
|
34
|
+
""
|
35
|
+
else
|
36
|
+
home_mark
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def home_mark
|
41
|
+
Card::Rule.global_setting(:home) || "Home"
|
42
|
+
end
|
43
|
+
|
44
|
+
def view_does_not_require_name?
|
45
|
+
return false unless (view = params[:view]&.to_sym)
|
46
|
+
|
47
|
+
Card::Set::Format::AbstractFormat::ViewOpts.unknown_ok[view]
|
48
|
+
end
|
49
|
+
|
50
|
+
def mark_from_card_hash
|
51
|
+
params.dig :card, :name
|
52
|
+
end
|
53
|
+
|
54
|
+
# alters params
|
55
|
+
def initial_setup
|
56
|
+
return unless Card::Auth.needs_setup? && Card::Env.html?
|
57
|
+
|
58
|
+
prepare_setup_card!
|
59
|
+
end
|
60
|
+
|
61
|
+
def prepare_setup_card!
|
62
|
+
params[:card] = { type_id: Card.default_accounted_type_id }
|
63
|
+
params[:view] = "setup"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
class CardController
|
2
2
|
# methods for managing decko responses
|
3
3
|
module Response
|
4
4
|
def response_format
|
@@ -72,13 +72,8 @@ module Decko
|
|
72
72
|
|
73
73
|
def require_card_for_soft_redirect!
|
74
74
|
return if card.is_a? Card
|
75
|
-
raise Card::Error, "tried to do soft redirect without a card"
|
76
|
-
end
|
77
75
|
|
78
|
-
|
79
|
-
def send_deprecated_asset
|
80
|
-
filename = [params[:mark], params[:format]].compact.join(".")
|
81
|
-
send_file asset_file_path(filename), x_sendfile: true
|
76
|
+
raise Card::Error, "tried to do soft redirect without a card"
|
82
77
|
end
|
83
78
|
|
84
79
|
def asset_file_path filename
|
@@ -97,9 +92,9 @@ module Decko
|
|
97
92
|
# below is about beginning (initialization). above is about end (response)
|
98
93
|
# Both this file and that would make sense as submodules of CardController
|
99
94
|
|
100
|
-
def load_format
|
95
|
+
def load_format status
|
101
96
|
request.format = :html if implicit_html?
|
102
|
-
card.format
|
97
|
+
card.format(response_format).tap { |fmt| fmt.error_status = status }
|
103
98
|
end
|
104
99
|
|
105
100
|
def implicit_html?
|
@@ -107,64 +102,13 @@ module Decko
|
|
107
102
|
end
|
108
103
|
|
109
104
|
def format_name_from_params
|
110
|
-
if explicit_file_format?
|
111
|
-
|
112
|
-
|
113
|
-
end
|
105
|
+
return :file if explicit_file_format?
|
106
|
+
|
107
|
+
(params[:format].present? ? params[:format] : request.format).to_sym
|
114
108
|
end
|
115
109
|
|
116
110
|
def explicit_file_format?
|
117
111
|
params[:explicit_file] || !Card::Format.registered.member?(request.format)
|
118
112
|
end
|
119
|
-
|
120
|
-
def interpret_mark mark
|
121
|
-
case mark
|
122
|
-
when "*previous"
|
123
|
-
# Why support this? It's only needed in Success, right? Deprecate?
|
124
|
-
return hard_redirect(Card::Env.previous_location)
|
125
|
-
when nil
|
126
|
-
implicit_mark
|
127
|
-
else
|
128
|
-
explicit_mark mark
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def explicit_mark mark
|
133
|
-
# we should find the place where we produce these bad urls
|
134
|
-
mark.valid_encoding? ? mark : mark.force_encoding("ISO-8859-1").encode("UTF-8")
|
135
|
-
end
|
136
|
-
|
137
|
-
def implicit_mark
|
138
|
-
case
|
139
|
-
when initial_setup then ""
|
140
|
-
when (name = params.dig :card, :name) then name
|
141
|
-
when view_does_not_require_name? then ""
|
142
|
-
else home_mark
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def home_mark
|
147
|
-
Card::Rule.global_setting(:home) || "Home"
|
148
|
-
end
|
149
|
-
|
150
|
-
def view_does_not_require_name?
|
151
|
-
return false unless (view = params[:view]&.to_sym)
|
152
|
-
Card::Set::Format::AbstractFormat::ViewOpts.unknown_ok[view]
|
153
|
-
end
|
154
|
-
|
155
|
-
# alters params
|
156
|
-
def initial_setup
|
157
|
-
return unless initial_setup?
|
158
|
-
prepare_setup_card!
|
159
|
-
end
|
160
|
-
|
161
|
-
def initial_setup?
|
162
|
-
Card::Auth.needs_setup? && Card::Env.html?
|
163
|
-
end
|
164
|
-
|
165
|
-
def prepare_setup_card!
|
166
|
-
params[:card] = { type_id: Card.default_accounted_type_id }
|
167
|
-
params[:view] = "setup"
|
168
|
-
end
|
169
113
|
end
|
170
114
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
class CardController
|
2
|
+
# RESTful action methods for card
|
3
|
+
module Rest
|
4
|
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
# PUBLIC METHODS
|
6
|
+
|
7
|
+
def create
|
8
|
+
handle { card.save! }
|
9
|
+
end
|
10
|
+
|
11
|
+
def read
|
12
|
+
show
|
13
|
+
end
|
14
|
+
|
15
|
+
def update
|
16
|
+
card.new_card? ? create : handle { card.update! params[:card]&.to_unsafe_h }
|
17
|
+
end
|
18
|
+
|
19
|
+
def delete
|
20
|
+
handle { card.delete! }
|
21
|
+
end
|
22
|
+
|
23
|
+
# @deprecated
|
24
|
+
def asset
|
25
|
+
body = "Decko installation error: missing asset symlinks"
|
26
|
+
Rails.logger.info "#{body}.\n >>> Try `rake decko:update_assets_symlink`"
|
27
|
+
render body: body, status: 404
|
28
|
+
end
|
29
|
+
|
30
|
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
31
|
+
# PRIVATE METHODS
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def setup
|
36
|
+
Card::Machine.refresh_script_and_style unless params[:explicit_file]
|
37
|
+
Card::Cache.renew
|
38
|
+
Card::Env.reset controller: self
|
39
|
+
end
|
40
|
+
|
41
|
+
def authenticate
|
42
|
+
Card::Auth.signin_with params
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_card
|
46
|
+
@card = Card.uri_fetch params
|
47
|
+
raise Card::Error::NotFound unless card
|
48
|
+
|
49
|
+
record_as_main
|
50
|
+
end
|
51
|
+
|
52
|
+
def load_action
|
53
|
+
card.select_action_by_params params
|
54
|
+
return unless params[:edit_draft] && card.drafts.present?
|
55
|
+
|
56
|
+
card.content = card.last_draft_content
|
57
|
+
end
|
58
|
+
|
59
|
+
# TODO: refactor this away this when new layout handling is ready
|
60
|
+
def record_as_main
|
61
|
+
Card::Env[:main_name] = params[:main] || card&.name || ""
|
62
|
+
end
|
63
|
+
|
64
|
+
def refresh_card
|
65
|
+
@card = card.refresh
|
66
|
+
end
|
67
|
+
|
68
|
+
# ----------( HELPER METHODS ) -------------
|
69
|
+
|
70
|
+
def handle
|
71
|
+
Card::Env.success card.name
|
72
|
+
yield ? cud_success : raise(Card::Error::UserError)
|
73
|
+
end
|
74
|
+
|
75
|
+
# successful create, update, or delete act
|
76
|
+
def cud_success
|
77
|
+
success = Card::Env.success.in_context card.name
|
78
|
+
if success.reload?
|
79
|
+
reload # instruct JSON to reload
|
80
|
+
else
|
81
|
+
redirect_cud_success success
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def show view=nil, status=200
|
86
|
+
card.action = :read
|
87
|
+
format = load_format status
|
88
|
+
result = render_page format, view
|
89
|
+
status = format.error_status || status
|
90
|
+
respond format, result, status
|
91
|
+
end
|
92
|
+
|
93
|
+
def render_page format, view
|
94
|
+
view ||= view_from_params
|
95
|
+
card.act do
|
96
|
+
format.page self, view, Card::Env.slot_opts
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def view_from_params
|
101
|
+
%i[view v].each { |k| return params[k] if params[k].present? }
|
102
|
+
nil
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/decko.rb
CHANGED
data/lib/decko/application.rb
CHANGED
@@ -63,7 +63,9 @@ module Decko
|
|
63
63
|
config.filter_parameters += [:password]
|
64
64
|
|
65
65
|
# Rails.autoloaders.log!
|
66
|
-
Rails.autoloaders.main.ignore(
|
66
|
+
Rails.autoloaders.main.ignore(
|
67
|
+
File.join(Cardio.gem_root, "lib/card/seed_consts.rb")
|
68
|
+
)
|
67
69
|
config
|
68
70
|
end
|
69
71
|
end
|
@@ -77,6 +79,7 @@ module Decko
|
|
77
79
|
|
78
80
|
paths["app/models"] = []
|
79
81
|
paths["app/mailers"] = []
|
82
|
+
paths["app/controllers"] = []
|
80
83
|
|
81
84
|
unless paths["config/routes.rb"].existent.present?
|
82
85
|
add_path paths, "config/routes.rb",
|
data/lib/decko/cli.rb
CHANGED
@@ -3,7 +3,7 @@ require "decko/script_decko_loader"
|
|
3
3
|
|
4
4
|
# If we are inside a Decko application this method performs an exec and thus
|
5
5
|
# the rest of this script is not run.
|
6
|
-
Decko::ScriptDeckoLoader.
|
6
|
+
Decko::ScriptDeckoLoader.exec!
|
7
7
|
|
8
8
|
require "rails/ruby_version_check"
|
9
9
|
Signal.trap("INT") { puts; exit(1) }
|
data/lib/decko/commands.rb
CHANGED
@@ -7,21 +7,21 @@ def load_rake_tasks
|
|
7
7
|
Decko::Application.load_tasks
|
8
8
|
end
|
9
9
|
|
10
|
-
RAILS_COMMANDS = %w
|
11
|
-
server dbconsole application runner
|
12
|
-
DECKO_COMMANDS = %w
|
13
|
-
DECKO_DB_COMMANDS = %w
|
10
|
+
RAILS_COMMANDS = %w[ generate destroy plugin benchmarker profiler console
|
11
|
+
server dbconsole application runner ].freeze
|
12
|
+
DECKO_COMMANDS = %w[new cucumber rspec jasmine].freeze
|
13
|
+
DECKO_DB_COMMANDS = %w[seed reseed load update].freeze
|
14
14
|
|
15
15
|
ALIAS = {
|
16
16
|
"rs" => "rspec",
|
17
17
|
"cc" => "cucumber",
|
18
18
|
"jm" => "jasmine",
|
19
|
-
"g"
|
20
|
-
"d"
|
21
|
-
"c"
|
22
|
-
"s"
|
19
|
+
"g" => "generate",
|
20
|
+
"d" => "destroy",
|
21
|
+
"c" => "console",
|
22
|
+
"s" => "server",
|
23
23
|
"db" => "dbconsole",
|
24
|
-
"r"
|
24
|
+
"r" => "runner"
|
25
25
|
}.freeze
|
26
26
|
|
27
27
|
def supported_rails_command? arg
|