wagn 1.12.7 → 1.12.8

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.12.7
1
+ 1.12.8
@@ -19,10 +19,12 @@ class Account
19
19
  base.ok?(:create) && trait.ok?(:create)
20
20
  end
21
21
 
22
- # Authenticates a user by their login name and unencrypted password. Returns the user or nil.
22
+ # Authenticates a user by their login name and unencrypted password.
23
23
  def authenticate(email, password)
24
- u = User.find_by_email(email.strip.downcase)
25
- u && u.authenticated?(password.strip) ? u.card_id : nil
24
+ if u = User.find_by_email(email.strip.downcase) and
25
+ ( Wagn.config.no_authentication or u.authenticated? password.strip )
26
+ u.card_id
27
+ end
26
28
  end
27
29
 
28
30
  # Encrypts some data with the salt.
@@ -16,6 +16,7 @@ class RenamingForMenu < ActiveRecord::Migration
16
16
  '*editing' => '*edited',
17
17
  }
18
18
  renames.each do |oldname, newname|
19
+ puts "updating: #{oldname}"
19
20
  c = Card[oldname]
20
21
  c.update_referencers = true
21
22
  c.name = newname
@@ -206,17 +206,48 @@ class Card
206
206
  render view, args
207
207
  end
208
208
 
209
- def optional_render view, args, default_hidden=false
210
- test = default_hidden ? :show : :hide
211
- override = args[test] && args[test].split(/[\s\,]+/).member?( view.to_s )
212
- return nil if default_hidden ? !override : override
213
- render view, args
209
+ def optional_render view, args, default=:show
210
+ if show_view? view, args, default
211
+ view = args["optional_#{ canonicalize_view view }_view".to_sym] || view
212
+ render view, args
213
+ end
214
214
  end
215
215
 
216
- def _optional_render view, args, default_hidden=false
216
+ def _optional_render view, args, default=:show
217
217
  args[:allowed] = true
218
- optional_render view, args, default_hidden
218
+ optional_render view, args, default
219
+ end
220
+
221
+ def show_view? view, args, default=:show
222
+ view_key = canonicalize_view view
223
+ api_option = args["optional_#{ view_key }".to_sym]
224
+ case
225
+ # args remove option
226
+ when api_option == :always ; true
227
+ when api_option == :never ; false
228
+ # wagneer's choice
229
+ when show_views( args ).member?( view_key ) ; true
230
+ when hide_views( args ).member?( view_key ) ; false
231
+ # args override default
232
+ when api_option == :show ; true
233
+ when api_option == :hide ; false
234
+ # default
235
+ else ; default==:show
236
+ end
219
237
  end
238
+
239
+ def show_views args
240
+ parse_view_visibility args[:show]
241
+ end
242
+
243
+ def hide_views args
244
+ parse_view_visibility args[:hide]
245
+ end
246
+
247
+ def parse_view_visibility val
248
+ (val || '').split( /[\s\,]+/ ).map { |view| canonicalize_view view }
249
+ end
250
+
220
251
 
221
252
  def send_final_render_method view, *a
222
253
  a = [{}] if a.empty?
@@ -228,7 +259,11 @@ class Card
228
259
  unsupported_view view
229
260
  end
230
261
  rescue Exception=>e
231
- rescue_view e, view
262
+ if Rails.env.test?
263
+ raise e
264
+ else
265
+ rescue_view e, view
266
+ end
232
267
  end
233
268
 
234
269
  def rescue_view e, view
@@ -48,6 +48,8 @@ namespace :wagn do
48
48
 
49
49
  desc "migrate structure and cards"
50
50
  task :migrate =>:environment do
51
+ ENV['SCHEMA'] = "#{Wagn.gem_root}/db/schema.rb"
52
+
51
53
  stamp = ENV['STAMP_MIGRATIONS']
52
54
 
53
55
  puts 'migrating structure'
@@ -71,7 +73,8 @@ namespace :wagn do
71
73
  desc "migrate cards"
72
74
  task :cards => :environment do
73
75
  Wagn::Cache.reset_global
74
- ENV['WAGN_MIGRATION'] = true
76
+ ENV['SCHEMA'] = "#{Wagn.gem_root}/db/schema.rb"
77
+ ENV['WAGN_MIGRATION'] = 'true'
75
78
  Card # this is needed in production mode to insure core db structures are loaded before schema_mode is set
76
79
 
77
80
  paths = ActiveRecord::Migrator.migrations_paths = Wagn::MigrationHelper.card_migration_paths
@@ -84,7 +87,8 @@ namespace :wagn do
84
87
 
85
88
  desc 'write the version to a file (not usually called directly)' #maybe we should move this to a method?
86
89
  task :stamp, :suffix do |t, args|
87
- ENV['WAGN_MIGRATION'] = true
90
+ ENV['WAGN_MIGRATION'] = 'true'
91
+ ENV['SCHEMA'] = "#{Wagn.gem_root}/db/schema.rb"
88
92
 
89
93
  stamp_file = Wagn::Version.schema_stamp_path args[:suffix]
90
94
  Wagn::MigrationHelper.schema_mode args[:suffix ] do
@@ -37,6 +37,7 @@ module Wagn
37
37
  config.filter_parameters += [:password]
38
38
  config.read_only = !!ENV['WAGN_READ_ONLY']
39
39
  config.allow_inline_styles = false
40
+ config.no_authentication = false
40
41
  config.files_web_path = 'files'
41
42
  config.cache_store = :file_store, 'tmp/cache'
42
43
 
@@ -70,6 +71,7 @@ module Wagn
70
71
  add_wagn_path paths, "config/routes", :with => "config/routes.rb"
71
72
  add_wagn_path paths, "db"
72
73
  add_wagn_path paths, "db/migrate"
74
+ add_wagn_path paths, "db/migrate_cards"
73
75
  add_wagn_path paths, "db/seeds", :with => "db/seeds.rb"
74
76
  add_wagn_path paths, 'gem-mods', :with => 'mods'
75
77
 
@@ -91,6 +93,13 @@ module Wagn
91
93
  paths[path] = Rails::Paths::Path.new(paths, wagn_path, with, options)
92
94
  end
93
95
 
96
+ def load_tasks(app=self)
97
+ super
98
+ unless approot_is_gemroot?
99
+ Rake::Task["db:schema:dump"].clear
100
+ end
101
+ self
102
+ end
94
103
  end
95
104
  end
96
105
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Wagn::MigrationHelper
4
4
  def self.card_migration_paths
5
- Wagn.paths.add 'db/migrate_cards'
6
5
  Wagn.paths['db/migrate_cards'].to_a
7
6
  end
8
7
 
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
- require 'wagn'
2
+ require File.expand_path( '../../wagn', __FILE__ )
3
3
 
4
4
  module Wagn
5
5
  module Version
@@ -97,12 +97,12 @@ class Card::HtmlFormat < Card::Format
97
97
  div = %{<div id="#{card.cardname.url_key}" data-card-id="#{card.id}" data-card-name="#{h card.name}" style="#{h args[:style]}" class="#{classes*' '}" } +
98
98
  %{data-slot='#{html_escape_except_quotes slot_options( args )}'>#{yield}</div>}
99
99
 
100
- if args[:no_wrap_comment]
101
- div
102
- else
100
+ if params[:debug] == 'slot' && !tagged(view, :no_wrap_comments )
103
101
  name = h card.name
104
102
  space = ' ' * @depth
105
103
  %{<!--\n\n#{ space }BEGIN SLOT: #{ name }\n\n-->#{ div }<!--\n\n#{space}END SLOT: #{ name }\n\n-->}
104
+ else
105
+ div
106
106
  end
107
107
  end
108
108
 
@@ -129,7 +129,7 @@ event :permit_codename, :before=>:approve, :on=>:update, :changed=>:codename do
129
129
  end
130
130
 
131
131
  event :validate_unique_codename, :after=>:permit_codename do
132
- if !codename.empty? and errors.empty? and Card.find_by_codename(codename).present?
132
+ if codename.present? and errors.empty? and Card.find_by_codename(codename).present?
133
133
  errors.add :codename, "codename #{codename} already in use"
134
134
  end
135
135
  end
@@ -133,7 +133,7 @@ format :html do
133
133
 
134
134
 
135
135
  view :signin, :tags=>:unknown_ok, :perms=>:none do |args|
136
- frame_args = args.merge :title=>'Sign In', :show_help=>true, :hide_menu=>true
136
+ frame_args = args.merge :title=>'Sign In', :show_help=>true, :optional_menu=>:never
137
137
  signin_core = wrap_frame :signin, frame_args do
138
138
  form_tag wagn_path('account/signin') do
139
139
  %{
@@ -156,7 +156,7 @@ format :html do
156
156
 
157
157
 
158
158
  view :forgot_password, :perms=>:none do |args|
159
- frame_args = args.merge :title=>'Forgot Password', :show_help=>true, :hide_menu=>true
159
+ frame_args = args.merge :title=>'Forgot Password', :show_help=>true, :optional_menu=>:never
160
160
  wrap_frame :forgot_password, frame_args do
161
161
  form_tag wagn_path('account/forgot_password') do
162
162
  %{
@@ -3,7 +3,7 @@ view :setup, :tags=>:unknown_ok do |args|
3
3
  frame_args = {
4
4
  :title=>'Welcome, Wagneer!',
5
5
  :show_help=>true,
6
- :hide_menu=>true,
6
+ :optional_menu=>:never,
7
7
  :help_text=>'To get started, set up an account.'
8
8
  }
9
9
 
@@ -11,6 +11,7 @@ view :name, :perms=>:none do |args| card.name end
11
11
  view :codename, :perms=>:none do |args| card.codename.to_s end
12
12
  view :key, :perms=>:none do |args| card.key end
13
13
  view :id, :perms=>:none do |args| card.id end
14
+ view :type, :perms=>:none do |args| card.type_name end
14
15
  view :linkname, :perms=>:none do |args| card.cardname.url_key end
15
16
  view :url, :perms=>:none do |args| wagn_url _render_linkname end
16
17
 
@@ -1,7 +1,7 @@
1
1
  format :html do
2
2
 
3
3
  watch_perms = lambda { |r| Account.logged_in? && !r.card.new_card? }
4
- view :watch, :tags=>:unknown_ok, :denial=>:blank, :perms=>watch_perms do |args|
4
+ view :watch, :tags=>[:unknown_ok, :no_wrap_comments], :denial=>:blank, :perms=>watch_perms do |args|
5
5
 
6
6
  wrap :watch, args do
7
7
  if card.watching_type?
@@ -23,7 +23,7 @@ format :html do
23
23
 
24
24
  view :content do |args|
25
25
  wrap :content, args.merge(:slot_class=>'card-content') do
26
- menu = optional_render :menu, args, default_hidden=true
26
+ menu = optional_render :menu, args, :hide
27
27
  %{#{ menu }#{ _render_core args }}
28
28
  end
29
29
  end
@@ -31,7 +31,7 @@ format :html do
31
31
  view :titled, :tags=>:comment do |args|
32
32
  wrap :titled, args do
33
33
  %{
34
- #{ _render_header args.merge( :menu_default_hidden=>true ) }
34
+ #{ _render_header args.merge( :optional_menu=>:hide ) }
35
35
  #{ wrap_body( :content=>true ) { _render_core args } }
36
36
  #{ optional_render :comment_box, args }
37
37
  }
@@ -54,7 +54,7 @@ format :html do
54
54
 
55
55
  view :title do |args|
56
56
  title = fancy_title args[:title]
57
- title = _optional_render( :title_link, args.merge( :title_ready=>title ), default_hidden=true ) || title
57
+ title = _optional_render( :title_link, args.merge( :title_ready=>title ), :hide ) || title
58
58
  add_name_context
59
59
  title
60
60
  end
@@ -64,26 +64,30 @@ format :html do
64
64
  end
65
65
 
66
66
  view :open, :tags=>:comment do |args|
67
- args[:toggler] = link_to '', path( :view=>:closed ),
68
- :remote => true,
69
- :title => "close #{card.name}",
70
- :class => "close-icon ui-icon ui-icon-circle-triangle-s toggler slotter nodblclick"
71
-
72
67
  wrap_frame :open, args.merge(:content=>true) do
73
- %{#{ _render_open_content args }#{ optional_render :comment_box, args }}
68
+ %{
69
+ #{ _render_open_content args }
70
+ #{ optional_render :comment_box, args }
71
+ }
74
72
  end
75
73
  end
76
74
 
75
+ view :toggle do |args|
76
+ verb, adjective, direction = args[:toggle] == :close ? %w{ close closed s } : %w{ open open e }
77
+
78
+ link_to '', path( :view=>adjective ),
79
+ :remote => true,
80
+ :title => "#{verb} #{card.name}",
81
+ :class => "#{verb}-icon ui-icon ui-icon-circle-triangle-#{direction} toggler slotter nodblclick"
82
+ end
83
+
84
+
77
85
  view :header do |args|
78
86
  %{
79
87
  <h1 class="card-header">
80
- #{ args.delete :toggler }
88
+ #{ _optional_render :toggle, args, :hide }
81
89
  #{ _render_title args }
82
- #{
83
- args[:custom_menu] or unless args[:hide_menu] # developer config
84
- _optional_render :menu, args, (args[:menu_default_hidden] || false) # wagneer config
85
- end
86
- }
90
+ #{ _optional_render :menu, args }
87
91
  </h1>
88
92
  }
89
93
  end
@@ -106,7 +110,7 @@ format :html do
106
110
  @menu_vars.merge!({
107
111
  :edit => card.ok?(:update),
108
112
  :account => card.account && card.update_account_ok?,
109
- :watch => Account.logged_in? && render_watch(args.merge :no_wrap_comment=>true),
113
+ :watch => Account.logged_in? && render_watch,
110
114
  :creator => card.creator.name,
111
115
  :updater => card.updater.name,
112
116
  :delete => card.ok?(:delete) && link_to( 'delete', path(:action=>:delete),
@@ -131,13 +135,7 @@ format :html do
131
135
  end
132
136
 
133
137
  view :closed do |args|
134
- args[:toggler] = link_to '', path( :view=>:open ),
135
- :remote => true,
136
- :title => "open #{card.name}",
137
- :class => "open-icon ui-icon ui-icon-circle-triangle-e toggler slotter nodblclick"
138
-
139
- wrap_frame :closed, args.merge(:content=>true, :body_class=>'closed-content') do
140
- # wrap :closed, args do
138
+ wrap_frame :closed, args.merge(:content=>true, :body_class=>'closed-content', :toggle=>:close ) do
141
139
  _render_closed_content args
142
140
  end
143
141
  end
@@ -377,8 +375,8 @@ format :html do
377
375
  view :change do |args|
378
376
  wrap :change, args do
379
377
  %{
380
- #{link_to_page card.name, nil, :class=>'change-card'}
381
- #{ _optional_render :menu, args, default_hidden=true }
378
+ #{ link_to_page card.name, nil, :class=>'change-card' }
379
+ #{ _optional_render :menu, args, :hide }
382
380
  #{
383
381
  if rev = card.current_revision and !rev.new_record?
384
382
  # this check should be unnecessary once we fix search result bug
@@ -417,7 +415,7 @@ format :html do
417
415
  </div>}
418
416
  end
419
417
 
420
- wrap_frame :notfound, args.merge(:title=>'Not Found', :hide_menu=>'true') do
418
+ wrap_frame :notfound, args.merge(:title=>'Not Found', :optional_menu=>:never) do
421
419
  %{
422
420
  <h2>Could not find #{card.name.present? ? "<em>#{card.name}</em>" : 'that'}.</h2>
423
421
  #{sign_in_or_up_links}
@@ -3,7 +3,7 @@
3
3
  format :html do
4
4
  view :new do |args|
5
5
  #FIXME - make more use of standard new view
6
- frame_args = args.merge :title=>'Sign Up', :show_help=>true #, :hide_menu=>true
6
+ frame_args = args.merge :title=>'Sign Up', :show_help=>true #, :optional_menu=>:never
7
7
  frame_args[:help_text] = case
8
8
  when card.rule_card( :add_help, :fallback=>:help ) ; nil
9
9
  when Account.create_ok? ; 'Send us the following, and we\'ll send you a password.'
@@ -30,7 +30,7 @@ format :html do
30
30
 
31
31
 
32
32
  view :edit do |args|
33
- frame_args = { :title=>'Invite', :show_help=>true, :hide_menu=>true,
33
+ frame_args = { :title=>'Invite', :show_help=>true, :optional_menu=>:never,
34
34
  :help_text=>"Accept account request from: #{link_to_page card.name}"
35
35
  }
36
36
 
@@ -38,14 +38,17 @@ format :html do
38
38
  end
39
39
  end
40
40
 
41
+ view :template_closer do |args|
42
+ link_to_view '', :template_link, :class=>'slotter ui-icon ui-icon-closethick template-editor-close'
43
+ end
44
+
41
45
  view :template_editor do |args|
42
- custom_menu = link_to_view '', :template_link, :class=>'slotter ui-icon ui-icon-closethick template-editor-close'
43
46
  wrap :template_editor, args do
44
47
  %{
45
48
  <div class="template-editor-left">{{</div>
46
49
  <div class="template-editor-main">
47
50
  #{
48
- wrap_frame :template_editor, :no_slot=>true, :title=>card.label, :custom_menu=>custom_menu do
51
+ wrap_frame :template_editor, :no_slot=>true, :title=>card.label, :optional_menu_view=>:template_closer do
49
52
  _render_core args.merge(:unlabeled=>true)
50
53
  end
51
54
  }
@@ -7,13 +7,13 @@ attr_accessor :email
7
7
  format :html do
8
8
  #FIXME - should perms check permission to create account?
9
9
  view :new do |args|
10
- wrap_frame :invite, args.merge( :title=>'Invite', :show_help=>true, :hide_menu=>true ) do
10
+ wrap_frame :invite, args.merge( :title=>'Invite', :show_help=>true, :optional_menu=>:never ) do
11
11
  card_form :create do |f|
12
12
  @form = f
13
13
  %{
14
14
  #{ f.hidden_field :type_id }
15
15
  #{ _render_name_editor :help=>'usually first and last name' }
16
- #{ fieldset :email, text_field( :account, :email, :size=>60 ) }
16
+ #{ fieldset :email, text_field( 'card[account_args]', :email, :size=>60 ) }
17
17
  #{ _render_invitation_field }
18
18
  }
19
19
  end
File without changes
@@ -2,7 +2,7 @@
2
2
  require 'wagn/spec_helper'
3
3
 
4
4
  describe Card::Format do
5
-
5
+ =begin
6
6
  describe :render do
7
7
  it "should ignore underscores in view names" do
8
8
  render_card(:not_found).should == render_card('not found')
@@ -170,4 +170,35 @@ describe Card::Format do
170
170
  end
171
171
  end
172
172
 
173
+ =end
174
+ describe '#show?' do
175
+ before :all do
176
+ @format = described_class.new Card.new
177
+ end
178
+
179
+ it "should respect defaults" do
180
+ @format.show_view?( :menu, {}, :show ).should be_true
181
+ @format.show_view?( :menu, {}, :hide ).should be_false
182
+ @format.show_view?( :menu, {} ).should be_true
183
+ end
184
+
185
+ it "should respect developer default overrides" do
186
+ @format.show_view?( :menu, { :optional_menu=>:show }, :hide ).should be_true
187
+ @format.show_view?( :menu, { :optional_menu=>:hide }, :show ).should be_false
188
+ @format.show_view?( :menu, { :optional_menu=>:hide } ).should be_false
189
+ end
190
+
191
+ it "should handle args from inclusions" do
192
+ @format.show_view?( :menu, { :show=>'menu' }, :hide ).should be_true
193
+ @format.show_view?( :menu, { :hide=>'menu, paging' }, :show ).should be_false
194
+ @format.show_view?( :menu, :show=>'menu', :optional_menu=>:hide ).should be_true
195
+ end
196
+
197
+ it "should handle hard developer overrides" do
198
+ @format.show_view?( :menu, :optional_menu=>:always, :hide=>'menu' ).should be_true
199
+ @format.show_view?( :menu, :optional_menu=>:never, :show=>'menu' ).should be_false
200
+ end
201
+
202
+ end
203
+
173
204
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wagn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.7
4
+ version: 1.12.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-01-30 00:00:00.000000000 Z
14
+ date: 2014-02-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -949,7 +949,7 @@ files:
949
949
  - script/autospec
950
950
  - script/rails
951
951
  - script/test_filter
952
- - script/wagn.rb
952
+ - script/wagn
953
953
  - spec/controllers/account_controller_spec.rb
954
954
  - spec/controllers/admin_controller_spec.rb
955
955
  - spec/controllers/captcha_spec.rb