jabe 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/Gemfile +35 -0
  2. data/Gemfile.lock +217 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.textile +12 -0
  5. data/Rakefile +55 -0
  6. data/VERSION +1 -0
  7. data/app/controllers/admin/base_controller.rb +3 -0
  8. data/app/controllers/admin/entries_controller.rb +42 -0
  9. data/app/controllers/admin/settings_controller.rb +11 -0
  10. data/app/controllers/comments_controller.rb +25 -0
  11. data/app/controllers/entries_controller.rb +26 -0
  12. data/app/helpers/application_helper.rb +9 -0
  13. data/app/models/admin.rb +9 -0
  14. data/app/models/comment.rb +17 -0
  15. data/app/models/entry.rb +17 -0
  16. data/app/models/settings.rb +2 -0
  17. data/app/stylesheets/_will_paginate.scss +102 -0
  18. data/app/stylesheets/application.scss +247 -0
  19. data/app/stylesheets/grid.scss +336 -0
  20. data/app/stylesheets/handheld.scss +7 -0
  21. data/app/stylesheets/style.scss +273 -0
  22. data/app/views/admin/entries/_form.html.haml +6 -0
  23. data/app/views/admin/entries/edit.html.haml +1 -0
  24. data/app/views/admin/entries/index.html.haml +43 -0
  25. data/app/views/admin/entries/new.html.haml +1 -0
  26. data/app/views/admin/settings/edit.html.haml +9 -0
  27. data/app/views/entries/_comment.html.haml +0 -0
  28. data/app/views/entries/_comment_form.html.haml +3 -0
  29. data/app/views/entries/index.html.haml +13 -0
  30. data/app/views/entries/show.html.haml +36 -0
  31. data/app/views/layouts/_footer.html.haml +2 -0
  32. data/app/views/layouts/_header.html.haml +4 -0
  33. data/app/views/layouts/_sidebar.html.haml +0 -0
  34. data/app/views/layouts/application.html.haml +59 -0
  35. data/config/initializers/sass.rb +5 -0
  36. data/config/initializers/settings.rb +5 -0
  37. data/config/initializers/time_formats.rb +4 -0
  38. data/config/routes.rb +26 -0
  39. data/features/admin.feature +30 -0
  40. data/features/entries.feature +24 -0
  41. data/features/step_definitions/admin_steps.rb +14 -0
  42. data/features/step_definitions/entry_steps.rb +35 -0
  43. data/features/step_definitions/support_steps.rb +3 -0
  44. data/features/step_definitions/web_steps.rb +219 -0
  45. data/features/support/blueprints.rb +31 -0
  46. data/features/support/env.rb +59 -0
  47. data/features/support/paths.rb +37 -0
  48. data/lib/generators/jabe/migrations/migrations_generator.rb +42 -0
  49. data/lib/generators/jabe/templates/migrations/create_comments.rb +20 -0
  50. data/lib/generators/jabe/templates/migrations/create_entries.rb +16 -0
  51. data/lib/generators/jabe/templates/migrations/create_settings.rb +21 -0
  52. data/lib/generators/jabe/templates/migrations/create_slugs.rb +18 -0
  53. data/lib/generators/jabe/templates/migrations/devise_create_admins.rb +26 -0
  54. data/lib/jabe.rb +9 -0
  55. data/public/.htaccess +220 -0
  56. data/public/apple-touch-icon.png +0 -0
  57. data/public/blackbird/blackbird.css +80 -0
  58. data/public/blackbird/blackbird.js +365 -0
  59. data/public/blackbird/blackbird.png +0 -0
  60. data/public/crossdomain.xml +25 -0
  61. data/public/images/delete_page.png +0 -0
  62. data/public/images/full_page.png +0 -0
  63. data/public/javascripts/application.js +34 -0
  64. data/public/javascripts/jquery-ui.js +11511 -0
  65. data/public/javascripts/jquery-ui.min.js +404 -0
  66. data/public/javascripts/jquery.js +7179 -0
  67. data/public/javascripts/jquery.min.js +167 -0
  68. data/public/javascripts/libs/dd_belatedpng.js +13 -0
  69. data/public/javascripts/libs/modernizr-1.6.min.js +30 -0
  70. data/public/javascripts/libs/profiling/charts.swf +0 -0
  71. data/public/javascripts/libs/profiling/config.js +59 -0
  72. data/public/javascripts/libs/profiling/yahoo-profiling.css +7 -0
  73. data/public/javascripts/libs/profiling/yahoo-profiling.min.js +39 -0
  74. data/public/javascripts/plugins.js +40 -0
  75. data/public/javascripts/rails.js +154 -0
  76. data/public/nginx.conf +108 -0
  77. data/public/robots.txt +5 -0
  78. data/spec/support/blueprints.rb +31 -0
  79. data/test/dummy/app/controllers/application_controller.rb +3 -0
  80. data/test/dummy/app/helpers/application_helper.rb +2 -0
  81. data/test/dummy/config/application.rb +45 -0
  82. data/test/dummy/config/boot.rb +10 -0
  83. data/test/dummy/config/environment.rb +5 -0
  84. data/test/dummy/config/environments/development.rb +26 -0
  85. data/test/dummy/config/environments/production.rb +49 -0
  86. data/test/dummy/config/environments/test.rb +35 -0
  87. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  88. data/test/dummy/config/initializers/devise.rb +142 -0
  89. data/test/dummy/config/initializers/inflections.rb +10 -0
  90. data/test/dummy/config/initializers/mime_types.rb +5 -0
  91. data/test/dummy/config/initializers/secret_token.rb +7 -0
  92. data/test/dummy/config/initializers/session_store.rb +8 -0
  93. data/test/dummy/config/routes.rb +58 -0
  94. data/test/dummy/db/migrate/20101229224027_create_settings.rb +21 -0
  95. data/test/dummy/db/migrate/20101229224028_create_slugs.rb +18 -0
  96. data/test/dummy/db/migrate/20101229224029_devise_create_admins.rb +26 -0
  97. data/test/dummy/db/migrate/20101229224030_create_entries.rb +16 -0
  98. data/test/dummy/db/migrate/20101229224031_create_comments.rb +20 -0
  99. data/test/dummy/db/schema.rb +82 -0
  100. data/test/dummy/vendor/plugins/acts_as_textiled/init.rb +8 -0
  101. data/test/dummy/vendor/plugins/acts_as_textiled/lib/acts_as_textiled.rb +108 -0
  102. data/test/dummy/vendor/plugins/acts_as_textiled/test/fixtures/author.rb +4 -0
  103. data/test/dummy/vendor/plugins/acts_as_textiled/test/fixtures/story.rb +4 -0
  104. data/test/dummy/vendor/plugins/acts_as_textiled/test/helper.rb +87 -0
  105. data/test/dummy/vendor/plugins/acts_as_textiled/test/textiled_test.rb +145 -0
  106. metadata +641 -0
@@ -0,0 +1,5 @@
1
+ Sass::Plugin.options[:style] = :expanded
2
+ Sass::Plugin.options[:property_syntax] = :new
3
+ Sass::Plugin.options[:template_location] = {
4
+ File.expand_path(File.join(__FILE__, '../../../app/stylesheets')) => 'public/stylesheets'
5
+ }
@@ -0,0 +1,5 @@
1
+ begin
2
+ SETTINGS = Settings.first || Settings.create
3
+ Time.zone = SETTINGS.time_zone
4
+ rescue ActiveRecord::StatementInvalid
5
+ end
@@ -0,0 +1,4 @@
1
+ Time::DATE_FORMATS[:url_part] = lambda { |time|
2
+ month = time.strftime('%m').gsub(/^0/, '')
3
+ time.strftime("%Y/#{month}/%e")
4
+ }
@@ -0,0 +1,26 @@
1
+ Rails::Application.routes.draw do
2
+
3
+ root :to => "entries#index"
4
+
5
+ resources :entries do
6
+ resources :comments
7
+ end
8
+
9
+ namespace :admin do
10
+ root :to => 'entries#index'
11
+ resource :settings
12
+ resources :entries
13
+ end
14
+
15
+ devise_for :admin, :path_names => {
16
+ :sign_in => 'login',
17
+ :sign_out => 'logout'
18
+ }
19
+
20
+ match "/:year/:month/:day/:id" => 'entries#show',
21
+ :constraints => {
22
+ :year => /\d{4}/,
23
+ :month => /\d{1,2}/,
24
+ :day => /\d{1,2}/
25
+ }
26
+ end
@@ -0,0 +1,30 @@
1
+ Feature: Site management
2
+
3
+ Background:
4
+ Given a logged in admin
5
+
6
+ Scenario: An admin edits the site settings
7
+ When I follow "Settings"
8
+ And I fill in "settings_site_name" with "Pixels and Bits"
9
+ And I press "Save"
10
+ Then I should see "Pixels and Bits"
11
+
12
+ Scenario: An admin wants to add a new entry as a draft, then publish
13
+ When I follow "Entries"
14
+ And I follow "Start a new entry"
15
+ And I fill in "entry_title" with "Is this thing on"
16
+ And I fill in "entry_body" with "Hrm, Who knows"
17
+ And I press "Save as draft"
18
+ Then the entry should be a draft
19
+ When I go to the home page
20
+ Then I should not see the entry
21
+ When I follow "Logout"
22
+ And I go to the entry page
23
+ Then the response should be a 404
24
+ Given a logged in admin
25
+ And I go to the admin home page
26
+ And I follow "Entries"
27
+ And I follow the title of the entry
28
+ And I press "Publish"
29
+ And I go to the home page
30
+ Then I should see the entry
@@ -0,0 +1,24 @@
1
+ Feature: Interacting with entries
2
+
3
+ Background:
4
+ Given a published entry
5
+ When I am on the home page
6
+ And I follow the title of the entry
7
+ Then I should see the entry
8
+
9
+ Scenario: A human submits a comment
10
+ When I fill in "comment_name" with "Michael"
11
+ And I fill in "comment_email" with "michael@example.com"
12
+ And I fill in "comment_body" with "Cool post"
13
+ And I press "Add comment"
14
+ Then I should see "Michael"
15
+ And I should see "Cool post"
16
+ And the entry should have 1 comment
17
+
18
+ Scenario: A bot submits a comment
19
+ When I fill in "comment_name" with "v1@gr@"
20
+ And I fill in "comment_nickname" with "blue pill"
21
+ And I fill in "comment_email" with "spambot@example.com"
22
+ And I fill in "comment_body" with "take the blue pill"
23
+ And I press "Add comment"
24
+ Then the entry should have 0 comments
@@ -0,0 +1,14 @@
1
+ Given /^a logged in admin$/ do
2
+ @admin ||= Admin.make!
3
+ steps %Q{
4
+ When I go to the admin home page
5
+ And I fill in "admin_email" with "admin@example.com"
6
+ And I fill in "admin_password" with "password"
7
+ And I press "Sign in"
8
+ Then I should be on the admin home page
9
+ }
10
+ end
11
+
12
+ Then /^I should see the settings options$/ do
13
+ pending # express the regexp above with the code you wish you had
14
+ end
@@ -0,0 +1,35 @@
1
+ Given /^a published entry$/ do
2
+ Entry.make!(:published)
3
+ end
4
+
5
+ Then /^the entry should be a draft$/ do
6
+ entry = @entry || Entry.last
7
+ entry.draft.should be_true
8
+ end
9
+
10
+ Then /^I should not see the entry$/ do
11
+ entry = @entry || Entry.last
12
+ steps %Q{
13
+ And I should not see "#{entry.title}"
14
+ }
15
+ end
16
+
17
+ When /^I follow the title of the entry$/ do
18
+ entry = @entry || Entry.last
19
+ steps %Q{
20
+ And I follow "#{entry.title}"
21
+ }
22
+ end
23
+
24
+ Then /^I should see the entry$/ do
25
+ entry = @entry || Entry.last
26
+ steps %Q{
27
+ And I should see "#{entry.title}"
28
+ And I should see "#{entry.body(:source)}"
29
+ }
30
+ end
31
+
32
+ Then /^the entry should have (\d+) comments?$/ do |count|
33
+ entry = @entry || Entry.last
34
+ entry.comments.count.should eql(count.to_i)
35
+ end
@@ -0,0 +1,3 @@
1
+ Then /^the response should be a (\d+)$/ do |status|
2
+ page.driver.response.status.should eql(status.to_i)
3
+ end
@@ -0,0 +1,219 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ require 'uri'
9
+ require 'cgi'
10
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
11
+
12
+ module WithinHelpers
13
+ def with_scope(locator)
14
+ locator ? within(locator) { yield } : yield
15
+ end
16
+ end
17
+ World(WithinHelpers)
18
+
19
+ Given /^(?:|I )am on (.+)$/ do |page_name|
20
+ visit path_to(page_name)
21
+ end
22
+
23
+ When /^(?:|I )go to (.+)$/ do |page_name|
24
+ visit path_to(page_name)
25
+ end
26
+
27
+ When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
28
+ with_scope(selector) do
29
+ click_button(button)
30
+ end
31
+ end
32
+
33
+ When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
34
+ with_scope(selector) do
35
+ click_link(link)
36
+ end
37
+ end
38
+
39
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
40
+ with_scope(selector) do
41
+ fill_in(field, :with => value)
42
+ end
43
+ end
44
+
45
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
46
+ with_scope(selector) do
47
+ fill_in(field, :with => value)
48
+ end
49
+ end
50
+
51
+ # Use this to fill in an entire form with data from a table. Example:
52
+ #
53
+ # When I fill in the following:
54
+ # | Account Number | 5002 |
55
+ # | Expiry date | 2009-11-01 |
56
+ # | Note | Nice guy |
57
+ # | Wants Email? | |
58
+ #
59
+ # TODO: Add support for checkbox, select og option
60
+ # based on naming conventions.
61
+ #
62
+ When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
63
+ with_scope(selector) do
64
+ fields.rows_hash.each do |name, value|
65
+ When %{I fill in "#{name}" with "#{value}"}
66
+ end
67
+ end
68
+ end
69
+
70
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
71
+ with_scope(selector) do
72
+ select(value, :from => field)
73
+ end
74
+ end
75
+
76
+ When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
77
+ with_scope(selector) do
78
+ check(field)
79
+ end
80
+ end
81
+
82
+ When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
83
+ with_scope(selector) do
84
+ uncheck(field)
85
+ end
86
+ end
87
+
88
+ When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
89
+ with_scope(selector) do
90
+ choose(field)
91
+ end
92
+ end
93
+
94
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
95
+ with_scope(selector) do
96
+ attach_file(field, path)
97
+ end
98
+ end
99
+
100
+ Then /^(?:|I )should see JSON:$/ do |expected_json|
101
+ require 'json'
102
+ expected = JSON.pretty_generate(JSON.parse(expected_json))
103
+ actual = JSON.pretty_generate(JSON.parse(response.body))
104
+ expected.should == actual
105
+ end
106
+
107
+ Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
108
+ with_scope(selector) do
109
+ if page.respond_to? :should
110
+ page.should have_content(text)
111
+ else
112
+ assert page.has_content?(text)
113
+ end
114
+ end
115
+ end
116
+
117
+ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
118
+ regexp = Regexp.new(regexp)
119
+ with_scope(selector) do
120
+ if page.respond_to? :should
121
+ page.should have_xpath('//*', :text => regexp)
122
+ else
123
+ assert page.has_xpath?('//*', :text => regexp)
124
+ end
125
+ end
126
+ end
127
+
128
+ Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
129
+ with_scope(selector) do
130
+ if page.respond_to? :should
131
+ page.should have_no_content(text)
132
+ else
133
+ assert page.has_no_content?(text)
134
+ end
135
+ end
136
+ end
137
+
138
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
139
+ regexp = Regexp.new(regexp)
140
+ with_scope(selector) do
141
+ if page.respond_to? :should
142
+ page.should have_no_xpath('//*', :text => regexp)
143
+ else
144
+ assert page.has_no_xpath?('//*', :text => regexp)
145
+ end
146
+ end
147
+ end
148
+
149
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
150
+ with_scope(selector) do
151
+ field = find_field(field)
152
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
153
+ if field_value.respond_to? :should
154
+ field_value.should =~ /#{value}/
155
+ else
156
+ assert_match(/#{value}/, field_value)
157
+ end
158
+ end
159
+ end
160
+
161
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
162
+ with_scope(selector) do
163
+ field = find_field(field)
164
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
165
+ if field_value.respond_to? :should_not
166
+ field_value.should_not =~ /#{value}/
167
+ else
168
+ assert_no_match(/#{value}/, field_value)
169
+ end
170
+ end
171
+ end
172
+
173
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
174
+ with_scope(selector) do
175
+ field_checked = find_field(label)['checked']
176
+ if field_checked.respond_to? :should
177
+ field_checked.should be_true
178
+ else
179
+ assert field_checked
180
+ end
181
+ end
182
+ end
183
+
184
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
185
+ with_scope(selector) do
186
+ field_checked = find_field(label)['checked']
187
+ if field_checked.respond_to? :should
188
+ field_checked.should be_false
189
+ else
190
+ assert !field_checked
191
+ end
192
+ end
193
+ end
194
+
195
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
196
+ current_path = URI.parse(current_url).path
197
+ if current_path.respond_to? :should
198
+ current_path.should == path_to(page_name)
199
+ else
200
+ assert_equal path_to(page_name), current_path
201
+ end
202
+ end
203
+
204
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
205
+ query = URI.parse(current_url).query
206
+ actual_params = query ? CGI.parse(query) : {}
207
+ expected_params = {}
208
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
209
+
210
+ if actual_params.respond_to? :should
211
+ actual_params.should == expected_params
212
+ else
213
+ assert_equal expected_params, actual_params
214
+ end
215
+ end
216
+
217
+ Then /^show me the page$/ do
218
+ save_and_open_page
219
+ end
@@ -0,0 +1,31 @@
1
+ require 'machinist/active_record'
2
+
3
+ # takes care of
4
+ # Validation failed: Email has already been taken (ActiveRecord::RecordInvalid)
5
+ Machinist.configure do |config|
6
+ config.cache_objects = false
7
+ end
8
+
9
+ Admin.blueprint do
10
+ email { 'admin@example.com' }
11
+ password { 'password' }
12
+ password_confirmation { 'password' }
13
+ end
14
+
15
+ Settings.blueprint do
16
+ # Attributes here
17
+ end
18
+
19
+ Entry.blueprint do
20
+ title { Faker::Lorem.words.to_s }
21
+ body { Faker::Lorem.paragraph }
22
+ published_at { Time.now }
23
+ end
24
+
25
+ Entry.blueprint(:published) do
26
+ draft { false }
27
+ end
28
+
29
+ Comment.blueprint do
30
+ # Attributes here
31
+ end
@@ -0,0 +1,59 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+ ENV["RAILS_ENV"] ||= "test"
8
+ require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
9
+
10
+ require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
11
+ require 'cucumber/rails/rspec'
12
+ require 'cucumber/rails/world'
13
+ require 'cucumber/rails/active_record'
14
+ require 'cucumber/web/tableish'
15
+
16
+ require 'capybara/rails'
17
+ require 'capybara/cucumber'
18
+ require 'capybara/session'
19
+ #require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
20
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
21
+ # order to ease the transition to Capybara we set the default here. If you'd
22
+ # prefer to use XPath just remove this line and adjust any selectors in your
23
+ # steps to use the XPath syntax.
24
+ Capybara.default_selector = :css
25
+
26
+ # If you set this to false, any error raised from within your app will bubble
27
+ # up to your step definition and out to cucumber unless you catch it somewhere
28
+ # on the way. You can make Rails rescue errors and render error pages on a
29
+ # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
30
+ #
31
+ # If you set this to true, Rails will rescue all errors and render error
32
+ # pages, more or less in the same way your application would behave in the
33
+ # default production environment. It's not recommended to do this for all
34
+ # of your scenarios, as this makes it hard to discover errors in your application.
35
+ ActionController::Base.allow_rescue = false
36
+
37
+ # If you set this to true, each scenario will run in a database transaction.
38
+ # You can still turn off transactions on a per-scenario basis, simply tagging
39
+ # a feature or scenario with the @no-txn tag. If you are using Capybara,
40
+ # tagging with @culerity or @javascript will also turn transactions off.
41
+ #
42
+ # If you set this to false, transactions will be off for all scenarios,
43
+ # regardless of whether you use @no-txn or not.
44
+ #
45
+ # Beware that turning transactions off will leave data in your database
46
+ # after each scenario, which can lead to hard-to-debug failures in
47
+ # subsequent scenarios. If you do this, we recommend you create a Before
48
+ # block that will explicitly put your database in a known state.
49
+ Cucumber::Rails::World.use_transactional_fixtures = true
50
+ # How to clean your database when transactions are turned off. See
51
+ # http://github.com/bmabey/database_cleaner for more info.
52
+ if defined?(ActiveRecord::Base)
53
+ begin
54
+ require 'database_cleaner'
55
+ DatabaseCleaner.strategy = :truncation
56
+ DatabaseCleaner.clean
57
+ rescue LoadError => ignore_if_database_cleaner_not_present
58
+ end
59
+ end