parlez 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/Gemfile +16 -0
  2. data/Gemfile.lock +91 -0
  3. data/README.markdown +19 -0
  4. data/Rakefile +57 -0
  5. data/VERSION +1 -0
  6. data/app/controllers/application_controller.rb +3 -0
  7. data/app/controllers/parlez/admin/base_controller.rb +3 -0
  8. data/app/controllers/parlez/admin/comments_controller.rb +20 -0
  9. data/app/controllers/parlez/admin/posts_controller.rb +51 -0
  10. data/app/controllers/parlez/auth_controller.rb +9 -0
  11. data/app/controllers/parlez/comments_controller.rb +17 -0
  12. data/app/controllers/parlez/posts_controller.rb +12 -0
  13. data/app/helpers/parlez_helper.rb +14 -0
  14. data/app/models/parlez/comment.rb +25 -0
  15. data/app/models/parlez/post.rb +26 -0
  16. data/app/views/layouts/application.html.haml +6 -0
  17. data/app/views/layouts/parlez_admin.html.haml +18 -0
  18. data/app/views/parlez/admin/_menu.html.haml +4 -0
  19. data/app/views/parlez/admin/comments/_comment.html.haml +4 -0
  20. data/app/views/parlez/admin/comments/_form.html.haml +9 -0
  21. data/app/views/parlez/admin/comments/edit.html.haml +4 -0
  22. data/app/views/parlez/admin/comments/index.html.haml +3 -0
  23. data/app/views/parlez/admin/posts/_form.html.haml +5 -0
  24. data/app/views/parlez/admin/posts/_post.html.haml +8 -0
  25. data/app/views/parlez/admin/posts/edit.html.haml +5 -0
  26. data/app/views/parlez/admin/posts/index.html.haml +3 -0
  27. data/app/views/parlez/admin/posts/new.html.haml +5 -0
  28. data/app/views/parlez/comments/_comment.html.haml +3 -0
  29. data/app/views/parlez/comments/_form.html.haml +9 -0
  30. data/app/views/parlez/comments/create.js.rjs +7 -0
  31. data/app/views/parlez/comments/index.html.haml +0 -0
  32. data/app/views/parlez/posts/_post.html.haml +2 -0
  33. data/app/views/parlez/posts/index.html.haml +2 -0
  34. data/app/views/parlez/posts/show.html.haml +10 -0
  35. data/config.ru +4 -0
  36. data/config/application.rb +44 -0
  37. data/config/boot.rb +13 -0
  38. data/config/database.yml +24 -0
  39. data/config/environment.rb +5 -0
  40. data/config/environments/development.rb +26 -0
  41. data/config/environments/production.rb +49 -0
  42. data/config/environments/test.rb +35 -0
  43. data/config/initializers/parlez.rb +27 -0
  44. data/config/locales/en.yml +5 -0
  45. data/config/routes.rb +13 -0
  46. data/db/migrate/01_setup_parlez.rb +32 -0
  47. data/db/schema.rb +41 -0
  48. data/db/seeds.rb +7 -0
  49. data/doc/README_FOR_APP +2 -0
  50. data/lib/generators/README +7 -0
  51. data/lib/generators/parlez_generator.rb +39 -0
  52. data/lib/parlez.rb +20 -0
  53. data/lib/parlez/email_validator.rb +21 -0
  54. data/lib/parlez/engine.rb +32 -0
  55. data/lib/parlez/form_builder.rb +57 -0
  56. data/lib/parlez/view_extensions.rb +17 -0
  57. data/lib/tasks/.gitkeep +0 -0
  58. data/parlez.gemspec +168 -0
  59. data/public/404.html +26 -0
  60. data/public/422.html +26 -0
  61. data/public/500.html +26 -0
  62. data/public/favicon.ico +0 -0
  63. data/public/javascripts/.gitkeep +0 -0
  64. data/public/javascripts/parlez/codemirror-lib.js +1 -0
  65. data/public/javascripts/parlez/codemirror.js +1 -0
  66. data/public/javascripts/parlez/jquery.slugify.js +31 -0
  67. data/public/javascripts/parlez/parlez.js +30 -0
  68. data/public/javascripts/parlez/rails.js +160 -0
  69. data/public/robots.txt +5 -0
  70. data/public/stylesheets/.gitkeep +0 -0
  71. data/public/stylesheets/parlez/codemirror/csscolors.css +36 -0
  72. data/public/stylesheets/parlez/codemirror/jscolors.css +36 -0
  73. data/public/stylesheets/parlez/codemirror/xmlcolors.css +32 -0
  74. data/public/stylesheets/parlez/forms.css +22 -0
  75. data/public/stylesheets/parlez/reset.css +41 -0
  76. data/public/stylesheets/parlez/structure.css +75 -0
  77. data/public/stylesheets/parlez/typography.css +44 -0
  78. data/public/stylesheets/sass/parlez/codemirror/csscolors.sass +37 -0
  79. data/public/stylesheets/sass/parlez/codemirror/jscolors.sass +37 -0
  80. data/public/stylesheets/sass/parlez/codemirror/xmlcolors.sass +33 -0
  81. data/public/stylesheets/sass/parlez/forms.sass +25 -0
  82. data/public/stylesheets/sass/parlez/reset.sass +43 -0
  83. data/public/stylesheets/sass/parlez/structure.sass +77 -0
  84. data/public/stylesheets/sass/parlez/typography.sass +50 -0
  85. data/script/rails +6 -0
  86. data/test/factories/comment.rb +35 -0
  87. data/test/factories/post.rb +7 -0
  88. data/test/functional/parlez/admin/comments_controller_test.rb +10 -0
  89. data/test/functional/parlez/admin/posts_controller_test.rb +90 -0
  90. data/test/functional/parlez/comments_controller_test.rb +10 -0
  91. data/test/functional/parlez/posts_controller_test.rb +19 -0
  92. data/test/integration/http_auth_test.rb +16 -0
  93. data/test/performance/browsing_test.rb +9 -0
  94. data/test/test_helper.rb +29 -0
  95. data/test/unit/helpers/parlez/admin/comments_helper_test.rb +4 -0
  96. data/test/unit/helpers/parlez/comments_helper_test.rb +4 -0
  97. data/test/unit/parlez/comment_test.rb +8 -0
  98. data/test/unit/parlez/post_test.rb +24 -0
  99. data/vendor/plugins/.gitkeep +0 -0
  100. metadata +262 -0
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '3.0.3'
4
+ gem 'mysql2'
5
+ gem 'haml'
6
+ gem 'active_link_to'
7
+ gem 'rakismet'
8
+
9
+ group :development do
10
+ gem 'jeweler'
11
+ end
12
+
13
+ group :test do
14
+ gem 'factory_girl', '= 2.0.0.beta1'
15
+ gem 'factory_girl_rails', '= 1.1.beta1'
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,91 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.3)
6
+ actionpack (= 3.0.3)
7
+ mail (~> 2.2.9)
8
+ actionpack (3.0.3)
9
+ activemodel (= 3.0.3)
10
+ activesupport (= 3.0.3)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.13)
16
+ rack-test (~> 0.5.6)
17
+ tzinfo (~> 0.3.23)
18
+ active_link_to (0.0.6)
19
+ activemodel (3.0.3)
20
+ activesupport (= 3.0.3)
21
+ builder (~> 2.1.2)
22
+ i18n (~> 0.4)
23
+ activerecord (3.0.3)
24
+ activemodel (= 3.0.3)
25
+ activesupport (= 3.0.3)
26
+ arel (~> 2.0.2)
27
+ tzinfo (~> 0.3.23)
28
+ activeresource (3.0.3)
29
+ activemodel (= 3.0.3)
30
+ activesupport (= 3.0.3)
31
+ activesupport (3.0.3)
32
+ arel (2.0.6)
33
+ builder (2.1.2)
34
+ erubis (2.6.6)
35
+ abstract (>= 1.0.0)
36
+ factory_girl (2.0.0.beta1)
37
+ factory_girl_rails (1.1.beta1)
38
+ factory_girl (~> 2.0.0.beta)
39
+ rails (>= 3.0.0)
40
+ git (1.2.5)
41
+ haml (3.0.25)
42
+ i18n (0.5.0)
43
+ jeweler (1.5.2)
44
+ bundler (~> 1.0.0)
45
+ git (>= 1.2.5)
46
+ rake
47
+ mail (2.2.13)
48
+ activesupport (>= 2.3.6)
49
+ i18n (>= 0.4.0)
50
+ mime-types (~> 1.16)
51
+ treetop (~> 1.4.8)
52
+ mime-types (1.16)
53
+ mysql2 (0.2.6)
54
+ polyglot (0.3.1)
55
+ rack (1.2.1)
56
+ rack-mount (0.6.13)
57
+ rack (>= 1.0.0)
58
+ rack-test (0.5.6)
59
+ rack (>= 1.0)
60
+ rails (3.0.3)
61
+ actionmailer (= 3.0.3)
62
+ actionpack (= 3.0.3)
63
+ activerecord (= 3.0.3)
64
+ activeresource (= 3.0.3)
65
+ activesupport (= 3.0.3)
66
+ bundler (~> 1.0)
67
+ railties (= 3.0.3)
68
+ railties (3.0.3)
69
+ actionpack (= 3.0.3)
70
+ activesupport (= 3.0.3)
71
+ rake (>= 0.8.7)
72
+ thor (~> 0.14.4)
73
+ rake (0.8.7)
74
+ rakismet (1.0.1)
75
+ thor (0.14.6)
76
+ treetop (1.4.9)
77
+ polyglot (>= 0.3.1)
78
+ tzinfo (0.3.23)
79
+
80
+ PLATFORMS
81
+ ruby
82
+
83
+ DEPENDENCIES
84
+ active_link_to
85
+ factory_girl (= 2.0.0.beta1)
86
+ factory_girl_rails (= 1.1.beta1)
87
+ haml
88
+ jeweler
89
+ mysql2
90
+ rails (= 3.0.3)
91
+ rakismet
data/README.markdown ADDED
@@ -0,0 +1,19 @@
1
+ Parlez is a blog engine for Rails 3.
2
+ ====================================
3
+
4
+ Parlez means 'Speak!' in French.
5
+
6
+ It is in active development and is currently very basic.
7
+ It provides an admin interface for creating a new post and viewing the comments on that post.
8
+ Currently, the front end of the blog is entirely up to you(ie. there are no 'themes'), but there are a couple of basic views set up.
9
+
10
+ Things left to do
11
+ -----------------
12
+
13
+ * Send comments to Akismet for spam filtering.
14
+ * Better admin UI/styling
15
+ * Better display of comments in the admin UI
16
+ * Improved handling of spam comments
17
+ * Improved documentation for creating front end views
18
+ * Improved documentation for the initializer options
19
+ * Better test coverage
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rubygems'
6
+ require 'rake'
7
+
8
+ Parlez::Application.load_tasks
9
+
10
+ begin
11
+ require 'jeweler'
12
+ Jeweler::Tasks.new do |gem|
13
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
14
+ gem.name = "parlez"
15
+ gem.homepage = "http://github.com/multiplegeorges/parlez"
16
+ gem.license = "MIT"
17
+ gem.summary = %Q{Parlez is a blog.}
18
+ gem.description = %Q{Parlez is french for 'Speak!'. It's also a blog which is also a Rails 3 Engine.}
19
+ gem.email = "parlez@georg.es"
20
+ gem.authors = ["Georges Gabereau"]
21
+ end
22
+ Jeweler::GemcutterTasks.new
23
+ rescue LoadError
24
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
25
+ end
26
+
27
+ # require 'rake/testtask'
28
+ # Rake::TestTask.new(:test) do |test|
29
+ # test.libs << 'lib' << 'test'
30
+ # test.pattern = 'test/**/test_*.rb'
31
+ # test.verbose = true
32
+ # end
33
+
34
+ # begin
35
+ # require 'rcov/rcovtask'
36
+ # Rcov::RcovTask.new do |test|
37
+ # test.libs << 'test'
38
+ # test.pattern = 'test/**/*.rb'
39
+ # test.verbose = true
40
+ # end
41
+ # rescue LoadError
42
+ # task :rcov do
43
+ # abort "RCov is not available."
44
+ # end
45
+ # end
46
+
47
+ # task :default => :test
48
+
49
+ require 'rake/rdoctask'
50
+ Rake::RDocTask.new do |rdoc|
51
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
52
+
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "parlez #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.3
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,3 @@
1
+ class Parlez::Admin::BaseController < (Parlez::Engine.config.admin_parent_class || Parlez::AuthController)
2
+ # FIXME: you should *really* implement some kind of authentication system here.
3
+ end
@@ -0,0 +1,20 @@
1
+ class Parlez::Admin::CommentsController < Parlez::Admin::BaseController
2
+ layout 'layouts/parlez_admin'
3
+
4
+ def index
5
+ @comments = Parlez::Comment.all
6
+ end
7
+
8
+ def edit
9
+ @comment = Parlez::Comment.find(params[:id])
10
+ rescue ActiveRecord::RecordNotFound
11
+ flash[:error] = 'Comment not found.'
12
+
13
+ end
14
+
15
+ def update
16
+ end
17
+
18
+ def destroy
19
+ end
20
+ end
@@ -0,0 +1,51 @@
1
+ class Parlez::Admin::PostsController < Parlez::Admin::BaseController
2
+ helper :parlez
3
+ layout 'layouts/parlez_admin'
4
+
5
+ def index
6
+ @posts = Parlez::Post.order('published_at DESC').all
7
+ end
8
+
9
+ def new
10
+ @post = Parlez::Post.new
11
+ end
12
+
13
+ def create
14
+ @post = Parlez::Post.create!(params[:parlez_post])
15
+ flash[:notice] = 'Post created!'
16
+ redirect_to :action => :index
17
+ rescue ActiveRecord::RecordInvalid => e
18
+ @post = e.record
19
+ flash[:error] = 'Please correct the errors below.'
20
+ render :action => :new
21
+ end
22
+
23
+ def edit
24
+ @post = Parlez::Post.find(params[:id])
25
+ end
26
+
27
+ def update
28
+ @post = Parlez::Post.find(params[:id])
29
+ @post.update_attributes!(params[:parlez_post])
30
+ flash[:notice] = 'Post saved!'
31
+ redirect_to :action => :index
32
+ rescue ActiveRecord::RecordInvalid => e
33
+ @post = e.record
34
+ flash[:error] = 'Please correct the errors below.'
35
+ render :action => :edit
36
+ rescue ActiveRecord::RecordNotFound
37
+ flash[:error] = 'Post not found!'
38
+ redirect_to :action => :index
39
+ end
40
+
41
+ def destroy
42
+ @post = Parlez::Post.find(params[:id])
43
+ @post.destroy
44
+ flash[:notice] = 'Post deleted.'
45
+ redirect_to :action => :index
46
+ rescue ActiveRecord::RecordNotFound
47
+ flash[:error] = 'Post not found!'
48
+ redirect_to :action => :index
49
+ end
50
+
51
+ end
@@ -0,0 +1,9 @@
1
+ class Parlez::AuthController < ApplicationController
2
+ before_filter :check_authentication
3
+ def check_authentication
4
+ authenticate_or_request_with_http_basic 'Parlez!' do |user, pw|
5
+ user == Parlez::Engine.config.username &&
6
+ pw == Parlez::Engine.config.password
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ class Parlez::CommentsController < ApplicationController
2
+
3
+ def create
4
+ @post = Parlez::Post.find(params[:parlez_comment][:post_id])
5
+ @comment = Parlez::Comment.create!(params[:parlez_comment])
6
+ # FIXME: Add Akismet checking here.
7
+ @comment.is_spam = false
8
+ @comment.save!
9
+ rescue ActiveRecord::RecordNotFound => e
10
+ flash[:error] = 'Post not found!'
11
+ redirect_to parlez_posts_path
12
+ rescue ActiveRecord::RecordInvalid => e
13
+ @comment = e.record
14
+ flash[:error] = 'Errors posting your comment!'
15
+ end
16
+
17
+ end
@@ -0,0 +1,12 @@
1
+ class Parlez::PostsController < ApplicationController
2
+ layout Parlez::Engine.config.layout
3
+
4
+ def index
5
+ @posts = Parlez::Post.published.order('published_at DESC').limit(Parlez::Engine.config.posts_per_page)
6
+ end
7
+
8
+ def show
9
+ @post = Parlez::Post.find(params[:id])
10
+ @comments = @post.comments.ham.order('updated_at DESC')
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ module ParlezHelper
2
+
3
+ def published_at_in_words(dt)
4
+ out = ""
5
+ distance = distance_of_time_in_words_to_now(dt)
6
+ long_ordinal = dt.to_formatted_s(:long_ordinal)
7
+ if dt.future?
8
+ out << 'Will be published ' << ((dt > 1.day.from_now) ? "on #{long_ordinal}" : "in #{distance}")
9
+ else
10
+ out << 'Was published ' << ((dt < 1.day.ago) ? "on #{long_ordinal}" : "#{distance} ago")
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,25 @@
1
+ class Parlez::Comment < ActiveRecord::Base
2
+ # TODO: Update this when isolated engines comes into play.
3
+ self.table_name_prefix = 'parlez_'
4
+
5
+ include Rakismet::Model
6
+
7
+ # Associations
8
+ belongs_to :post, :class_name => 'Parlez::Post'
9
+
10
+ # Scopes
11
+ scope :ham, where(:is_spam => false)
12
+ scope :spam, where(:is_spam => true)
13
+
14
+ # Validations
15
+ validates_presence_of :content, :message => 'You must include a comment!'
16
+ # validates :author_email, :presence => true, :email => true
17
+
18
+ # Class Methods
19
+
20
+ # Instance Methods
21
+ def permalink
22
+ post.permalink
23
+ end
24
+
25
+ end
@@ -0,0 +1,26 @@
1
+ class Parlez::Post < ActiveRecord::Base
2
+ # TODO: Update this when isolated engines comes into play.
3
+ self.table_name_prefix = 'parlez_'
4
+
5
+ # Associations
6
+ has_many :comments, :class_name => 'Parlez::Comment'
7
+
8
+ # Validations
9
+ [ :title, :slug, :author, :body, :published_at ].each do |attr|
10
+ validates_presence_of attr, :message => "#{attr.to_s.humanize} must be present."
11
+ end
12
+
13
+ # Scopes
14
+ scope :published, lambda{ where(['published_at < ?', DateTime.now]) }
15
+
16
+ # Class Methods
17
+
18
+ # Instance Methods
19
+ def permalink
20
+ 'Not yet implemented'
21
+ end
22
+
23
+ def to_param
24
+ "#{self.id}-#{self.slug}"
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ = javascript_include_tag 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js', 'parlez/rails'
5
+ %body
6
+ = yield
@@ -0,0 +1,18 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ %title Parlez
5
+ = stylesheet_link_tag :parlez, :cache => :parlez_styles
6
+ = javascript_include_tag :parlez, :cache => :parlez_js
7
+ = csrf_meta_tag
8
+
9
+ %body
10
+ .menu-container
11
+ = render :partial => 'parlez/admin/menu'
12
+ = yield :menu
13
+ .extras-container
14
+ .extras
15
+ = yield :extras
16
+ .content-container
17
+ .content
18
+ = yield
@@ -0,0 +1,4 @@
1
+ %ul.menu
2
+ %li= active_link_to 'Posts', parlez_admin_posts_path
3
+ %li= active_link_to 'Comments', parlez_admin_comments_path
4
+ = yield :menu_item
@@ -0,0 +1,4 @@
1
+ %p
2
+ = truncate comment.content, :length => 250
3
+ = comment.author
4
+ = comment.author_email
@@ -0,0 +1,9 @@
1
+ = f.text_field :user_ip
2
+ = f.text_field :user_agent
3
+ = f.text_field :referrer
4
+ = f.text_field :comment_type
5
+ = f.text_field :author
6
+ = f.text_field :author_email
7
+ = f.text_field :author_url
8
+ = f.rich_area :content
9
+ = f.text_field :is_spam
@@ -0,0 +1,4 @@
1
+ %h1 Editing a Comment
2
+ = parlez_form_for @comment, :url => parlez_admin_comment_path do |f|
3
+ = render :partial => 'form', :locals => {:f => f}
4
+ = f.submit 'Save changes'