hitchens 0.0.1

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.
Files changed (96) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +39 -0
  4. data/app/assets/javascripts/hitchens/application.js +9 -0
  5. data/app/assets/stylesheets/hitchens/application.css +7 -0
  6. data/app/assets/stylesheets/hitchens/coderay.css.scss +34 -0
  7. data/app/assets/stylesheets/hitchens/pagination.css.scss +6 -0
  8. data/app/controllers/hitchens/application_controller.rb +17 -0
  9. data/app/controllers/hitchens/posts_controller.rb +32 -0
  10. data/app/decorators/hitchens/application_decorator.rb +25 -0
  11. data/app/decorators/hitchens/post_decorator.rb +22 -0
  12. data/app/helpers/hitchens/application_helper.rb +4 -0
  13. data/app/models/hitchens/ability.rb +17 -0
  14. data/app/models/hitchens/post.rb +18 -0
  15. data/app/views/hitchens/posts/_form.html.haml +5 -0
  16. data/app/views/hitchens/posts/_post.html.haml +5 -0
  17. data/app/views/hitchens/posts/edit.html.haml +1 -0
  18. data/app/views/hitchens/posts/index.html.haml +7 -0
  19. data/app/views/hitchens/posts/index.rss.builder +18 -0
  20. data/app/views/hitchens/posts/new.html.haml +1 -0
  21. data/app/views/hitchens/posts/show.html.haml +1 -0
  22. data/app/views/layouts/hitchens/application.html.haml +10 -0
  23. data/config/initializers/simple_form.rb +93 -0
  24. data/config/locales/simple_form.en.yml +24 -0
  25. data/config/routes.rb +4 -0
  26. data/db/migrate/20111201212510_create_hitchens_posts.rb +11 -0
  27. data/lib/hitchens/engine.rb +5 -0
  28. data/lib/hitchens/version.rb +3 -0
  29. data/lib/hitchens.rb +34 -0
  30. data/lib/tasks/hitchens_tasks.rake +4 -0
  31. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  32. data/test/dummy/Rakefile +7 -0
  33. data/test/dummy/app/assets/javascripts/application.js +9 -0
  34. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  35. data/test/dummy/app/controllers/application_controller.rb +3 -0
  36. data/test/dummy/app/helpers/application_helper.rb +2 -0
  37. data/test/dummy/app/models/user.rb +9 -0
  38. data/test/dummy/app/views/layouts/application.html.erb +22 -0
  39. data/test/dummy/config/application.rb +45 -0
  40. data/test/dummy/config/boot.rb +10 -0
  41. data/test/dummy/config/database.yml +28 -0
  42. data/test/dummy/config/environment.rb +5 -0
  43. data/test/dummy/config/environments/development.rb +30 -0
  44. data/test/dummy/config/environments/production.rb +60 -0
  45. data/test/dummy/config/environments/test.rb +39 -0
  46. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  47. data/test/dummy/config/initializers/devise.rb +209 -0
  48. data/test/dummy/config/initializers/inflections.rb +10 -0
  49. data/test/dummy/config/initializers/mime_types.rb +5 -0
  50. data/test/dummy/config/initializers/secret_token.rb +7 -0
  51. data/test/dummy/config/initializers/session_store.rb +8 -0
  52. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  53. data/test/dummy/config/locales/devise.en.yml +58 -0
  54. data/test/dummy/config/locales/en.yml +5 -0
  55. data/test/dummy/config/routes.rb +5 -0
  56. data/test/dummy/config.ru +4 -0
  57. data/test/dummy/db/development.sqlite3 +0 -0
  58. data/test/dummy/db/migrate/20111202001010_devise_create_users.rb +25 -0
  59. data/test/dummy/db/migrate/20111202003417_add_admin_to_users.rb +5 -0
  60. data/test/dummy/db/migrate/20111202023821_create_hitchens_posts.rb +11 -0
  61. data/test/dummy/db/schema.rb +43 -0
  62. data/test/dummy/db/test.sqlite3 +0 -0
  63. data/test/dummy/log/development.log +18853 -0
  64. data/test/dummy/log/test.log +0 -0
  65. data/test/dummy/public/404.html +26 -0
  66. data/test/dummy/public/422.html +26 -0
  67. data/test/dummy/public/500.html +26 -0
  68. data/test/dummy/public/favicon.ico +0 -0
  69. data/test/dummy/script/rails +6 -0
  70. data/test/dummy/spec/models/user_spec.rb +5 -0
  71. data/test/dummy/tmp/cache/assets/C1E/200/sprockets%2F3d344d935905630d41134fb51e119849 +0 -0
  72. data/test/dummy/tmp/cache/assets/CA8/B10/sprockets%2Fd31e4202073904ed51e4f3aa75148d79 +0 -0
  73. data/test/dummy/tmp/cache/assets/CCD/060/sprockets%2F7dd86c789291a96633962ed81f272f1f +0 -0
  74. data/test/dummy/tmp/cache/assets/CE6/E50/sprockets%2Ffe709a4d78a49cd80a434a99027404b8 +0 -0
  75. data/test/dummy/tmp/cache/assets/CFA/190/sprockets%2F81caafd20de19b068c5c14b514060906 +0 -0
  76. data/test/dummy/tmp/cache/assets/D04/8A0/sprockets%2F411cb82258bc23e6d4ba58278122b4fe +0 -0
  77. data/test/dummy/tmp/cache/assets/D0C/830/sprockets%2Fb5d74b7769bb13a1a3844d8386b3a04f +0 -0
  78. data/test/dummy/tmp/cache/assets/D12/940/sprockets%2F5efd50c82d402f87c1d37826fed07009 +0 -0
  79. data/test/dummy/tmp/cache/assets/D29/CB0/sprockets%2Fa2ab72eb0a4f976e45dd24207c151b05 +0 -0
  80. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  81. data/test/dummy/tmp/cache/assets/D40/0F0/sprockets%2Faf73134f805550e9ebd7a422bea59a77 +0 -0
  82. data/test/dummy/tmp/cache/assets/D48/CD0/sprockets%2Fbc8d07d3da016d76b744f35fd1b76797 +0 -0
  83. data/test/dummy/tmp/cache/assets/D52/1C0/sprockets%2Fdfac94984609e75ff28ccf1355f520d5 +0 -0
  84. data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +0 -0
  85. data/test/dummy/tmp/cache/assets/D74/DA0/sprockets%2Fa3677e4caf2ff11891e85a2fd37d624b +0 -0
  86. data/test/dummy/tmp/cache/assets/D83/650/sprockets%2F377ee3574e6b7a6961a870cd90e9afcf +0 -0
  87. data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
  88. data/test/dummy/tmp/cache/assets/DC9/0F0/sprockets%2F80fcaf8fc7c8b1cc04aef35313a84b65 +0 -0
  89. data/test/dummy/tmp/cache/assets/DD2/D70/sprockets%2Fbc1de009791757d84fc047cdcb87ceba +0 -0
  90. data/test/dummy/tmp/cache/assets/DEF/3C0/sprockets%2Fa6da5fcafbea0bd73346b47e21407cd6 +0 -0
  91. data/test/dummy/tmp/cache/assets/DF8/550/sprockets%2F9bb580e4aaccde7aa60e189a15f95a5a +0 -0
  92. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  93. data/test/hitchens_test.rb +7 -0
  94. data/test/integration/navigation_test.rb +10 -0
  95. data/test/test_helper.rb +10 -0
  96. metadata +340 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2011 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Hitchens
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Hitchens'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+ Bundler::GemHelper.install_tasks
28
+
29
+ require 'rake/testtask'
30
+
31
+ Rake::TestTask.new(:test) do |t|
32
+ t.libs << 'lib'
33
+ t.libs << 'test'
34
+ t.pattern = 'test/**/*_test.rb'
35
+ t.verbose = false
36
+ end
37
+
38
+
39
+ task :default => :test
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,34 @@
1
+ .CodeRay {
2
+ background-color: #232323;
3
+ border: 1px solid black;
4
+ font-family: 'Courier New', 'Terminal', monospace;
5
+ color: #E6E0DB;
6
+ padding: 3px 5px;
7
+ overflow: auto;
8
+ font-size: 12px;
9
+ margin: 12px 10px;
10
+ border-radius: 10px;
11
+ }
12
+ .CodeRay pre {
13
+ margin: 0px;
14
+ padding: 0px;
15
+ }
16
+
17
+ .CodeRay .an { color:#E7BE69 } /* html attribute */
18
+ .CodeRay .c { color:#BC9358; font-style: italic; } /* comment */
19
+ .CodeRay .ch { color:#509E4F } /* escaped character */
20
+ .CodeRay .cl { color:#FFF } /* class */
21
+ .CodeRay .co { color:#FFF } /* constant */
22
+ .CodeRay .fl { color:#A4C260 } /* float */
23
+ .CodeRay .fu { color:#FFC56D } /* function */
24
+ .CodeRay .gv { color:#D0CFFE } /* global variable */
25
+ .CodeRay .i { color:#A4C260 } /* integer */
26
+ .CodeRay .il { background:#151515 } /* inline code */
27
+ .CodeRay .iv { color:#D0CFFE } /* instance variable */
28
+ .CodeRay .pp { color:#E7BE69 } /* doctype */
29
+ .CodeRay .r { color:#CB7832 } /* keyword */
30
+ .CodeRay .rx { color:#A4C260 } /* regex */
31
+ .CodeRay .s { color:#A4C260 } /* string */
32
+ .CodeRay .sy { color:#6C9CBD } /* symbol */
33
+ .CodeRay .ta { color:#E7BE69 } /* html tag */
34
+ .CodeRay .pc { color:#6C9CBD } /* boolean */
@@ -0,0 +1,6 @@
1
+ .pagination {
2
+ padding: 1em 0;
3
+ .disabled {
4
+ display: none;
5
+ }
6
+ }
@@ -0,0 +1,17 @@
1
+ module Hitchens
2
+ class ApplicationController < ActionController::Base
3
+ check_authorization
4
+ load_and_authorize_resource
5
+ layout Hitchens.use_parent_layout ? 'application' : 'hitchens/application'
6
+
7
+ def current_ability
8
+ # we need to tell CanCan to use our Hitchens::Ability class
9
+ @current_ability ||= Ability.new(get_current_user)
10
+ end
11
+
12
+ private
13
+ def get_current_user
14
+ __send__ Hitchens.current_user_helper_name
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ module Hitchens
2
+ class PostsController < ApplicationController
3
+ def index
4
+ @posts = @posts.page(params[:page]).per_page(Hitchens.posts_per_page)
5
+ @posts = PostDecorator.decorate @posts
6
+ end
7
+
8
+ def show
9
+ @post = PostDecorator.decorate @post
10
+ end
11
+
12
+ def create
13
+ if @post.save
14
+ redirect_to posts_path
15
+ else
16
+ render 'new'
17
+ end
18
+ end
19
+ def update
20
+ if @post.update_attributes params[:post]
21
+ redirect_to posts_path
22
+ else
23
+ render 'edit'
24
+ end
25
+ end
26
+
27
+ def new
28
+ end
29
+ def edit
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,25 @@
1
+ module Hitchens
2
+ class ApplicationDecorator < Draper::Base
3
+ def markdown(text)
4
+ syntax_highlighter(markdown_parser.render(text)).html_safe
5
+ end
6
+
7
+ private
8
+ def markdown_parser
9
+ @@parser ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML,
10
+ :autolink => true, :space_after_headers => true,
11
+ :fenced_code_blocks => true)
12
+ end
13
+
14
+ def syntax_highlighter(html)
15
+ doc = Nokogiri::HTML(html)
16
+ doc.search("code").each do |pre|
17
+ code_ray = CodeRay.scan(pre.text.rstrip, pre[:class]).div
18
+ # first line of code wasn't indented as much as others
19
+ # need to add a line break after the pre tag
20
+ pre.replace code_ray.sub('<pre>', "<pre>\n")
21
+ end
22
+ doc.to_s
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ module Hitchens
2
+ class PostDecorator < ApplicationDecorator
3
+ decorates 'Hitchens::Post'
4
+
5
+ def body_to_html
6
+ markdown(body)
7
+ end
8
+
9
+ def pubdate_tag
10
+ if publication_date
11
+ h.time_tag publication_date, pubdate_display, pubdate: true
12
+ else
13
+ "(not yet published)"
14
+ end
15
+ end
16
+
17
+ private
18
+ def pubdate_display
19
+ publication_date.getlocal.strftime("%A, %B %e, %Y at %l:%M %p")
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ module Hitchens
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,17 @@
1
+ module Hitchens
2
+ class Ability
3
+ include CanCan::Ability
4
+
5
+ def initialize(user)
6
+ user ||= Hitchens.user_class.new # guest user (not logged in)
7
+ if user.__send__ Hitchens.blog_admin_user_method
8
+ can :manage, :all
9
+ else
10
+ can :read, Post, Post.published do |post|
11
+ post.published
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,18 @@
1
+ module Hitchens
2
+ class Post < ActiveRecord::Base
3
+ default_scope order('publication_date desc')
4
+ scope :published, lambda{ where('publication_date < ?', Time.now) }
5
+
6
+ def published=(value)
7
+ if ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value)
8
+ self.publication_date = Time.now unless publication_date
9
+ else
10
+ self.publication_date = nil
11
+ end
12
+ end
13
+ def published
14
+ return false unless publication_date
15
+ publication_date < Time.now
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ = simple_form_for post do |f|
2
+ = f.input :title
3
+ = f.input :body
4
+ = f.input :published, as: :boolean
5
+ = f.submit 'save'
@@ -0,0 +1,5 @@
1
+ = content_tag_for :div, post do
2
+ %h2.title= post.title
3
+ %p.dateline= post.pubdate_tag
4
+ %p.body= post.body_to_html
5
+ = link_to 'Edit', edit_post_path(post) if can? :update, post
@@ -0,0 +1 @@
1
+ = render partial: 'form', locals: { post: @post }
@@ -0,0 +1,7 @@
1
+ = link_to 'new post', new_post_path if can? :create, @post
2
+ = render partial: 'post', collection: @posts
3
+ = will_paginate @posts,
4
+ previous_label: 'newer posts',
5
+ next_label: 'older posts',
6
+ page_links: false
7
+
@@ -0,0 +1,18 @@
1
+ xml.instruct! :xml, :version => "1.0"
2
+ xml.rss :version => "2.0" do
3
+ xml.channel do
4
+ xml.title Hitchens.blog_name
5
+ xml.description Hitchens.blog_description
6
+ xml.link posts_url(format: :rss)
7
+
8
+ @posts.each do |post|
9
+ xml.item do
10
+ xml.title post.title
11
+ xml.description post.body_to_html
12
+ xml.pubDate post.publication_date.to_s(:rfc822)
13
+ xml.link post_url(post)
14
+ xml.guid post_url(post)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1 @@
1
+ = render partial: 'form', locals: { post: @post }
@@ -0,0 +1 @@
1
+ = render @post
@@ -0,0 +1,10 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title Hitchens
5
+ = stylesheet_link_tag "hitchens/application"
6
+ = javascript_include_tag "hitchens/application"
7
+ = auto_discovery_link_tag(:rss, posts_url(format: :rss))
8
+ = csrf_meta_tags
9
+ %body
10
+ = yield
@@ -0,0 +1,93 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ # Components used by the form builder to generate a complete input. You can remove
4
+ # any of them, change the order, or even add your own components to the stack.
5
+ # config.components = [ :placeholder, :label_input, :hint, :error ]
6
+
7
+ # Default tag used on hints.
8
+ # config.hint_tag = :span
9
+
10
+ # CSS class to add to all hint tags.
11
+ # config.hint_class = :hint
12
+
13
+ # CSS class used on errors.
14
+ # config.error_class = :error
15
+
16
+ # Default tag used on errors.
17
+ # config.error_tag = :span
18
+
19
+ # Method used to tidy up errors.
20
+ # config.error_method = :first
21
+
22
+ # Default tag used for error notification helper.
23
+ # config.error_notification_tag = :p
24
+
25
+ # CSS class to add for error notification helper.
26
+ # config.error_notification_class = :error_notification
27
+
28
+ # ID to add for error notification helper.
29
+ # config.error_notification_id = nil
30
+
31
+ # You can wrap all inputs in a pre-defined tag.
32
+ # config.wrapper_tag = :div
33
+
34
+ # CSS class to add to all wrapper tags.
35
+ # config.wrapper_class = :input
36
+
37
+ # CSS class to add to the wrapper if the field has errors.
38
+ # config.wrapper_error_class = :field_with_errors
39
+
40
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
41
+ # config.collection_wrapper_tag = nil
42
+
43
+ # You can wrap each item in a collection of radio/check boxes with a tag, defaulting to span.
44
+ # config.item_wrapper_tag = :span
45
+
46
+ # Series of attempts to detect a default label method for collection.
47
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
48
+
49
+ # Series of attempts to detect a default value method for collection.
50
+ # config.collection_value_methods = [ :id, :to_s ]
51
+
52
+ # How the label text should be generated altogether with the required text.
53
+ # config.label_text = lambda { |label, required| "#{required} #{label}" }
54
+
55
+ # You can define the class to use on all labels. Default is nil.
56
+ # config.label_class = nil
57
+
58
+ # You can define the class to use on all forms. Default is simple_form.
59
+ # config.form_class = :simple_form
60
+
61
+ # Whether attributes are required by default (or not). Default is true.
62
+ # config.required_by_default = true
63
+
64
+ # Tell browsers whether to use default HTML5 validations (novalidate option).
65
+ # Default is enabled.
66
+ # config.browser_validations = true
67
+
68
+ # Determines whether HTML5 types (:email, :url, :search, :tel) and attributes
69
+ # (e.g. required) are used or not. True by default.
70
+ # Having this on in non-HTML5 compliant sites can cause odd behavior in
71
+ # HTML5-aware browsers such as Chrome.
72
+ # config.html5 = true
73
+
74
+ # Custom mappings for input types. This should be a hash containing a regexp
75
+ # to match as key, and the input type that will be used when the field name
76
+ # matches the regexp as value.
77
+ # config.input_mappings = { /count/ => :integer }
78
+
79
+ # Collection of methods to detect if a file type was given.
80
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
81
+
82
+ # Default priority for time_zone inputs.
83
+ # config.time_zone_priority = nil
84
+
85
+ # Default priority for country inputs.
86
+ # config.country_priority = nil
87
+
88
+ # Default size for text inputs.
89
+ # config.default_input_size = 50
90
+
91
+ # When false, do not use translations for labels, hints or placeholders.
92
+ # config.translate = true
93
+ end
@@ -0,0 +1,24 @@
1
+ en:
2
+ simple_form:
3
+ "yes": 'Yes'
4
+ "no": 'No'
5
+ required:
6
+ text: 'required'
7
+ mark: '*'
8
+ # You can uncomment the line below if you need to overwrite the whole required html.
9
+ # When using html, text and mark won't be used.
10
+ # html: '<abbr title="required">*</abbr>'
11
+ error_notification:
12
+ default_message: "Some errors were found, please take a look:"
13
+ # Labels and hints examples
14
+ # labels:
15
+ # password: 'Password'
16
+ # user:
17
+ # new:
18
+ # email: 'E-mail para efetuar o sign in.'
19
+ # edit:
20
+ # email: 'E-mail.'
21
+ # hints:
22
+ # username: 'User name to sign in.'
23
+ # password: 'No special characters, please.'
24
+
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ Hitchens::Engine.routes.draw do
2
+ resources :posts
3
+ root :to => 'posts#index'
4
+ end
@@ -0,0 +1,11 @@
1
+ class CreateHitchensPosts < ActiveRecord::Migration
2
+ def change
3
+ create_table :hitchens_posts do |t|
4
+ t.text :body
5
+ t.string :title
6
+ t.datetime :publication_date
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module Hitchens
2
+ class Engine < Rails::Engine
3
+ isolate_namespace Hitchens
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Hitchens
2
+ VERSION = "0.0.1"
3
+ end
data/lib/hitchens.rb ADDED
@@ -0,0 +1,34 @@
1
+ # dependencies - is this necessary?
2
+ require 'haml'
3
+ require 'simple_form'
4
+ require 'draper'
5
+ require 'redcarpet'
6
+ require 'cancan'
7
+ require 'nokogiri'
8
+ require 'coderay'
9
+ require 'will_paginate'
10
+
11
+ require 'hitchens/engine'
12
+
13
+ module Hitchens
14
+ mattr_accessor :blog_name,
15
+ :blog_description,
16
+ :posts_per_page,
17
+ :use_parent_layout,
18
+ :user_class_name,
19
+ :current_user_helper_name,
20
+ :blog_admin_user_method
21
+
22
+ #TODO: set these up in the Hitchens initializer file
23
+ self.blog_name = "Ian's test blog"
24
+ self.blog_description = "Just a thing about stuff"
25
+ self.use_parent_layout = true
26
+ self.posts_per_page = 5
27
+ self.user_class_name = 'User'
28
+ self.current_user_helper_name = 'current_user'
29
+ self.blog_admin_user_method = 'blog_admin?'
30
+
31
+ def self.user_class
32
+ user_class_name.constantize
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :hitchens do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,13 @@
1
+ <%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
2
+ <%%= f.error_notification %>
3
+
4
+ <div class="inputs">
5
+ <%- attributes.each do |attribute| -%>
6
+ <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
7
+ <%- end -%>
8
+ </div>
9
+
10
+ <div class="actions">
11
+ <%%= f.button :submit %>
12
+ </div>
13
+ <%% end %>
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,9 @@
1
+ class User < ActiveRecord::Base
2
+ # Include default devise modules. Others available are:
3
+ # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
4
+ devise :database_authenticatable, :registerable,
5
+ :recoverable, :rememberable, :trackable, :validatable
6
+
7
+ # Setup accessible (or protected) attributes for your model
8
+ attr_accessible :email, :password, :password_confirmation, :remember_me
9
+ end
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+ <p>
11
+ <% if current_user %>
12
+ <%= link_to 'sign out', main_app.destroy_user_session_path, method: 'delete' %>
13
+ <% else %>
14
+ <%= link_to 'sign in', main_app.new_user_session_path %>
15
+ <% end %>
16
+ </p>
17
+ <h1> PARENT LAYOUT </h1>
18
+
19
+ <%= yield %>
20
+
21
+ </body>
22
+ </html>
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require
6
+ require "hitchens"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Custom directories with classes and modules you want to be autoloadable.
15
+ # config.autoload_paths += %W(#{config.root}/extras)
16
+
17
+ # Only load the plugins named here, in the order given (default is alphabetical).
18
+ # :all can be used as a placeholder for all plugins not explicitly named.
19
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
20
+
21
+ # Activate observers that should always be running.
22
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
23
+
24
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
+ # config.time_zone = 'Central Time (US & Canada)'
27
+
28
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
+ # config.i18n.default_locale = :de
31
+
32
+ # Configure the default encoding used in templates for Ruby 1.9.
33
+ config.encoding = "utf-8"
34
+
35
+ # Configure sensitive parameters which will be filtered from the log file.
36
+ config.filter_parameters += [:password]
37
+
38
+ # Enable the asset pipeline
39
+ config.assets.enabled = true
40
+
41
+ # Version of your assets, change this if you want to expire all your assets
42
+ config.assets.version = '1.0'
43
+ end
44
+ end
45
+