wagn 1.13.0.pre1 → 1.13.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/controllers/card_controller.rb +3 -3
  4. data/db/migrate_cards/20140307231621_user_data_to_cards.rb +5 -1
  5. data/lib/card.rb +5 -7
  6. data/lib/card/chunk.rb +1 -0
  7. data/lib/card/codename.rb +48 -31
  8. data/lib/card/env.rb +0 -1
  9. data/lib/card/exceptions.rb +3 -3
  10. data/lib/card/format.rb +89 -166
  11. data/lib/card/generators/set/USAGE +1 -1
  12. data/lib/card/loader.rb +1 -1
  13. data/lib/card/set.rb +196 -112
  14. data/lib/card/set_pattern.rb +37 -71
  15. data/lib/wagn/cache.rb +8 -7
  16. data/lib/wagn/commands.rb +1 -1
  17. data/lib/wagn/config/environments/development.rb +1 -1
  18. data/lib/wagn/config/initializers/paperclip.rb +1 -0
  19. data/lib/wagn/generators/wagn/templates/Gemfile +59 -55
  20. data/lib/wagn/location.rb +2 -2
  21. data/mods/core/formats/html_format.rb +2 -6
  22. data/mods/core/formats/text_format.rb +1 -1
  23. data/mods/core/set_patterns/01_all.rb +0 -5
  24. data/mods/core/set_patterns/02_all_plus.rb +1 -3
  25. data/mods/core/set_patterns/07_type_plus_right.rb +0 -1
  26. data/mods/core/sets/all/active_card.rb +1 -1
  27. data/mods/core/sets/all/name.rb +3 -2
  28. data/mods/core/sets/all/pattern.rb +9 -23
  29. data/mods/core/sets/all/phases.rb +27 -13
  30. data/mods/core/sets/all/rules.rb +3 -3
  31. data/mods/core/sets/all/templating.rb +5 -2
  32. data/mods/core/sets/all/tracked_attributes.rb +2 -1
  33. data/mods/core/sets/right/structure.rb +13 -0
  34. data/mods/{standard → core}/sets/type/plain_text.rb +0 -0
  35. data/mods/standard/formats/email_html_format.rb +1 -1
  36. data/mods/standard/lib/card/machine.rb +16 -12
  37. data/mods/standard/lib/card/machine_input.rb +1 -1
  38. data/mods/standard/sets/all/attach.rb +1 -1
  39. data/mods/standard/sets/all/base.rb +92 -94
  40. data/mods/standard/sets/all/follow.rb +1 -1
  41. data/mods/standard/sets/all/rich_html.rb +5 -3
  42. data/mods/standard/sets/all/rss.rb +12 -5
  43. data/mods/standard/sets/right/account.rb +1 -1
  44. data/mods/standard/sets/right/add_help.rb +3 -1
  45. data/mods/standard/sets/right/comment.rb +92 -3
  46. data/mods/standard/sets/right/create.rb +2 -87
  47. data/mods/standard/sets/right/default.rb +3 -2
  48. data/mods/standard/sets/right/delete.rb +2 -5
  49. data/mods/standard/sets/right/help.rb +3 -1
  50. data/mods/standard/sets/right/machine_output.rb +9 -7
  51. data/mods/standard/sets/right/read.rb +2 -5
  52. data/mods/standard/sets/right/style.rb +3 -2
  53. data/mods/standard/sets/right/update.rb +2 -5
  54. data/mods/standard/sets/rstar/rules.rb +0 -2
  55. data/mods/standard/sets/self/head.rb +2 -3
  56. data/mods/standard/sets/self/navbox.rb +0 -7
  57. data/mods/standard/sets/self/recent.rb +2 -2
  58. data/mods/standard/sets/self/search.rb +10 -3
  59. data/mods/standard/sets/self/signin.rb +3 -3
  60. data/mods/standard/sets/type/cardtype.rb +2 -2
  61. data/mods/standard/sets/type/coffee_script.rb +4 -4
  62. data/mods/standard/sets/type/css.rb +12 -4
  63. data/mods/standard/sets/type/image.rb +19 -19
  64. data/mods/standard/sets/type/java_script.rb +1 -1
  65. data/mods/standard/sets/type/layout_type.rb +3 -2
  66. data/mods/standard/sets/type/pointer.rb +3 -2
  67. data/mods/standard/sets/type/scss.rb +6 -34
  68. data/mods/standard/sets/type/search_type.rb +22 -16
  69. data/mods/standard/sets/type/set.rb +2 -2
  70. data/mods/standard/sets/type/setting.rb +2 -2
  71. data/mods/standard/sets/type/skin.rb +4 -18
  72. data/spec/controllers/card_controller_spec.rb +2 -2
  73. data/spec/lib/card/flexmail_spec.rb +1 -0
  74. data/spec/lib/card/format_spec.rb +9 -9
  75. data/spec/lib/card/loader_spec.rb +1 -2
  76. data/spec/lib/card/name_spec.rb +7 -1
  77. data/spec/lib/card/set_pattern_spec.rb +5 -5
  78. data/spec/mods/core/sets/all/pattern_spec.rb +0 -9
  79. data/spec/mods/core/sets/all/phases_spec.rb +2 -1
  80. data/spec/mods/standard/lib/machine_input_spec.rb +20 -4
  81. data/spec/mods/standard/lib/machine_spec.rb +64 -14
  82. data/spec/mods/standard/sets/right/machine_output_spec.rb +2 -17
  83. data/spec/mods/standard/sets/right/script_spec.rb +9 -5
  84. data/spec/mods/standard/sets/right/style_spec.rb +11 -5
  85. data/spec/mods/standard/sets/type/coffeescript_spec.rb +5 -7
  86. data/spec/mods/standard/sets/type/css_spec.rb +3 -4
  87. data/spec/mods/standard/sets/type/javascript_spec.rb +3 -5
  88. data/spec/mods/standard/sets/type/scss_spec.rb +4 -7
  89. data/spec/mods/standard/sets/type/skin_spec.rb +29 -8
  90. metadata +5 -4
  91. data/mods/standard/sets/right/structure.rb +0 -12
@@ -1,26 +1,29 @@
1
1
 
2
2
  include File
3
3
 
4
- view :closed_content do |args|
5
- _render_core :size=>:icon
6
- end
7
-
8
- view :source do |args|
9
- style = case
10
- when @mode==:closed ; :icon
11
- when args[:size] ; args[:size]
12
- when main? ; :large
13
- else ; :medium
14
- end
15
- style = :original if style.to_sym == :full
16
- card.attach.url style
17
- end
4
+ format do
5
+
6
+ include File::Format
18
7
 
8
+ view :closed_content do |args|
9
+ _render_core :size=>:icon
10
+ end
19
11
 
20
- view :core, :type=>:file
12
+ view :source do |args|
13
+ style = case
14
+ when @mode==:closed ; :icon
15
+ when args[:size] ; args[:size]
16
+ when main? ; :large
17
+ else ; :medium
18
+ end
19
+ style = :original if style.to_sym == :full
20
+ card.attach.url style
21
+ end
21
22
 
23
+ end
22
24
 
23
25
  format :html do
26
+ include File::HtmlFormat
24
27
 
25
28
  view :core do |args|
26
29
  handle_source args do |source|
@@ -40,8 +43,6 @@ format :html do
40
43
  out
41
44
  end
42
45
 
43
- view :editor, :type=>:file
44
-
45
46
  end
46
47
 
47
48
  format :css do
@@ -55,12 +56,11 @@ format :css do
55
56
  end
56
57
 
57
58
  format :file do
59
+ include File::FileFormat
58
60
 
59
61
  view :style do |args| #should this be in model?
60
62
  ['', 'full'].member?( args[:style].to_s ) ? :original : args[:style]
61
63
  end
62
64
 
63
- view :core, :type=>:file
64
-
65
65
  end
66
66
 
@@ -22,7 +22,7 @@ end
22
22
 
23
23
  format :html do
24
24
 
25
- view :editor, :type=>:plain_text
25
+ view :editor, :mod=>PlainText::HtmlFormat
26
26
 
27
27
  view :core do |args|
28
28
  highlighted_js = ::CodeRay.scan( _render_raw, :js ).div
@@ -1,8 +1,9 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  include Html
3
3
 
4
- view :editor, :type=>:html
5
- view :closed_content, :type=>:html
4
+ format do
5
+ include Html::Format
6
+ end
6
7
 
7
8
  format :html do
8
9
  view :core do |args|
@@ -128,13 +128,14 @@ format :css do
128
128
  %(#{major_comment "STYLE GROUP: \"#{card.name}\"", '='}#{ _render_core })
129
129
  end
130
130
 
131
- view :content, :core
132
-
133
131
  view :core do |args|
134
132
  card.item_cards.map do |item|
135
133
  nest item, :view=>(params[:item] || :content)
136
134
  end.join "\n\n"
137
135
  end
136
+
137
+ view :content, :core
138
+
138
139
  end
139
140
 
140
141
  format :data do
@@ -1,38 +1,11 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'sass'
3
-
4
- include Machine
5
- include MachineInput
6
-
7
- store_machine_output :filetype => "css"
8
-
9
- def compressed_css input
10
- begin
11
- Sass.compile input, :style=>:compressed
12
- rescue Exception=>e
13
- raise Card::Oops, "Stylesheet Error:\n#{ e.message }"
14
- end
15
- end
16
-
17
- machine_input do
18
- compressed_css format(:format => :css)._render_core
19
- end
20
-
1
+ include Card::Set::Type::Css
21
2
 
22
3
  format :html do
23
-
24
- view :editor, :type=>:plain_text
4
+ view :core, :mod=>Css::HtmlFormat
5
+ view :editor, :mod=>PlainText::HtmlFormat
6
+ end
25
7
 
26
- view :core do |args|
27
- #fixme - shouldn't we just render SCSS?
28
- css = compile_scss _render_raw
29
- highlighted_css = ::CodeRay.scan( css, :css ).div
30
- process_content highlighted_css
31
- end
32
8
 
33
- end
34
-
35
-
36
9
  format do
37
10
  view :core do |args|
38
11
  process_content compile_scss(_render_raw)
@@ -40,10 +13,9 @@ format do
40
13
 
41
14
  def compile_scss scss, style=:expanded
42
15
  Sass.compile scss, :style=>style
43
- rescue Exception=>e
16
+ rescue =>e
44
17
  e
45
- end
46
-
18
+ end
47
19
  end
48
20
 
49
21
 
@@ -55,6 +55,8 @@ format do
55
55
  %{#{e.class.to_s} :: #{e.message} :: #{card.content}}
56
56
  when search_vars[:spec][:return] =='count'
57
57
  search_vars[:results].to_s
58
+ when @mode == :template
59
+ render :raw
58
60
  else
59
61
  _render_card_list args
60
62
  end
@@ -72,13 +74,13 @@ format do
72
74
 
73
75
  def search_vars args={}
74
76
 
75
- @vars[:search] ||= begin
77
+ @search_vars ||= begin
76
78
  v = {}
77
79
  v[:spec] = card.spec search_params
78
80
  v[:item] = set_inclusion_opts args.merge( :spec_view=>v[:spec][:view] )
79
81
  v[:results] = card.item_cards search_params
80
82
  v
81
- rescue Exception=>e
83
+ rescue =>e
82
84
  { :error => e }
83
85
  end
84
86
  end
@@ -90,20 +92,11 @@ format do
90
92
  # explicit > inclusion syntax > WQL > inclusion defaults
91
93
  end
92
94
 
93
- def default_search_params
94
- set_default_search_params
95
- end
96
95
 
97
- def set_default_search_params overrides={}
98
- @default_search_params ||= begin
99
- p = { :default_limit=> 100 }.merge overrides
100
- set_search_params_variables! p
101
- p
102
- end
103
- end
96
+
104
97
 
105
98
  def search_params
106
- @vars[:search_params] ||= begin
99
+ @search_params ||= begin
107
100
  p = default_search_params.clone
108
101
 
109
102
  if focal?
@@ -114,18 +107,31 @@ format do
114
107
  p
115
108
  end
116
109
  end
110
+
111
+ def default_search_params # wahh?
112
+ set_default_search_params
113
+ end
114
+
115
+ def set_default_search_params overrides={}
116
+ @default_search_params ||= begin
117
+ p = { :default_limit=> 100 }.merge overrides
118
+ set_search_params_variables! p
119
+ p
120
+ end
121
+ end
117
122
 
118
123
  def set_search_params_variables! hash
119
124
  hash[:vars] = params[:vars] || {}
120
125
  params.each do |key,val|
121
- if key.to_s =~ /^\_(\w+)$/
122
- hash[:vars][$1.to_sym] = val
126
+ case key.to_s
127
+ when '_wql' ; hash.merge! val
128
+ when /^\_(\w+)$/ ; hash[:vars][$1.to_sym] = val
123
129
  end
124
130
  end
125
131
  end
126
132
 
127
133
  def page_link text, page
128
- @paging_path_args[:offset] = page * @paging_limit #fixme. should be @vars?
134
+ @paging_path_args[:offset] = page * @paging_limit
129
135
  " #{link_to raw(text), path(@paging_path_args), :class=>'card-paging-link slotter', :remote => true} "
130
136
  end
131
137
 
@@ -67,13 +67,13 @@ include Card::Set::Type::SearchType
67
67
 
68
68
  def inheritable?
69
69
  return true if junction_only?
70
- cardname.trunk_name.junction? and cardname.tag_name.key == Card::SetPattern::SelfPattern.key_name.key
70
+ cardname.trunk_name.junction? and cardname.tag_name.key == Card::SelfSet.pattern.key
71
71
  end
72
72
 
73
73
  def subclass_for_set
74
74
  set_class_key = tag.codename
75
75
  Card.set_patterns.find do |sub|
76
- cardname.tag_name.key == sub.key_name.key
76
+ cardname.tag_name.key == sub.pattern.key
77
77
  end
78
78
  end
79
79
 
@@ -21,7 +21,7 @@ view :core do |args|
21
21
  :sort => ['content', 'name'],
22
22
  :limit => 0
23
23
  }
24
- wql[:left][ (set_class.anchorless? ? :id : :right_id )] = set_class.key_id
24
+ wql[:left][ (set_class.anchorless? ? :id : :right_id )] = set_class.pattern_id
25
25
 
26
26
  rules = Card.search wql
27
27
  [ set_class, rules ] unless rules.empty?
@@ -37,7 +37,7 @@ view :core do |args|
37
37
  klasses.map do |klass, rules|
38
38
  %{
39
39
  <tr class="klass-row anchorless-#{ klass.anchorless? }">
40
- <td class="setting-klass">#{ klass.anchorless? ? link_to_page( klass.key_name ) : klass.key_name }</td>
40
+ <td class="setting-klass">#{ klass.anchorless? ? link_to_page( klass.pattern ) : klass.pattern }</td>
41
41
  <td class="rule-content-container">
42
42
  <span class="closed-content content">#{ subformat(rules[0])._render_closed_content if klass.anchorless? }</span>
43
43
  </td>
@@ -1,26 +1,12 @@
1
- include Pointer
2
1
  include Machine
3
2
  include MachineInput
4
3
 
5
4
  store_machine_output :filetype => "css"
6
5
 
7
- view :core, :type=>:pointer
8
-
9
- format :html do
10
- view :closed_content, :type=>:pointer
11
- view :core, :type=>:pointer
12
- view :editor, :type=>:pointer
13
- view :list, :type=>:pointer
14
- view :checkbox, :type=>:pointer
15
- view :multiselect, :type=>:pointer
16
- view :radio, :type=>:pointer
17
- view :select, :type=>:pointer
18
- end
19
-
20
- format :css do
21
- view :content, :type=>:pointer
22
- view :core, :type=>:pointer
23
- end
6
+ include Pointer
7
+ format() { include Pointer::Format }
8
+ format(:html) { include Pointer::HtmlFormat }
9
+ format(:css ) { include Pointer::CssFormat }
24
10
 
25
11
 
26
12
 
@@ -180,7 +180,7 @@ describe CardController do
180
180
  get :read, {:id=>'~9999999'}
181
181
  assert_response 404
182
182
  end
183
-
183
+
184
184
  it "returns denial when no read permission" do
185
185
  Card::Auth.as_bot do
186
186
  Card.create! :name=>'Strawberry', :type=>'Fruit' #only admin can read
@@ -249,7 +249,7 @@ describe CardController do
249
249
  args = { :id=>@all_style.machine_output_card.name, :format=>'css', :explicit_file=>true }
250
250
  get :read, args
251
251
  output_card = Card[ "#{ Card[:all].name }+#{ Card[:style].name }+#{ Card[:machine_output].name}" ]
252
- expect(response).to redirect_to( "#{ wagn_path output_card.attach.url }" )
252
+ expect(response).to redirect_to( @all_style.machine_output_url )
253
253
  get :read, args
254
254
  expect(response.status).to eq(200)
255
255
  end
@@ -86,6 +86,7 @@ describe Card::Flexmail do
86
86
  end
87
87
 
88
88
  it "returns list with correct hash for card with configs" do
89
+ pending 'spec is breaking but flexmail is being refactored'
89
90
  Card::Auth.as_bot do
90
91
  Card::Env[:protocol] = 'http://'
91
92
  Card::Env[:host] = 'a.com'
@@ -8,21 +8,21 @@ describe Card::Format do
8
8
  end
9
9
 
10
10
  it "should respect defaults" do
11
- @format.show_view?( :menu, {}, :show ).should be_true
12
- @format.show_view?( :menu, {}, :hide ).should be_false
13
- @format.show_view?( :menu, {} ).should be_true
11
+ @format.show_view?( :menu, :default_visibility=>:show ).should be_true
12
+ @format.show_view?( :menu, :default_visibility=>:hide ).should be_false
13
+ @format.show_view?( :menu, {} ).should be_true
14
14
  end
15
15
 
16
16
  it "should respect developer default overrides" do
17
- @format.show_view?( :menu, { :optional_menu=>:show }, :hide ).should be_true
18
- @format.show_view?( :menu, { :optional_menu=>:hide }, :show ).should be_false
19
- @format.show_view?( :menu, { :optional_menu=>:hide } ).should be_false
17
+ @format.show_view?( :menu, :optional_menu=>:show, :default_visibility=>:hide ).should be_true
18
+ @format.show_view?( :menu, :optional_menu=>:hide, :default_visibility=>:show ).should be_false
19
+ @format.show_view?( :menu, :optional_menu=>:hide ).should be_false
20
20
  end
21
21
 
22
22
  it "should handle args from inclusions" do
23
- @format.show_view?( :menu, { :show=>'menu' }, :hide ).should be_true
24
- @format.show_view?( :menu, { :hide=>'menu, paging' }, :show ).should be_false
25
- @format.show_view?( :menu, :show=>'menu', :optional_menu=>:hide ).should be_true
23
+ @format.show_view?( :menu, :show=>'menu', :default_visibility=>:hide ).should be_true
24
+ @format.show_view?( :menu, :hide=>'menu, paging', :default_visibility=>:show ).should be_false
25
+ @format.show_view?( :menu, :show=>'menu', :optional_menu=>:hide ).should be_true
26
26
  end
27
27
 
28
28
  it "should handle hard developer overrides" do
@@ -1,7 +1,7 @@
1
1
 
2
2
  describe Card::Loader do
3
3
  let(:card_double) { proxy Card }
4
- let(:pat_all_double) { proxy Card::SetPattern::AllPattern }
4
+ let(:pat_all_double) { proxy Card::AllSet }
5
5
  let(:format_double) { proxy Card::Format }
6
6
  let(:html_format_double) { proxy Card::HtmlFormat }
7
7
  it "should auto-load Card class methods from lib/wagn and mods" do
@@ -10,7 +10,6 @@ describe Card::Loader do
10
10
  card_double.should_receive(:load_sets)
11
11
  card_double.should_receive(:tracks).with(:any_args) # so Card still loads without core in failure testing
12
12
  card_double.method(:version).should be
13
- card_double.method(:method_key).should be
14
13
  card_double.method(:type_card).should be
15
14
  card_double.method(:file_path).should be
16
15
  end
@@ -101,7 +101,13 @@ describe Card::Name do
101
101
  # "Tes~sd".to_name.should_not be_valid
102
102
  "TEST/DDER".to_name.should_not be_valid
103
103
  end
104
- end
104
+
105
+ it "rejects long names" do
106
+ card = Card.new
107
+ card.name="1"*256
108
+ card.should_not be_valid
109
+ end
110
+ end
105
111
 
106
112
  describe "#left_name" do
107
113
  it "returns nil for non junction" do
@@ -17,23 +17,23 @@ end
17
17
 
18
18
  #FIXME - these should probably be in pattern-specific specs, though that may not leave much to test in the base class :)
19
19
 
20
- describe Card::SetPattern::RightPattern do
20
+ describe Card::RightSet do
21
21
  it_generates :name => "author+*right", :from => Card.new( :name => "Iliad+author" )
22
22
  it_generates :name => "author+*right", :from => Card.new( :name => "+author" )
23
23
  end
24
24
 
25
- describe Card::SetPattern::TypePattern do
25
+ describe Card::TypeSet do
26
26
  it_generates :name => "Book+*type", :from => Card.new( :type => "Book" )
27
27
  end
28
28
 
29
- describe Card::SetPattern::AllPlusPattern do
29
+ describe Card::AllPlusSet do
30
30
  it_generates :name => "*all plus", :from => Card.new( :name => "Book+author" )
31
31
  end
32
32
 
33
- describe Card::SetPattern::AllPattern do
33
+ describe Card::AllSet do
34
34
  it_generates :name => "*all", :from => Card.new( :type => "Book" )
35
35
  end
36
36
 
37
- describe Card::SetPattern::TypePlusRightPattern do
37
+ describe Card::TypePlusRightSet do
38
38
  it_generates :name => "Book+author+*type plus right", :from => Card.new( :name=>"Iliad+author" )
39
39
  end
@@ -44,15 +44,6 @@ describe Card::Set::All::Pattern do
44
44
  end
45
45
  end
46
46
 
47
- describe :method_keys do
48
- it "returns correct set names for simple cards" do
49
- card = Card.new( :name => "AnewCard" )
50
- card.method_keys.should == [ "basic_type", ""]
51
- card.save!
52
- card = Card.fetch("AnewCard")
53
- card.method_keys.should == [ "basic_type",""]
54
- end
55
- end
56
47
 
57
48
  describe :rule_set_keys do
58
49
  it "returns correct set names for new cards" do