wagn 1.12.9 → 1.12.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +15 -0
  2. data/Gemfile +10 -22
  3. data/VERSION +1 -1
  4. data/app/assets/javascripts/wagn.js.coffee +3 -3
  5. data/app/controllers/account_controller.rb +23 -29
  6. data/app/controllers/admin_controller.rb +14 -20
  7. data/app/controllers/card_controller.rb +1 -39
  8. data/app/controllers/wagn_controller.rb +46 -3
  9. data/app/mailers/mailer.rb +11 -10
  10. data/config/environments/development.rb +3 -0
  11. data/{app/models → lib}/card.rb +0 -0
  12. data/lib/card/content.rb +2 -2
  13. data/lib/card/format.rb +26 -5
  14. data/{app/models → lib}/card/reference.rb +0 -0
  15. data/{app/models → lib}/card/revision.rb +0 -0
  16. data/lib/generators/wagn/templates/Gemfile +2 -0
  17. data/lib/tasks/wagn.rake +6 -7
  18. data/lib/wagn/all.rb +11 -2
  19. data/lib/wagn/application.rb +1 -0
  20. data/mods/core/formats/html_format.rb +74 -29
  21. data/mods/core/sets/all/content.rb +5 -1
  22. data/mods/core/sets/all/permissions.rb +11 -4
  23. data/mods/core/sets/all/trash.rb +6 -1
  24. data/mods/standard/chunks/include.rb +3 -5
  25. data/mods/standard/lib/stylesheets/functional.scss +2 -0
  26. data/mods/standard/lib/stylesheets/standard.scss +1 -1
  27. data/mods/standard/sets/all/account.rb +66 -53
  28. data/mods/standard/sets/all/admin.rb +16 -16
  29. data/mods/standard/sets/all/all_css.rb +2 -2
  30. data/mods/standard/sets/all/base.rb +8 -3
  31. data/mods/standard/sets/all/follow.rb +2 -2
  32. data/mods/standard/sets/all/history.rb +1 -1
  33. data/mods/standard/sets/all/json.rb +3 -2
  34. data/mods/standard/sets/all/kml.rb +3 -2
  35. data/mods/standard/sets/all/rich_html.rb +220 -169
  36. data/mods/standard/sets/all/rss.rb +2 -2
  37. data/mods/standard/sets/right/structure.rb +5 -4
  38. data/mods/standard/sets/self/head.rb +2 -2
  39. data/mods/standard/sets/type/account_request.rb +20 -27
  40. data/mods/standard/sets/type/cardtype.rb +15 -2
  41. data/mods/standard/sets/type/layout_type.rb +6 -4
  42. data/mods/standard/sets/type/search_type.rb +1 -1
  43. data/mods/standard/sets/type/set.rb +6 -3
  44. data/mods/standard/sets/type/user.rb +13 -10
  45. data/public/assets/{application-7f1664ac8e65db8af0bfa6539e23c7df.js → application-af2bc486eb3db1c02c4dcd0e23ca25fc.js} +1 -1
  46. data/public/assets/{application-7f1664ac8e65db8af0bfa6539e23c7df.js.gz → application-af2bc486eb3db1c02c4dcd0e23ca25fc.js.gz} +0 -0
  47. data/public/assets/application.js +1 -1
  48. data/public/assets/application.js.gz +0 -0
  49. data/public/assets/html5shiv-printshiv-ad36fc7219f4aeaa275f9a7fe2383413.js.gz +0 -0
  50. data/public/assets/html5shiv-printshiv.js.gz +0 -0
  51. data/public/assets/manifest.yml +2 -2
  52. data/public/assets/tinymce-22b5a139d9ff7df7643afae9ce205508.js.gz +0 -0
  53. data/public/assets/tinymce.js.gz +0 -0
  54. data/spec/lib/card/codename_spec.rb +1 -0
  55. data/spec/mods/core/sets/all/permissions_spec.rb +25 -0
  56. data/spec/mods/core/sets/all/trash_spec.rb +16 -0
  57. data/spec/mods/standard/chunks/include_spec.rb +5 -0
  58. data/spec/mods/standard/sets/all/json_spec.rb +6 -6
  59. data/spec/mods/standard/sets/all/rich_html_spec.rb +36 -0
  60. data/spec/mods/standard/sets/right/structure_spec.rb +8 -2
  61. data/wagn.gemspec +2 -2
  62. metadata +14 -38
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTU0MTc4NzBhYWNkMWM0NDgwZjUwN2Y1M2RjOTkwY2MzZGY3MGJjMQ==
5
+ data.tar.gz: !binary |-
6
+ ZjMxYmFmMTAxMzI3NzE0MWM5MjAyMTU2ZjU3MTM2ZThmMDY4N2EzOQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YjU1N2ZkMjM2ZmZlNDhkODkwNDBjMWY0OTVkMDVlYmIxNDBmZDhkNWY5MzYy
10
+ YmNiNzc2NDE2ZmVhZDJkMGIxYzQ5ZTJhZTgwMTZjOTg4MmFlYjI2NTQ2ZTk0
11
+ MDFiMTU0YTQ1NTJiNzBlMGY4MTMwYmM5ZTIwOWFhYmEzODQxMDU=
12
+ data.tar.gz: !binary |-
13
+ ZDRkMDdkNjU3ZjZkNGIzMTEyZDU1OTA5ZWRhNDQ4NWVlNTMwYjM4ODAwODc5
14
+ OTgxN2M2Y2U0MTYwMGFjZWNiMzNiODRjMTE1MzA1MzlmMDJjNzhkNzMwYjZl
15
+ NmViMmMxZDRlYmU5OThlOWY5OWRmNWE5NzVkZjgwN2NkODc1MGM=
data/Gemfile CHANGED
@@ -5,21 +5,21 @@ gemspec
5
5
 
6
6
  gem 'wagn', :path=>File.expand_path( '../', __FILE__ )
7
7
 
8
- gem 'dalli', :group => :memcache
8
+ gem 'wagn-dev', :path=>File.expand_path( '../../wagn-dev', __FILE__ )
9
9
 
10
10
  group :mysql do
11
11
  gem "mysql2", "~> 0.3"
12
12
  end
13
13
 
14
- group :postgres do
15
- gem 'pg', '~>0.12.2'
16
- # if using 1.8.7 or ree and having no luck with the above, try:
17
- # gem 'postgres', '~>0.7.9.2008.01.28'
14
+
15
+
16
+ group :profile do
17
+ gem 'ruby-prof', '~>0.12.1' # profiling
18
+ #gem 'test-unit' #was causing errors after cucumber runs.
18
19
  end
19
- #gem 'sqlite3-ruby', :require => 'sqlite3', :group=>'sqlite'
20
20
 
21
- # These should only be needed if you're developing new JS / CSS. It's all pre-compiled for production
22
- group :assets do
21
+ group :test do
22
+
23
23
  gem 'sass-rails', "~> 3.1" # pretty code; compiles to CSS
24
24
  gem 'coffee-rails', "~> 3.1" # pretty code; compiles to JS
25
25
  gem 'uglifier' # makes pretty code ugly again. compresses js/css for fast loading
@@ -31,22 +31,10 @@ group :assets do
31
31
 
32
32
  # execjs is necessary for developing coffeescript. mac users have execjs built-in; don't need this one
33
33
  gem 'therubyrhino', :platform=>:ruby # :ruby is MRI rubies, so if you use a mac ruby ...
34
- end
35
-
36
-
37
-
38
- group :profile do
39
- gem 'ruby-prof', '~>0.12.1' # profiling
40
- #gem 'test-unit' #was causing errors after cucumber runs.
41
- end
42
-
43
- group :test, :development do
34
+
44
35
  gem 'rails-dev-tweaks', '~> 0.6' # dramatic speeds up asset loading, among other tweaks
45
36
  gem 'rspec-rails', "~> 2.6" # behavior-driven-development suite
46
- # gem 'jasmine-rails'
47
- end
48
-
49
- group :test do
37
+
50
38
  gem 'cucumber-rails', '~> 1.3', :require=>false # feature-driven-development suite
51
39
  gem 'capybara', '~> 2.2.1' # note, selectors were breaking when we used 2.0.1
52
40
  gem 'selenium-webdriver', '~> 2.39'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.12.9
1
+ 1.12.10
@@ -187,10 +187,10 @@ $(window).ready ->
187
187
  $(this).closest('form').submit()
188
188
 
189
189
  $('body').on 'click', '.renamer-updater', ->
190
- $(this).closest('form').find('.update_referencers').val 'true'
190
+ $(this).closest('form').find('#card_update_referencers').val 'true'
191
191
 
192
- $('body').on 'submit', '.card-name-form', ->
193
- confirmer = $(this).find '.confirm-rename'
192
+ $('body').on 'submit', '.edit_name-view .card-form', ->
193
+ confirmer = $(this).find '.confirm_rename-view'
194
194
  if confirmer.is ':hidden'
195
195
  if $(this).find('#referers').val() > 0
196
196
  $(this).find('.renamer-updater').show()
@@ -4,9 +4,9 @@ class AccountController < WagnController
4
4
  def signin
5
5
  @card = Card.new
6
6
  if params[:login]
7
- password_authentication params[:login], params[:password]
7
+ handle { password_authentication params[:login], params[:password] }
8
8
  else
9
- show :signin
9
+ show :signin_and_forgot_password
10
10
  end
11
11
  end
12
12
 
@@ -18,23 +18,8 @@ class AccountController < WagnController
18
18
 
19
19
  def forgot_password
20
20
  @card = Card.new
21
- if request.post? and email = params[:email]
22
- @account = Account[ email.downcase ]
23
- case
24
- when @account.nil?
25
- flash[:notice] = "Unrecognized email."
26
- show :signin, 404
27
- when !@account.active?
28
- flash[:notice] = "That account is not active."
29
- show :signin, 403
30
- else
31
- @account.send_account_info(
32
- :subject => "Password Reset",
33
- :message => "You have been given a new temporary password. Please update your password once you've signed in."
34
- )
35
- flash[:notice] = "Check your email for your new temporary password"
36
- redirect_to previous_location
37
- end
21
+ if email = params[:email]
22
+ handle { reset_password Account[ email.downcase ] }
38
23
  else
39
24
  show :forgot_password
40
25
  end
@@ -42,26 +27,35 @@ class AccountController < WagnController
42
27
 
43
28
  protected
44
29
 
30
+ def reset_password account
31
+ error = case
32
+ when account.nil? ; "Unrecognized email."
33
+ when !account.active? ; "That account is not active."
34
+ end
35
+
36
+ if error
37
+ @card.errors.add :account, error
38
+ false
39
+ else
40
+ account.send_account_info(
41
+ :subject => "Password Reset",
42
+ :message => "You have been given a new temporary password. Please update your password once you've signed in."
43
+ )
44
+ end
45
+ end
46
+
45
47
  def password_authentication(login, password)
46
48
  if self.current_account_id = Account.authenticate( params[:login], params[:password] )
47
49
  flash[:notice] = "Successfully signed in"
48
- #warn Rails.logger.info("to prev #{previous_location}")
49
- redirect_to previous_location
50
50
  else
51
51
  usr=Account[ params[:login].strip.downcase ]
52
- failed_login(
53
- case
52
+ @card.errors.add :signin, case
54
53
  when usr.nil? ; "Unrecognized email."
55
54
  when usr.blocked? ; "Sorry, that account is blocked."
56
55
  else ; "Wrong password"
57
56
  end
58
- )
57
+ false
59
58
  end
60
59
  end
61
60
 
62
- def failed_login(message)
63
- flash[:notice] = "Oops: #{message}"
64
- show :signin, 403
65
- end
66
-
67
61
  end
@@ -4,30 +4,29 @@ class AdminController < CardController
4
4
 
5
5
  def setup
6
6
  raise Wagn::Oops, "Already setup" unless Account.no_logins?
7
- Wagn::Env[:recaptcha_on] = false
8
7
  if request.post?
9
- Account.as_bot do
10
- @card = Card.create params[:card]
11
- set_default_request_recipient
12
-
13
- if @card.errors.empty?
14
- roles_card = card.fetch :trait=>:roles, :new=>{}
15
- roles_card.content = "[[#{Card[Card::AdminID].name}]]"
16
- roles_card.save
17
- self.current_account_id = @card.id
18
- Card.cache.delete 'no_logins'
8
+ Wagn::Env[:recaptcha_on] = false
9
+ handle do
10
+ Account.as_bot do
11
+ @card = Card.create params[:card].merge( :cards=>{
12
+ '+*roles' => { :content=>"[[#{Card[:administrator].name}]]" },
13
+ '*request+*to' => { :content=>params[:card][:account_args][:email] }
14
+ })
15
+
16
+ @card.errors.empty? and
17
+ self.current_account_id = @card.id and
18
+ Card.cache.delete 'no_logins' and
19
19
  flash[:notice] = "You're good to go!"
20
- redirect_to Card.path_setting('/')
21
- else
22
- show :setup
23
20
  end
24
21
  end
25
22
  else
26
- @card = Card.new( params[:card] || {} ) #should prolly skip default
23
+ @card = Card.new #should prolly skip default
27
24
  show :setup
28
25
  end
29
26
  end
30
27
 
28
+
29
+
31
30
  def clear_cache
32
31
  Wagn::Cache.reset_global
33
32
  render_text 'Cache cleared'
@@ -122,9 +121,4 @@ class AdminController < CardController
122
121
  raise Wagn::PermissionDenied unless Account.always_ok?
123
122
  end
124
123
 
125
- def set_default_request_recipient
126
- to_card = Card.fetch '*request+*to', :new=>{}
127
- to_card.content=params[:card][:account_args][:email]
128
- to_card.save
129
- end
130
124
  end
@@ -53,6 +53,7 @@ class CardController < WagnController
53
53
  watchers.send((params[:toggle]=='on' ? :add_item : :drop_item), myname)
54
54
  watchers.save!
55
55
  ajax? ? show(:watch) : read
56
+
56
57
  end
57
58
 
58
59
 
@@ -60,9 +61,6 @@ class CardController < WagnController
60
61
 
61
62
  private
62
63
 
63
- def handle
64
- yield ? success : render_errors
65
- end
66
64
 
67
65
  #-------( FILTERS )
68
66
 
@@ -123,41 +121,5 @@ class CardController < WagnController
123
121
 
124
122
  #------- REDIRECTION
125
123
 
126
- def success
127
- redirect, new_params = !ajax?, {}
128
-
129
- target = case params[:success]
130
- when Hash
131
- new_params = params[:success]
132
- redirect ||= !!(new_params.delete :redirect)
133
- new_params.delete :id
134
- when /^REDIRECT:\s*(.+)/
135
- redirect=true
136
- $1
137
- when nil ; '_self'
138
- else ; params[:success]
139
- end
140
-
141
- target = case target
142
- when '*previous' ; previous_location #could do as *previous
143
- when '_self ' ; card #could do as _self
144
- when /^(http|\/)/ ; target
145
- when /^TEXT:\s*(.+)/ ; $1
146
- else ; Card.fetch target.to_name.to_absolute(card.cardname), :new=>{}
147
- end
148
-
149
- case
150
- when redirect
151
- target = page_path target.cardname, new_params if Card === target
152
- wagn_redirect target
153
- when String===target
154
- render :text => target
155
- else
156
- @card = target
157
- self.params = self.params.merge new_params #need tests. insure we get slot, main...
158
- show
159
- end
160
- end
161
-
162
124
  end
163
125
 
@@ -47,6 +47,47 @@ class WagnController < ActionController::Base
47
47
  end
48
48
  end
49
49
 
50
+ def handle
51
+ yield ? success : render_errors
52
+ end
53
+
54
+
55
+ def success
56
+ redirect, new_params = !ajax?, {}
57
+
58
+ target = case params[:success]
59
+ when Hash
60
+ new_params = params[:success]
61
+ redirect ||= !!(new_params.delete :redirect)
62
+ new_params.delete :id
63
+ when /^REDIRECT:\s*(.+)/
64
+ redirect=true
65
+ $1
66
+ when nil ; '_self'
67
+ else ; params[:success]
68
+ end
69
+
70
+ target = case target
71
+ when '*previous' ; previous_location #could do as *previous
72
+ when '_self ' ; card #could do as _self
73
+ when /^(http|\/)/ ; target
74
+ when /^TEXT:\s*(.+)/ ; $1
75
+ else ; Card.fetch target.to_name.to_absolute(card.cardname), :new=>{}
76
+ end
77
+
78
+ case
79
+ when redirect
80
+ target = page_path target.cardname, new_params if Card === target
81
+ wagn_redirect target
82
+ when String===target
83
+ render :text => target
84
+ else
85
+ @card = target
86
+ self.params = self.params.merge new_params #need tests. insure we get slot, main...
87
+ show
88
+ end
89
+ end
90
+
50
91
 
51
92
  def render_errors
52
93
  #fixme - should prioritize certain error classes
@@ -68,7 +109,7 @@ class WagnController < ActionController::Base
68
109
  opts[:view] = view || params[:view]
69
110
 
70
111
  formatter = Card::Format.new card, :controller=>self, :format=>format, :inclusion_opts=>opts[:items]
71
- result = formatter.render_show opts
112
+ result = formatter.show opts
72
113
  status = formatter.error_status || status
73
114
 
74
115
  if format==:file && status==200
@@ -83,7 +124,6 @@ class WagnController < ActionController::Base
83
124
  end
84
125
 
85
126
 
86
-
87
127
  rescue_from Exception do |exception|
88
128
  Rails.logger.info "exception = #{exception.class}: #{exception.message}"
89
129
 
@@ -109,7 +149,7 @@ class WagnController < ActionController::Base
109
149
 
110
150
  if ActiveRecord::RecordInvalid === exception
111
151
  :errors
112
- elsif ENV['WAGN_MIGRATION'] or Rails.logger.level == 0 # could also just check non-production mode...
152
+ elsif Rails.logger.level == 0 # could also just check non-production mode...
113
153
  raise exception
114
154
  else
115
155
  :server_error
@@ -118,6 +158,9 @@ class WagnController < ActionController::Base
118
158
 
119
159
  show view
120
160
  end
161
+
162
+
163
+
121
164
  end
122
165
 
123
166
 
@@ -89,16 +89,17 @@ class Mailer < ActionMailer::Base
89
89
  private
90
90
 
91
91
  def mail_from args, from
92
- #puts "unprocessed mail args: #{args}"
93
- unless ENV['WAGN_MIGRATION']
94
- from_name, from_email = (from =~ /(.*)\<(.*)>/) ? [$1.strip, $2] : [nil, from]
95
- if default_from=@@defaults[:from]
96
- args[:from] = !from_email ? default_from : "#{from_name || from_email} <#{default_from}>"
97
- args[:reply_to] ||= from
98
- else
99
- args[:from] = from
100
- end
101
- #puts "mail args: #{args}"
92
+ from_name, from_email = (from =~ /(.*)\<(.*)>/) ? [$1.strip, $2] : [nil, from]
93
+ if default_from=@@defaults[:from]
94
+ args[:from] = !from_email ? default_from : "#{from_name || from_email} <#{default_from}>"
95
+ args[:reply_to] ||= from
96
+ else
97
+ args[:from] = from
98
+ end
99
+
100
+ if config.send_emails == false
101
+ Rails.logger.debug "Email is off; NOT mailing the following: #{args}"
102
+ else
102
103
  mail args
103
104
  end
104
105
  end
@@ -46,6 +46,7 @@ Wagn.application.class.configure do
46
46
  # Log the query plan for queries taking more than this (works
47
47
  # with SQLite, MySQL, and PostgreSQL)
48
48
  config.active_record.auto_explain_threshold_in_seconds = 0.5
49
+
49
50
 
50
51
  # if File.exists?(File.join(Rails.root,'tmp', 'debug.txt'))
51
52
  # require 'ruby-debug'
@@ -53,6 +54,8 @@ Wagn.application.class.configure do
53
54
  # Debugger.start_remote
54
55
  # File.delete(File.join(Rails.root,'tmp', 'debug.txt'))
55
56
  # end
57
+
58
+ config.send_emails = false
56
59
  end
57
60
 
58
61
 
File without changes
@@ -131,9 +131,9 @@ class Card
131
131
  ALLOWED_TAGS.each_key {|k|
132
132
  ALLOWED_TAGS[k] << 'class'
133
133
  ALLOWED_TAGS[k] << 'style' if Wagn.config.allow_inline_styles
134
- ALLOWED_TAGS[k].freeze
134
+ ALLOWED_TAGS[k]
135
135
  }
136
- ALLOWED_TAGS.freeze
136
+ ALLOWED_TAGS
137
137
 
138
138
  ATTR_VALUE_RE = [ /(?<=^')[^']+(?=')/, /(?<=^")[^"]+(?=")/, /\S+/ ]
139
139
 
@@ -72,6 +72,8 @@ class Card
72
72
  end
73
73
 
74
74
 
75
+
76
+
75
77
  def new card, opts={}
76
78
  klass = self != Format ? self : get_format( (opts[:format] || :html).to_sym )
77
79
  new_format = klass.allocate
@@ -190,6 +192,8 @@ class Card
190
192
  #
191
193
  # ---------- Rendering ------------
192
194
  #
195
+
196
+
193
197
 
194
198
  def render view, args={}
195
199
  prefix = args.delete(:allowed) ? '_' : ''
@@ -250,22 +254,40 @@ class Card
250
254
 
251
255
 
252
256
  def send_final_render_method view, *a
253
- a = [{}] if a.empty?
257
+ @current_view = view
258
+ args = default_render_args view, *a
254
259
  if final_method = view_method(view)
255
260
  with_inclusion_mode view do
256
- send final_method, *a
261
+ send final_method, args
257
262
  end
258
263
  else
259
264
  unsupported_view view
260
265
  end
261
266
  rescue Exception=>e
262
- if Rails.env.test?
267
+ if Rails.env =~ /^cucumber|test$/
263
268
  raise e
264
269
  else
265
270
  rescue_view e, view
266
271
  end
267
272
  end
268
273
 
274
+ def default_render_args view, a=nil
275
+ args = case a
276
+ when nil ; {}
277
+ when Hash ; a.clone
278
+ when Array ; a[0].merge a[1]
279
+ else ; raise Wagn::Error, "bad render args: #{a}"
280
+ end
281
+
282
+ view_key = canonicalize_view view
283
+ default_method = "default_#{ view }_args"
284
+ if respond_to? default_method
285
+ send default_method, args
286
+ end
287
+ args
288
+ end
289
+
290
+
269
291
  def rescue_view e, view
270
292
  controller.send :notify_airbrake, e if Airbrake.configuration.api_key
271
293
  Rails.logger.info "\nError rendering #{error_cardname} / #{view}: #{e.class} : #{e.message}"
@@ -492,7 +514,6 @@ class Card
492
514
  args
493
515
  end
494
516
 
495
-
496
517
  def default_item_view
497
518
  :name
498
519
  end
@@ -570,7 +591,7 @@ class Card
570
591
  @context_names += name.to_name.part_names
571
592
  @context_names.uniq!
572
593
  end
573
- end
574
594
 
595
+ end
575
596
  end
576
597