decko 0.11.3 → 0.11.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/decko +2 -2
- data/lib/card_controller.rb +25 -0
- data/{rails/controllers → lib}/card_controller/errors.rb +1 -0
- data/lib/card_controller/mark.rb +66 -0
- data/lib/{decko → card_controller}/response.rb +5 -61
- 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 +3 -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 +2 -1
- data/lib/decko/generators/deck/deck_generator/interactive.rb +4 -4
- data/lib/decko/generators/deck/templates/config/application.rb.erb +2 -2
- 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/docs.rake +1 -1
- data/lib/decko/tasks/decko/seed.rake +3 -0
- data/rails/engine-routes.rb +1 -1
- data/script/decko +2 -2
- data/script/rails +4 -4
- metadata +12 -12
- data/rails/controllers/application_controller.rb +0 -2
- data/rails/controllers/card_controller.rb +0 -122
- data/script/test_filter +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a66f5fefa04c2c0cdb0d972fb53a292ffa8db86c0cdaefbce4311df918793b32
|
4
|
+
data.tar.gz: 6a01a78d7177b1a29917373117db2d09a85c14737eb1c05f66db27b6ca79e4d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 497737ef6f1fc5e506fc4c2e399134dbe2528d24a4cc688a9c140ad5d883822ae9d04340f10108f7f978b227f2daed69d819844208aa2d07536e6fdaa78e057f
|
7
|
+
data.tar.gz: 4d32fc214d767aaf52d34c6bff39d7595cf029daf6dad37febf95c4ed64e923d3ea51afed006d26152d8a5f8863484a7c31820e02f175b0110ac979d80498e71
|
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,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
|
@@ -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
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path("
|
1
|
+
require File.expand_path("command", __dir__)
|
2
2
|
|
3
3
|
module Decko
|
4
4
|
module Commands
|
@@ -45,4 +45,4 @@ module Decko
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
require File.expand_path("
|
48
|
+
require File.expand_path("cucumber_command/parser", __dir__)
|
@@ -1,38 +1,42 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
|
2
3
|
require "optparse"
|
3
4
|
|
4
5
|
module Decko
|
5
6
|
module Commands
|
6
7
|
class CucumberCommand
|
7
8
|
class Parser < OptionParser
|
9
|
+
class Flagger
|
10
|
+
def initialize parser, opts
|
11
|
+
@parser = parser
|
12
|
+
@opts = opts
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_flags
|
16
|
+
add_flag "DEBUG", "-d", "--debug", "Drop into debugger on failure"
|
17
|
+
add_flag "FAST", "-f", "--fast", "Stop on first failure"
|
18
|
+
add_flag "LAUNCH", "-l", "--launchy", "Open page on failure"
|
19
|
+
add_flag "STEP", "-s", "--step", "Pause after each step"
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_flag flag, *args
|
23
|
+
@parser.on(*args) { |a| @opts[:env] << "#{flag}=1" if a }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse_spring parser, opts
|
28
|
+
parser.on("--[no-]spring", "Run with spring") do |spring|
|
29
|
+
opts[:executer] = spring ? "spring" : "bundle exec"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
8
33
|
def initialize opts
|
9
34
|
super() do |parser|
|
10
35
|
parser.banner = "Usage: decko cucumber [DECKO ARGS] -- [CUCUMBER ARGS]\n\n"
|
11
|
-
parser.separator
|
12
|
-
|
13
|
-
DECKO ARGS
|
14
|
-
EOT
|
36
|
+
parser.separator "\nDECKO ARGS"
|
15
37
|
opts[:env] = ["RAILS_ROOT=."]
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
parser.on("-f", "--fast", "Stop on first failure") do |a|
|
20
|
-
opts[:env] << "FAST=1" if a
|
21
|
-
end
|
22
|
-
parser.on("-l", "--launchy", "Open page on failure") do |a|
|
23
|
-
opts[:env] << "LAUNCHY=1" if a
|
24
|
-
end
|
25
|
-
parser.on("-s", "--step", "Pause after each step") do |a|
|
26
|
-
opts[:env] << "STEP=1" if a
|
27
|
-
end
|
28
|
-
parser.on("--[no-]spring", "Run with spring") do |spring|
|
29
|
-
opts[:executer] =
|
30
|
-
if spring
|
31
|
-
"spring"
|
32
|
-
else
|
33
|
-
"bundle exec"
|
34
|
-
end
|
35
|
-
end
|
38
|
+
Flagger.new(parser, opts).add_flags
|
39
|
+
parse_spring parser, opts
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path("
|
1
|
+
require File.expand_path("command", __dir__)
|
2
2
|
# require "pry"
|
3
3
|
|
4
4
|
module Decko
|
@@ -30,6 +30,7 @@ module Decko
|
|
30
30
|
def commands
|
31
31
|
task_cmd = "bundle exec rake #{@task}"
|
32
32
|
return [task_cmd] if !@envs || @envs.empty?
|
33
|
+
|
33
34
|
@envs.map do |env|
|
34
35
|
"env RAILS_ENV=#{env} #{task_cmd}"
|
35
36
|
end
|
@@ -38,4 +39,4 @@ module Decko
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
|
-
require File.expand_path("
|
42
|
+
require File.expand_path("rake_command/parser", __dir__)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
|
2
3
|
require "optparse"
|
3
4
|
|
4
5
|
module Decko
|
@@ -24,7 +25,7 @@ module Decko
|
|
24
25
|
end
|
25
26
|
parser.on("--all", "-a",
|
26
27
|
"#{command} production, test, and development database") do
|
27
|
-
opts[:envs] = %w
|
28
|
+
opts[:envs] = %w[production development test]
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path("
|
1
|
+
require File.expand_path("command", __dir__)
|
2
2
|
|
3
3
|
module Decko
|
4
4
|
module Commands
|
@@ -33,4 +33,4 @@ module Decko
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
require File.expand_path("
|
36
|
+
require File.expand_path("rspec_command/parser", __dir__)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
|
2
3
|
Decko.application.class.configure do
|
3
4
|
# Settings specified here will take precedence over those in config/application.rb
|
4
5
|
|
@@ -50,7 +51,8 @@ Decko.application.class.configure do
|
|
50
51
|
# config.action_controller.asset_host = "http://assets.example.com"
|
51
52
|
|
52
53
|
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
53
|
-
config.assets.precompile += %w
|
54
|
+
config.assets.precompile += %w[application-all.css application-print.css barebones.css
|
55
|
+
html5shiv-printshiv.js]
|
54
56
|
|
55
57
|
# Disable delivery errors, bad email addresses will be ignored
|
56
58
|
# config.action_mailer.raise_delivery_errors = false
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# Hack to get rid of annoying parser warnings
|
2
2
|
module Parser
|
3
3
|
def self.warn msg
|
4
|
-
|
5
|
-
|
4
|
+
super unless msg.match?(
|
5
|
+
%r{^warning: (?:parser/current|[\d.]+-compliant syntax|please see)}
|
6
|
+
)
|
6
7
|
end
|
7
8
|
end
|
data/lib/decko/engine.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
require "rails/all"
|
3
2
|
require "cardio"
|
4
3
|
|
@@ -15,7 +14,6 @@ require "decko"
|
|
15
14
|
|
16
15
|
module Decko
|
17
16
|
class Engine < ::Rails::Engine
|
18
|
-
paths.add "app/controllers", with: "rails/controllers", eager_load: true
|
19
17
|
paths.add "gem-assets", with: "rails/assets"
|
20
18
|
paths.add "config/routes.rb", with: "rails/engine-routes.rb"
|
21
19
|
paths.add "lib/tasks", with: "#{::Decko.gem_root}/lib/decko/tasks",
|
@@ -11,7 +11,7 @@ module Decko
|
|
11
11
|
include RailsOverrides
|
12
12
|
include DeckHelper
|
13
13
|
|
14
|
-
source_root File.expand_path("
|
14
|
+
source_root File.expand_path("templates", __dir__)
|
15
15
|
|
16
16
|
# All but the first aliases should be considered deprecated
|
17
17
|
class_option "monkey",
|
@@ -123,6 +123,7 @@ module Decko
|
|
123
123
|
|
124
124
|
def database_gemfile_entry
|
125
125
|
return [] if options[:skip_active_record]
|
126
|
+
|
126
127
|
gem_name, gem_version = gem_for_database
|
127
128
|
msg = "Use #{options[:database]} as the database for Active Record"
|
128
129
|
GemfileEntry.version gem_name, gem_version, msg
|
@@ -52,8 +52,8 @@ module Decko
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def build_option key, desc, command
|
55
|
-
command &&= "
|
56
|
-
" #{key} - #{desc}#{command
|
55
|
+
command &&= "#{' ' * (65 - desc.size)}[#{command}]"
|
56
|
+
" #{key} - #{desc}#{command}"
|
57
57
|
end
|
58
58
|
|
59
59
|
def add_config_options
|
@@ -108,9 +108,9 @@ module Decko
|
|
108
108
|
def add_after_seed_options
|
109
109
|
@menu["x"][:desc] = "exit"
|
110
110
|
@menu["r"] = {
|
111
|
-
desc:
|
111
|
+
desc: "run decko server",
|
112
112
|
command: "decko server",
|
113
|
-
code:
|
113
|
+
code: proc { bundle_exec "decko server" }
|
114
114
|
}
|
115
115
|
end
|
116
116
|
end
|
@@ -36,11 +36,11 @@ module <%= app_const_base %>
|
|
36
36
|
# CACHING
|
37
37
|
# config.cache_store = :file_store, "tmp/cache"
|
38
38
|
# determines caching mechanism. options include: file_store, memory_store,
|
39
|
-
# mem_cache_store
|
39
|
+
# mem_cache_store...
|
40
40
|
#
|
41
41
|
# for production, we highly recommend memcache
|
42
42
|
# here's a sample configuration for use with the dalli gem
|
43
|
-
# config.cache_store = :
|
43
|
+
# config.cache_store = :mem_cache_store, []
|
44
44
|
|
45
45
|
|
46
46
|
# FILES
|
@@ -6,26 +6,41 @@ module Decko
|
|
6
6
|
RbConfig::CONFIG["EXEEXT"]
|
7
7
|
SCRIPT_DECKO = File.join("script", "decko")
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
class << self
|
10
|
+
def exec!
|
11
|
+
cwd = Dir.pwd
|
12
|
+
return unless continue?
|
13
|
+
|
14
|
+
exec_decko_script
|
15
|
+
recurse cwd
|
16
|
+
rescue SystemCallError
|
17
|
+
# could not chdir, no problem just return
|
17
18
|
end
|
18
|
-
rescue SystemCallError
|
19
|
-
# could not chdir, no problem just return
|
20
|
-
end
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
def recurse cwd
|
21
|
+
Dir.chdir("..") do
|
22
|
+
# Recurse in a chdir block: if the search fails we want to be sure
|
23
|
+
# the application is generated in the original working directory.
|
24
|
+
exec! unless cwd == Dir.pwd
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def exec_decko_script
|
29
|
+
exec RUBY, SCRIPT_DECKO, *ARGV if in_application?
|
30
|
+
end
|
25
31
|
|
26
|
-
|
27
|
-
|
28
|
-
|
32
|
+
def continue?
|
33
|
+
in_application? || in_application_subdirectory?
|
34
|
+
end
|
35
|
+
|
36
|
+
def in_application?
|
37
|
+
File.exist?(SCRIPT_DECKO)
|
38
|
+
end
|
39
|
+
|
40
|
+
def in_application_subdirectory? path=Pathname.new(Dir.pwd)
|
41
|
+
File.exist?(File.join(path, SCRIPT_DECKO)) ||
|
42
|
+
!path.root? && in_application_subdirectory?(path.parent)
|
43
|
+
end
|
29
44
|
end
|
30
45
|
end
|
31
46
|
end
|
data/lib/decko/tasks/alias.rb
CHANGED
@@ -16,16 +16,15 @@ def link_task task, from: nil, to: nil, namespace: nil
|
|
16
16
|
case task
|
17
17
|
when Hash
|
18
18
|
task.each do |key, val|
|
19
|
-
link_task val, from: from, to: to
|
20
|
-
|
21
|
-
|
19
|
+
link_task val, from: from, to: to,
|
20
|
+
namespace: append_to_namespace(namespace, key)
|
22
21
|
end
|
23
22
|
when Array
|
24
23
|
task.each do |t|
|
25
|
-
|
24
|
+
link_task t, from: from, to: to, namespace: namespace
|
26
25
|
end
|
27
26
|
else
|
28
27
|
shared_part = append_to_namespace namespace, task
|
29
28
|
alias_task "#{from}:#{shared_part}", "#{to}:#{shared_part}"
|
30
29
|
end
|
31
|
-
end
|
30
|
+
end
|
@@ -5,61 +5,69 @@
|
|
5
5
|
# files.
|
6
6
|
|
7
7
|
unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gems:* tasks
|
8
|
+
vendored_cucumber_bin =
|
9
|
+
Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
10
|
+
unless vendored_cucumber_bin.nil?
|
11
|
+
$LOAD_PATH.unshift("#{File.dirname(vendored_cucumber_bin)}/../lib")
|
12
|
+
end
|
8
13
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
begin
|
13
|
-
require "cucumber/rake/task"
|
14
|
+
begin
|
15
|
+
require "cucumber/rake/task"
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
namespace :cucumber do
|
18
|
+
Cucumber::Rake::Task.new({ ok: "db:test:prepare" },
|
19
|
+
"Run features that should pass") do |t|
|
20
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
21
|
+
t.fork = true # You may get faster startup if you set this to false
|
22
|
+
t.profile = "default"
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
Cucumber::Rake::Task.new({ wip: "db:test:prepare" },
|
26
|
+
"Run features that are being worked on") do |t|
|
27
|
+
t.binary = vendored_cucumber_bin
|
28
|
+
t.fork = true # You may get faster startup if you set this to false
|
29
|
+
t.profile = "wip"
|
30
|
+
end
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
Cucumber::Rake::Task.new(
|
33
|
+
{ rerun: "db:test:prepare" },
|
34
|
+
"Record failing features and run only them if any exist"
|
35
|
+
) do |t|
|
36
|
+
t.binary = vendored_cucumber_bin
|
37
|
+
t.fork = true # You may get faster startup if you set this to false
|
38
|
+
t.profile = "rerun"
|
39
|
+
end
|
33
40
|
|
34
|
-
|
35
|
-
|
41
|
+
desc "Run all features"
|
42
|
+
task all: %i[ok wip]
|
36
43
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
task :statsetup do
|
45
|
+
require "rails/code_statistics"
|
46
|
+
::STATS_DIRECTORIES << %w[Cucumber\ features features] if File.exist?("features")
|
47
|
+
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?("features")
|
48
|
+
::STATS_DIRECTORIES << %w[Mods mods] if File.exist?("mods")
|
49
|
+
end
|
42
50
|
end
|
43
|
-
|
44
|
-
|
45
|
-
task cucumber: "cucumber:ok"
|
51
|
+
desc "Alias for cucumber:ok"
|
52
|
+
task cucumber: "cucumber:ok"
|
46
53
|
|
47
|
-
|
54
|
+
task default: :cucumber
|
48
55
|
|
49
|
-
|
50
|
-
|
51
|
-
|
56
|
+
task features: :cucumber do
|
57
|
+
warn "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
58
|
+
end
|
52
59
|
|
53
|
-
|
54
|
-
|
55
|
-
|
60
|
+
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
|
61
|
+
task "db:test:prepare" do
|
62
|
+
end
|
56
63
|
|
57
|
-
|
58
|
-
rescue LoadError
|
59
|
-
|
60
|
-
|
61
|
-
|
64
|
+
task stats: "cucumber:statsetup"
|
65
|
+
rescue LoadError
|
66
|
+
desc "cucumber rake task not available (cucumber not installed)"
|
67
|
+
task :cucumber do
|
68
|
+
abort "Cucumber rake task is not available. " \
|
69
|
+
"Be sure to install cucumber as a gem or plugin"
|
70
|
+
end
|
62
71
|
end
|
63
|
-
end
|
64
72
|
|
65
73
|
end
|
data/lib/decko/tasks/db.rake
CHANGED
@@ -19,6 +19,7 @@ unless Rake::TaskManager.methods.include?(:redefine_task)
|
|
19
19
|
task
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
22
23
|
class Task
|
23
24
|
class << self
|
24
25
|
def redefine_task args, &block
|
@@ -36,8 +37,14 @@ namespace :db do
|
|
36
37
|
require "active_record/fixtures"
|
37
38
|
fixture_path = File.join(Cardio.gem_root, "db", "seed", "test", "fixtures")
|
38
39
|
ActiveRecord::Base.establish_connection(::Rails.env.to_sym)
|
39
|
-
(
|
40
|
-
|
40
|
+
(if ENV["FIXTURES"]
|
41
|
+
ENV["FIXTURES"].split(/,/)
|
42
|
+
else
|
43
|
+
Dir.glob(File.join(fixture_path,
|
44
|
+
"*.{yml,csv}"))
|
45
|
+
end).each do |fixture_file|
|
46
|
+
ActiveRecord::FixtureSet.create_fixtures(fixture_path,
|
47
|
+
File.basename(fixture_file, ".*"))
|
41
48
|
end
|
42
49
|
end
|
43
50
|
end
|
data/lib/decko/tasks/decko.rake
CHANGED
@@ -5,9 +5,9 @@ require "card/seed_consts"
|
|
5
5
|
CARD_TASKS =
|
6
6
|
[
|
7
7
|
:migrate,
|
8
|
-
{ migrate: [
|
8
|
+
{ migrate: %i[cards structure core_cards deck_cards redo stamp] },
|
9
9
|
:reset_cache
|
10
|
-
]
|
10
|
+
].freeze
|
11
11
|
|
12
12
|
link_task CARD_TASKS, from: :decko, to: :card
|
13
13
|
|
@@ -80,6 +80,7 @@ decko_namespace = namespace :decko do
|
|
80
80
|
if Decko.paths["tmp"].existent
|
81
81
|
Dir.foreach(tmp_dir) do |filename|
|
82
82
|
next if filename.starts_with? "."
|
83
|
+
|
83
84
|
FileUtils.rm_rf File.join(tmp_dir, filename), secure: true
|
84
85
|
end
|
85
86
|
else
|
@@ -111,6 +112,7 @@ decko_namespace = namespace :decko do
|
|
111
112
|
|
112
113
|
def prepped_asset_path
|
113
114
|
return if Rails.root.to_s == Decko.gem_root # inside decko gem
|
115
|
+
|
114
116
|
assets_path = File.join Rails.public_path, "assets"
|
115
117
|
if File.symlink?(assets_path) || !File.directory?(assets_path)
|
116
118
|
FileUtils.rm_rf assets_path
|
@@ -133,7 +135,7 @@ decko_namespace = namespace :decko do
|
|
133
135
|
# creates!
|
134
136
|
begin
|
135
137
|
Rake::Task["db:drop"].invoke
|
136
|
-
rescue
|
138
|
+
rescue StandardError
|
137
139
|
puts "not dropped"
|
138
140
|
end
|
139
141
|
|
@@ -152,7 +154,7 @@ end
|
|
152
154
|
|
153
155
|
def failing_loudly task
|
154
156
|
yield
|
155
|
-
rescue
|
157
|
+
rescue StandardError
|
156
158
|
# TODO: fix this so that message appears *after* the errors.
|
157
159
|
# Solution should ensure that rake still exits with error code 1!
|
158
160
|
raise "\n>>>>>> FAILURE! #{task} did not complete successfully." \
|
@@ -16,7 +16,7 @@ namespace :decko do
|
|
16
16
|
|
17
17
|
# run yardoc command, which generates the docs content in the repo root
|
18
18
|
#
|
19
|
-
# If you run this while decko
|
19
|
+
# If you run this while using decko as a built gem, you could get some funky docs in
|
20
20
|
# your gems directory...
|
21
21
|
task :yardoc do
|
22
22
|
doc_dir = File.expand_path "..", Decko.gem_root
|
@@ -33,6 +33,7 @@ namespace :decko do
|
|
33
33
|
|
34
34
|
def delete_ignored_cards
|
35
35
|
return unless (ignore = Card["*ignore"])
|
36
|
+
|
36
37
|
Card::Auth.as_bot do
|
37
38
|
ignore.item_cards.each(&:delete!)
|
38
39
|
end
|
@@ -62,6 +63,7 @@ namespace :decko do
|
|
62
63
|
Card.search(right: { codename: codename }).each do |card|
|
63
64
|
FileUtils.rm_rf File.join("files", card.id.to_s), secure: true
|
64
65
|
next if reserved_output? card.name
|
66
|
+
|
65
67
|
card.delete!
|
66
68
|
end
|
67
69
|
end
|
@@ -116,6 +118,7 @@ namespace :decko do
|
|
116
118
|
|
117
119
|
def add_test_data
|
118
120
|
return unless Rails.env == "test"
|
121
|
+
|
119
122
|
load CARD_TEST_SEED_SCRIPT_PATH
|
120
123
|
SharedData.add_test_data
|
121
124
|
end
|
data/rails/engine-routes.rb
CHANGED
@@ -37,7 +37,7 @@ Decko::Engine.routes.draw do
|
|
37
37
|
|
38
38
|
# explicit GET alternatives for transactions
|
39
39
|
%w[create read update delete asset].each do |action|
|
40
|
-
get "(card)/#{action}(/:mark(.:format))"
|
40
|
+
get "(card)/#{action}(/:mark(.:format))" => "card", action: action
|
41
41
|
end
|
42
42
|
|
43
43
|
# for super-explicit over-achievers
|
data/script/decko
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
3
|
|
4
|
-
APP_PATH = File.expand_path("
|
5
|
-
require File.expand_path("
|
4
|
+
APP_PATH = File.expand_path("../config/application", __dir__)
|
5
|
+
require File.expand_path("../config/boot", __dir__)
|
6
6
|
require "decko/commands"
|
data/script/rails
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails"
|
2
|
+
# This command will automatically be run when you run "rails"
|
3
3
|
|
4
|
-
APP_PATH = File.expand_path("
|
5
|
-
require File.expand_path("
|
6
|
-
require "rails/commands"
|
4
|
+
# APP_PATH = File.expand_path("../config/application", __dir__)
|
5
|
+
# require File.expand_path("../config/boot", __dir__)
|
6
|
+
# require "rails/commands"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-08-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: card
|
@@ -18,28 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.101.
|
21
|
+
version: 1.101.7
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.101.
|
28
|
+
version: 1.101.7
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: card-mod-defaults
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.11.
|
35
|
+
version: 0.11.7
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.11.
|
42
|
+
version: 0.11.7
|
43
43
|
description: a wiki approach to structured data, dynamic interaction, and web design
|
44
44
|
email:
|
45
45
|
- info@decko.org
|
@@ -66,6 +66,11 @@ files:
|
|
66
66
|
- app/assets/images/smoothness/ui-icons_888888_256x240.png
|
67
67
|
- app/assets/images/smoothness/ui-icons_cd0a0a_256x240.png
|
68
68
|
- bin/decko
|
69
|
+
- lib/card_controller.rb
|
70
|
+
- lib/card_controller/errors.rb
|
71
|
+
- lib/card_controller/mark.rb
|
72
|
+
- lib/card_controller/response.rb
|
73
|
+
- lib/card_controller/rest.rb
|
69
74
|
- lib/decko.rb
|
70
75
|
- lib/decko/all.rb
|
71
76
|
- lib/decko/application.rb
|
@@ -131,7 +136,6 @@ files:
|
|
131
136
|
- lib/decko/generators/deck/templates/spec/javascripts/support/decko_jasmine.yml.erb
|
132
137
|
- lib/decko/generators/deck/templates/spec/spec_helper.rb
|
133
138
|
- lib/decko/mods_spec_helper.rb
|
134
|
-
- lib/decko/response.rb
|
135
139
|
- lib/decko/rest_spec_helper.rb
|
136
140
|
- lib/decko/script_decko_loader.rb
|
137
141
|
- lib/decko/swagger.rb
|
@@ -150,14 +154,10 @@ files:
|
|
150
154
|
- rails/assets/jasmine/500.html
|
151
155
|
- rails/assets/jasmine/card_form.html
|
152
156
|
- rails/assets/jquery.min.map
|
153
|
-
- rails/controllers/application_controller.rb
|
154
|
-
- rails/controllers/card_controller.rb
|
155
|
-
- rails/controllers/card_controller/errors.rb
|
156
157
|
- rails/engine-routes.rb
|
157
158
|
- script/autospec
|
158
159
|
- script/decko
|
159
160
|
- script/rails
|
160
|
-
- script/test_filter
|
161
161
|
homepage: https://decko.org
|
162
162
|
licenses:
|
163
163
|
- GPL-3.0
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
- !ruby/object:Gem::Version
|
183
183
|
version: '0'
|
184
184
|
requirements: []
|
185
|
-
rubygems_version: 3.1.
|
185
|
+
rubygems_version: 3.1.6
|
186
186
|
signing_key:
|
187
187
|
specification_version: 4
|
188
188
|
summary: structured wiki web platform
|
@@ -1,122 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
# Decko's only controller.
|
4
|
-
class CardController < ApplicationController
|
5
|
-
include ::Card::Env::Location
|
6
|
-
include ::Recaptcha::Verify
|
7
|
-
include ::Decko::Response
|
8
|
-
include Errors
|
9
|
-
|
10
|
-
layout nil
|
11
|
-
attr_reader :card
|
12
|
-
|
13
|
-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
14
|
-
# PUBLIC METHODS
|
15
|
-
|
16
|
-
def create
|
17
|
-
handle { card.save! }
|
18
|
-
end
|
19
|
-
|
20
|
-
def read
|
21
|
-
show
|
22
|
-
end
|
23
|
-
|
24
|
-
def update
|
25
|
-
card.new_card? ? create : handle { card.update! params[:card]&.to_unsafe_h }
|
26
|
-
end
|
27
|
-
|
28
|
-
def delete
|
29
|
-
handle { card.delete! }
|
30
|
-
end
|
31
|
-
|
32
|
-
# @deprecated
|
33
|
-
def asset
|
34
|
-
Rails.logger.info "Routing assets through Card. Recommend symlink from " \
|
35
|
-
'Deck to Card gem using "rake decko:update_assets_symlink"'
|
36
|
-
send_deprecated_asset
|
37
|
-
end
|
38
|
-
|
39
|
-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
40
|
-
# PRIVATE METHODS
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
#-------( FILTERS )
|
45
|
-
|
46
|
-
before_action :setup, except: [:asset]
|
47
|
-
before_action :authenticate, except: [:asset]
|
48
|
-
before_action :load_mark, only: [:read]
|
49
|
-
before_action :load_card, except: [:asset]
|
50
|
-
before_action :load_action, only: [:read]
|
51
|
-
before_action :refresh_card, only: [:create, :update, :delete]
|
52
|
-
|
53
|
-
def setup
|
54
|
-
Card::Machine.refresh_script_and_style unless params[:explicit_file]
|
55
|
-
Card::Cache.renew
|
56
|
-
Card::Env.reset controller: self
|
57
|
-
end
|
58
|
-
|
59
|
-
def authenticate
|
60
|
-
Card::Auth.signin_with token: params[:token], api_key: params[:api_key]
|
61
|
-
end
|
62
|
-
|
63
|
-
def load_mark
|
64
|
-
params[:mark] = interpret_mark params[:mark]
|
65
|
-
end
|
66
|
-
|
67
|
-
def load_card
|
68
|
-
@card = Card.controller_fetch params
|
69
|
-
raise Card::Error::NotFound unless card
|
70
|
-
record_as_main
|
71
|
-
end
|
72
|
-
|
73
|
-
def load_action
|
74
|
-
card.select_action_by_params params
|
75
|
-
card.content = card.last_draft_content if params[:edit_draft] && card.drafts.present?
|
76
|
-
end
|
77
|
-
|
78
|
-
# TODO: refactor this away this when new layout handling is ready
|
79
|
-
def record_as_main
|
80
|
-
Card::Env[:main_name] = params[:main] || card&.name || ""
|
81
|
-
end
|
82
|
-
|
83
|
-
def refresh_card
|
84
|
-
@card = card.refresh
|
85
|
-
end
|
86
|
-
|
87
|
-
# ----------( HELPER METHODS ) -------------
|
88
|
-
|
89
|
-
def handle
|
90
|
-
Card::Env.success card.name
|
91
|
-
yield ? cud_success : raise(Card::Error::UserError)
|
92
|
-
end
|
93
|
-
|
94
|
-
# successful create, update, or delete act
|
95
|
-
def cud_success
|
96
|
-
success = Card::Env.success.in_context card.name
|
97
|
-
if success.reload?
|
98
|
-
reload # instruct JSON to reload
|
99
|
-
else
|
100
|
-
redirect_cud_success success
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def show view=nil, status=200
|
105
|
-
card.action = :read
|
106
|
-
format = load_format status
|
107
|
-
result = render_page format, view
|
108
|
-
status = format.error_status || status
|
109
|
-
respond format, result, status
|
110
|
-
end
|
111
|
-
|
112
|
-
def render_page format, view
|
113
|
-
view ||= view_from_params
|
114
|
-
card.act do
|
115
|
-
format.page self, view, Card::Env.slot_opts
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def view_from_params
|
120
|
-
params[:view] || params[:v]
|
121
|
-
end
|
122
|
-
end
|
data/script/test_filter
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
#!/usr/local/bin/ruby
|
2
|
-
|
3
|
-
STDOUT.sync = true
|
4
|
-
errors_filename = "./log/err.out"
|
5
|
-
err_out = File.new(errors_filename, "a")
|
6
|
-
|
7
|
-
ARGF.each_line do |l|
|
8
|
-
error_section = false
|
9
|
-
if error_section
|
10
|
-
error_section = false if l =~ /^\s*$/
|
11
|
-
elsif l =~ /^\s*\d+\)\s*$/
|
12
|
-
error_section = true
|
13
|
-
elsif l =~ /^\*{40,}$/ ||
|
14
|
-
l =~ /^be removed from a future version of RSpec\.$/ ||
|
15
|
-
l =~ /^\* simple_matcher is deprecated\.$/ ||
|
16
|
-
l =~ /^\* please use Matcher DSL \(http\:\/\/rspec\.rubyforge\.org\/rspec\/1\.3.0\/classes\/Spec\/Matchers\.html\) instead\.$/
|
17
|
-
err_out << l if err_out
|
18
|
-
next
|
19
|
-
elsif l =~ /^([\.\[\]F\*\s]*)((\/| \(called from create_or_update_thumbnail|DEPRECATION WARN|The \{\{key\}\} interpolation syntax in|from \/).*\n?$)/
|
20
|
-
STDOUT << Regexp.last_match(1)
|
21
|
-
err_out << Regexp.last_match(2) if err_out
|
22
|
-
next
|
23
|
-
end
|
24
|
-
STDOUT << l
|
25
|
-
end
|