diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..dfe07704 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore index f80f8803..a373c1e4 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,10 @@ coverage/ .idea/ .idea/**/* -Gemfile.lock \ No newline at end of file +Gemfile.lock +*.lock + +.ruby-version +.rbenv-version +.rvmrc + diff --git a/.rbenv-version b/.rbenv-version deleted file mode 100644 index 0ca8caf7..00000000 --- a/.rbenv-version +++ /dev/null @@ -1 +0,0 @@ -1.9.3-p327 diff --git a/.rvmrc b/.rvmrc deleted file mode 100644 index 90364e8e..00000000 --- a/.rvmrc +++ /dev/null @@ -1 +0,0 @@ -rvm use 1.9.3@monologue --create diff --git a/.travis.yml b/.travis.yml index 24ca7ee6..f8244a11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,21 @@ language: ruby + before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start - mv spec/dummy/config/database-travis.yml spec/dummy/config/database.yml - bundle exec rake db:create db:migrate + rvm: - - 1.9.3 - 2.0.0 + - 2.1.0 + +gemfile: + - spec/support/gemfiles/rails4_0.gemfile + - spec/support/gemfiles/rails4_1.gemfile + +sudo: false + env: - DB=mysql DB_USERNAME=root - - DB=postgresql DB_USERNAME=postgres \ No newline at end of file + - DB=postgresql DB_USERNAME=postgres diff --git a/Gemfile b/Gemfile index 29865c5a..98f4b88e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source "http://rubygems.org" +source "https://rubygems.org" # Declare your gem's dependencies in monologue.gemspec. # Bundler will treat runtime dependencies like base dependencies, and @@ -16,7 +16,8 @@ gemspec group :development, :test do gem "thin" - gem 'rails', '>= 4.0.4' + gem 'rails', '= 4.2.7' + gem 'responders', '~> 2.0' gem 'pry' if RUBY_PLATFORM.downcase.include?("darwin") @@ -26,5 +27,5 @@ group :development, :test do end gem 'coveralls', require: false - gem 'pg' +gem 'turbolinks' diff --git a/README.md b/README.md index 6952b0f0..44642eba 100644 --- a/README.md +++ b/README.md @@ -6,27 +6,26 @@ **THIS README IS FOR THE MASTER BRANCH AND REFLECTS THE WORK CURRENTLY EXISTING ON THE MASTER BRANCH. IF YOU ARE WISHING TO USE A NON-MASTER BRANCH OF MONOLOGUE, PLEASE CONSULT THAT BRANCH'S README AND NOT THIS ONE.** -- +**NOT MAINTAINED ANYMORE**: This project hasn't been maintained for a while. It's pretty basic and should still work. Chances are issues and PRs might not receive the attention they deserve, at least, not quickly, if at all. -Monologue is a basic mountable blogging engine in Rails built to be easily mounted in an already existing Rails app, but it can also be used alone. +Monologue is a basic, mountable blogging engine in Rails built to be easily mounted in an already existing Rails app, but it can also be used alone. ## Version -This README is for a future Monologue version, that will be 0.4.X and be Rails 4 specific. See other branches for other versions (0-3-stable being the latest stable version). +This README is for the latest version of Monologue (0-5-stable being the latest stable version). ## Upgrade and changes -To know how to upgrade, see [UPGRADE.md](https://github.com/jipiboily/monologue/blob/master/UPGRADE.md) file. If you want to know what changed since the last versions, see [CHANGELOG.md](https://github.com/jipiboily/monologue/blob/master/CHANGELOG.md). +To learn how to upgrade, see [UPGRADE.md](https://github.com/jipiboily/monologue/blob/master/UPGRADE.md) file. If you want to learn what changed since the last versions, see [CHANGELOG.md](https://github.com/jipiboily/monologue/blob/master/CHANGELOG.md). ## Questions? Problems? Documentation? - [Mailing list for questions](http://groups.google.com/forum/#!forum/monologue-rb) - [Issues and bugs](http://github.com/jipiboily/monologue/issues) - [Wiki](https://github.com/jipiboily/monologue/wiki/_pages) -- IRC channel (on Freenode): #monologue. ## Some features -- Rails mountable engine (fully named spaced and mountable in an already existing app) +- Rails mountable engine (fully namespaced and mountable in an already existing app) - tested - back to basics: few features - tags (or categories) @@ -46,15 +45,15 @@ To know how to upgrade, see [UPGRADE.md](https://github.com/jipiboily/monologue/ ## Installation -### 1. Add the gem to your `Gemfile`. This will get the latest version compatible with Rails 4 until we release a gem +### 1. Add the gem to your `Gemfile`. ```ruby -gem 'monologue', github: 'jipiboily/monologue' +gem 'monologue' ``` And run `bundle install` to fetch the gem and update your 'Gemfile.lock'. ### 2. Route to Monologue -Add this to your route file (`config/route.rb`) +Add this to your route file (`config/routes.rb`) ```ruby # This line mounts Monologue's routes at the root of your application. # This means, any requests to URLs such as /my-post, will go to Monologue::PostsController. @@ -70,33 +69,37 @@ be available at `/monologue`. ### 3. Migrate Monologue's database tables Run these commands: -1. $`bundle exec rake monologue:install:migrations` -2. $`bundle exec rake db:create` (only if this is a new project) -3. $`bundle exec rake db:migrate` +1. $`bin/rake monologue:install:migrations` +2. $`bin/rake db:create` (only if this is a new project) +3. $`bin/rake db:migrate` ### 4. Create a user -Open your development console with `rails c`, then: +Open your development console with `bin/rails c`, then: ```ruby Monologue::User.create(name: "monologue", email:"monologue@example.com", password:"my-password", password_confirmation: "my-password") ``` ### 5. Configure Monologue. -This is all done in an initializer file, say `config/initializers/monologue.rb`. More on this in the [Wiki - Configuration](https://github.com/jipiboily/monologue/wiki/Configuration). +This is all done in an initializer file, typically `config/initializers/monologue.rb`. More on this in the [Wiki - Configuration](https://github.com/jipiboily/monologue/wiki/Configuration). ### 6. Ready -Start your server and head on [http://localhost:3000/monologue](http://localhost:3000/monologue) to log in the admin section. +Start your server and go to [http://localhost:3000/monologue](http://localhost:3000/monologue) to log in the admin section. ### Note to users -Monologue is using his own tables. If you want to use your own tables with monologue (for example the User table) -this might help you to monkey patch [Monkey Patch](https://gist.github.com/jipiboily/776d907fc932640ac59a) +Monologue is using its own tables. If you want to use your own tables with monologue (for example the User table) +this might help you to [monkey patch](https://gist.github.com/jipiboily/776d907fc932640ac59a). ## Customization See the [Wiki - Customizations](https://github.com/jipiboily/monologue/wiki/Customizations). +## Copy views +copy views like devise `rails g monologue:views` +or use scope: `rails g monologue:views blog` + ## Requirements -- Rails 4.0.4 + +- Rails 4.2.1 + - Database: MySQL & Postgres are supported but other databases might work too. ## Authors @@ -124,7 +127,8 @@ Starting point: * Fork the repo * Clone your repo * Run `bundle install` -* Run `bundle exec rake test_app` to create the test application in `spec/dummy` +* Run `bundle exec rake db:migrate` +* Run `bundle exec rake db:setup` * Make your changes * Ensure specs pass by running `bundle exec rspec spec` * Submit your pull request diff --git a/UPGRADE.md b/UPGRADE.md index 3c1f6027..d425b093 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,4 +1,7 @@ # Upgrade Monologue +## 0.4.0 to 0.5.0 + - No update required + ## 0.3.0 to 0.4.0 - Change of syntax for configuration. Please use Monologue::Config instead of the old Monologue module diff --git a/app/assets/javascripts/monologue/admin/application.js b/app/assets/javascripts/monologue/admin/application.js index 9fff8a52..fa7d9a21 100644 --- a/app/assets/javascripts/monologue/admin/application.js +++ b/app/assets/javascripts/monologue/admin/application.js @@ -11,7 +11,6 @@ //= require monologue/bootstrap/bootstrap-datepicker-fr //= require monologue/bootstrap/bootstrap-datepicker-pt //= require monologue/bootstrap/bootstrap-datepicker-es -//= require ckeditor/override //= require ckeditor/init //= require monologue/admin/ckeditor-config //= require monologue/admin/posts diff --git a/app/assets/javascripts/monologue/admin/ckeditor-config.js b/app/assets/javascripts/monologue/admin/ckeditor-config.js index d5918dc0..74d7c3ec 100644 --- a/app/assets/javascripts/monologue/admin/ckeditor-config.js +++ b/app/assets/javascripts/monologue/admin/ckeditor-config.js @@ -18,4 +18,5 @@ $(function() { { name: 'colors', items : [ 'TextColor','BGColor' ] }, { name: 'tools', items : [ 'Maximize', 'ShowBlocks' ] } ]; -}); \ No newline at end of file + CKEDITOR.config.disableNativeSpellChecker = false; +}()); \ No newline at end of file diff --git a/app/controllers/monologue/admin/posts_controller.rb b/app/controllers/monologue/admin/posts_controller.rb index 3f842deb..65786267 100644 --- a/app/controllers/monologue/admin/posts_controller.rb +++ b/app/controllers/monologue/admin/posts_controller.rb @@ -3,7 +3,8 @@ class Monologue::Admin::PostsController < Monologue::Admin::BaseController before_filter :load_post, only: [:edit, :update] def index - @posts = Monologue::Post.default + @page = params[:page].nil? ? 1 : params[:page] + @posts = Monologue::Post.listing_page(@page).includes(:user) end def new diff --git a/app/controllers/monologue/posts_controller.rb b/app/controllers/monologue/posts_controller.rb index f1d3c0b0..e4263514 100644 --- a/app/controllers/monologue/posts_controller.rb +++ b/app/controllers/monologue/posts_controller.rb @@ -1,7 +1,7 @@ class Monologue::PostsController < Monologue::ApplicationController def index @page = params[:page].nil? ? 1 : params[:page] - @posts = Monologue::Post.page(@page).published + @posts = Monologue::Post.page(@page).includes(:user).published end def show @@ -17,5 +17,10 @@ def show def feed @posts = Monologue::Post.published.limit(25) + if params[:tags].present? + tags = Monologue::Tag.where(name: params[:tags].split(",")).pluck(:id) + @posts = @posts.joins(:taggings).where("monologue_taggings.tag_id in (?)", tags) + end + render 'feed', layout: false end end diff --git a/app/models/monologue/post.rb b/app/models/monologue/post.rb index b9afb56e..8f11e69a 100644 --- a/app/models/monologue/post.rb +++ b/app/models/monologue/post.rb @@ -37,11 +37,11 @@ def published_in_future? end def self.page p - per_page = Monologue::Config.posts_per_page || 10 - set_total_pages(per_page) - p = (p.nil? ? 0 : p.to_i - 1) - offset = p * per_page - self.limit(per_page).offset(offset) + paged_results(p, Monologue::Config.posts_per_page || 10, false) + end + + def self.listing_page(p) + paged_results(p, Monologue::Config.admin_posts_per_page || 50, true) end def self.total_pages @@ -54,6 +54,17 @@ def self.set_total_pages per_page private + def self.paged_results(p, per_page, admin) + set_total_pages(per_page) + p = (p.nil? ? 0 : p.to_i - 1) + offset = p * per_page + if admin + default.limit(per_page).offset(offset) + else + limit(per_page).offset(offset) + end + end + def generate_url return unless self.url.blank? year = self.published_at.class == ActiveSupport::TimeWithZone ? self.published_at.year : DateTime.now.year @@ -63,5 +74,4 @@ def generate_url def url_do_not_start_with_slash errors.add(:url, I18n.t("activerecord.errors.models.monologue/post.attributes.url.start_with_slash")) if self.url.start_with?("/") end - end diff --git a/app/views/layouts/monologue/admin.html.erb b/app/views/layouts/monologue/admin.html.erb index e05d28af..8c691ac6 100644 --- a/app/views/layouts/monologue/admin.html.erb +++ b/app/views/layouts/monologue/admin.html.erb @@ -12,7 +12,7 @@ <% end %>
<% flash.each do |name, msg| %> - <%= content_tag :div, msg, id: "flash_#{name}", class: (name == :notice ? "alert alert-info" : "alert alert-error") %> + <%= content_tag :div, msg, id: "flash_#{name}", class: (name == 'notice' ? "alert alert-info" : "alert alert-error") %> <% end %> <%= yield %> diff --git a/app/views/layouts/monologue/application.html.erb b/app/views/layouts/monologue/application.html.erb index 4d624d93..c6b052c3 100644 --- a/app/views/layouts/monologue/application.html.erb +++ b/app/views/layouts/monologue/application.html.erb @@ -35,4 +35,4 @@ <%= render 'layouts/monologue/application/disqus' %> <%= render 'layouts/monologue/application/gauge_analytics' %> - \ No newline at end of file + diff --git a/app/views/monologue/admin/posts/_pagination.html.erb b/app/views/monologue/admin/posts/_pagination.html.erb new file mode 100644 index 00000000..3d9b406b --- /dev/null +++ b/app/views/monologue/admin/posts/_pagination.html.erb @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/app/views/monologue/admin/posts/index.html.erb b/app/views/monologue/admin/posts/index.html.erb index d1871bde..e3c4869b 100644 --- a/app/views/monologue/admin/posts/index.html.erb +++ b/app/views/monologue/admin/posts/index.html.erb @@ -20,3 +20,7 @@ <% end %> + +<% if @page %> + <%= render partial: "pagination" %> +<% end %> \ No newline at end of file diff --git a/app/views/monologue/posts/_post.html.erb b/app/views/monologue/posts/_post.html.erb index 14066fb2..64396c21 100644 --- a/app/views/monologue/posts/_post.html.erb +++ b/app/views/monologue/posts/_post.html.erb @@ -1,12 +1,12 @@ -
+
<%= render partial: 'monologue/posts/post_header', locals: {post: post} %>
- <%= truncate_html(post.content, length: 1000, omission: '...') %> + <%= truncate_html(post.content, length: Monologue::Config.preview_size, omission: '...') %>
<%= render post.tags %>
<%= link_to t(".readmore"), post.full_url, class: "button" %> -
\ No newline at end of file +
diff --git a/app/views/monologue/posts/_social_sharing.html.erb b/app/views/monologue/posts/_social_sharing.html.erb index 17fd7c60..d2340c52 100644 --- a/app/views/monologue/posts/_social_sharing.html.erb +++ b/app/views/monologue/posts/_social_sharing.html.erb @@ -1,51 +1,17 @@ - +
+ + +
diff --git a/app/views/monologue/posts/social/_facebook.html.erb b/app/views/monologue/posts/social/_facebook.html.erb new file mode 100644 index 00000000..6672d4d9 --- /dev/null +++ b/app/views/monologue/posts/social/_facebook.html.erb @@ -0,0 +1,12 @@ +<% if Monologue::Config.facebook_app_id.present? %> +
+ +
+<% end %> \ No newline at end of file diff --git a/app/views/monologue/posts/social/_gplus.html.erb b/app/views/monologue/posts/social/_gplus.html.erb new file mode 100644 index 00000000..4f6df5a1 --- /dev/null +++ b/app/views/monologue/posts/social/_gplus.html.erb @@ -0,0 +1,16 @@ +
+ + + +
\ No newline at end of file diff --git a/app/views/monologue/posts/social/_pinterest.html.erb b/app/views/monologue/posts/social/_pinterest.html.erb new file mode 100644 index 00000000..f2a097e1 --- /dev/null +++ b/app/views/monologue/posts/social/_pinterest.html.erb @@ -0,0 +1,16 @@ +<% if Monologue::Config.use_pinterest.presence %> +<%= link_to"Pin It", + "http://pinterest.com/pin/create/button/?url=#{@post.url}", + :class => "pin-it-button", + "count-layout" => "none" %> + + +<% end %> \ No newline at end of file diff --git a/app/views/monologue/posts/social/_twitter.html.erb b/app/views/monologue/posts/social/_twitter.html.erb new file mode 100644 index 00000000..ed6bcc1d --- /dev/null +++ b/app/views/monologue/posts/social/_twitter.html.erb @@ -0,0 +1,18 @@ +<% if Monologue::Config.twitter_username.present? %> + " + data-url="<%= request.protocol %><%= request.host_with_port %><%= request.path.gsub("//", "/") %>" + data-via="<%= Monologue::Config.twitter_username %>" + data-text="<%= @post.title %>" + data-count="horizontal">Tweet + + +<% end %> \ No newline at end of file diff --git a/app/views/monologue/sidebar/_latest_tweets.html.erb b/app/views/monologue/sidebar/_latest_tweets.html.erb index a7de6ba1..9c598e55 100644 --- a/app/views/monologue/sidebar/_latest_tweets.html.erb +++ b/app/views/monologue/sidebar/_latest_tweets.html.erb @@ -3,6 +3,6 @@ - + Tweets by <%= Monologue::Config.twitter_username %> <% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/monologue/tags/_tag.html.erb b/app/views/monologue/tags/_tag.html.erb index 78a4065b..a15971fe 100644 --- a/app/views/monologue/tags/_tag.html.erb +++ b/app/views/monologue/tags/_tag.html.erb @@ -1 +1 @@ -<%=link_to tag.name, tag_url(tag) %> \ No newline at end of file +<%=link_to tag.name, tag_url(tag) %> diff --git a/config/locales/de.yml b/config/locales/de.yml index 4df86f55..6a6c49eb 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -58,6 +58,7 @@ de: published: "Yes" not_published: "Nicht veröffentlicht" status: "Veröffentlichen ?" + author: "Autor" new: header: "Neuer Monologue" create: @@ -127,7 +128,6 @@ de: blank: "'Veröffentlichen am' wird benötigt" url: start_with_slash: "URL darf nicht mit einem Schrägstrich anfangen ('/')" - monologue/user: blank: "%{attribute} wird benötigt" taken: "%{attribute} wurde schon benutzt" diff --git a/config/locales/en.yml b/config/locales/en.yml index 87e0339a..48800b8c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -58,6 +58,7 @@ en: published: "Yes" not_published: "Not published" status: "Published ?" + author: "Author" new: header: "New monologue" create: @@ -127,7 +128,6 @@ en: blank: "'Published at' is required" url: start_with_slash: "URL can't start with a slash ('/')" - monologue/user: blank: "%{attribute} is required" taken: "%{attribute} has already been taken" diff --git a/config/locales/es.yml b/config/locales/es.yml index c93622b3..3753e9ed 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -58,6 +58,7 @@ es: published: "Sí" not_published: "No publicado" status: "Publicado?" + author: "Autor" new: header: "Nuevo artículo" create: @@ -139,7 +140,6 @@ es: blank: "'Publicado en' es obligatorio" url: start_with_slash: "URL no puede empezar con '/'" - monologue/user: blank: "%{attribute} es obligatorio" taken: "%{attribute} ya está en uso" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 937059a9..998a9c15 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -56,6 +56,7 @@ fr: published: "Oui" not_published: "Non publié" status: "Publié ?" + author: "Auteur" new: header: "Nouveau monologue" create: diff --git a/config/locales/it.yml b/config/locales/it.yml index 3bfcea9f..1735f0a1 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -58,6 +58,7 @@ it: published: "Sì" not_published: "Non pubblicato" status: "Pubblicato ?" + author: "Autore" new: header: "Nuovo monologue" create: diff --git a/config/locales/pt.yml b/config/locales/pt-BR.yml similarity index 99% rename from config/locales/pt.yml rename to config/locales/pt-BR.yml index 13857ae0..0b1ecb0e 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt-BR.yml @@ -1,4 +1,4 @@ -pt_BR: +pt-BR: monologue: posts: pagination: @@ -58,6 +58,7 @@ pt_BR: published: "Sim" not_published: "Não publicado" status: "Publicado?" + author: "Autor" new: header: "Novo blog post" create: diff --git a/config/locales/ro.yml b/config/locales/ro.yml index 6b81c842..a2c5a554 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -58,6 +58,7 @@ ro: published: "Da" not_published: "Nu e publicat" status: "Publicat ?" + author: "Autor" new: header: "Articol nou" create: diff --git a/config/locales/tr.yml b/config/locales/tr.yml index c1185b2b..14354848 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -58,6 +58,7 @@ tr: published: "Evet" not_published: "Yayınlanmadı" status: "Yayınlandı mı?" + author: "Yazar" new: header: "Yeni monolog" create: diff --git a/config/routes.rb b/config/routes.rb index a8098464..e916f677 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,6 +7,7 @@ namespace :admin, path: "monologue" do get "/" => "posts#index", as: "" # responds to admin_url and admin_path + get "/page/:page", to: "posts#index", as: "posts_page" get "logout" => "sessions#destroy" get "login" => "sessions#new" resources :sessions diff --git a/lib/generators/monologue/views_generator.rb b/lib/generators/monologue/views_generator.rb new file mode 100644 index 00000000..9849db73 --- /dev/null +++ b/lib/generators/monologue/views_generator.rb @@ -0,0 +1,27 @@ +require "rails/generators/base" + +module Monologue + module Generators + class ViewsGenerator < Rails::Generators::Base + desc "Copies Monologue views to your application." + argument :scope, required: false, default: nil, + desc: "The scope to copy views to" + source_root File.expand_path("../../../../app/views", __FILE__) + + def copy_views + view_directory :layouts + view_directory :monologue + end + + protected + + def view_directory(name) + directory name.to_s, "#{target_path}/#{name}" + end + + def target_path + @target_path ||= "app/views/#{scope || ''}" + end + end + end +end diff --git a/lib/monologue/configuration.rb b/lib/monologue/configuration.rb index 7bd0c690..259ed97e 100644 --- a/lib/monologue/configuration.rb +++ b/lib/monologue/configuration.rb @@ -3,34 +3,43 @@ class Configuration include ConfigurationExtensions attr_accessor :disqus_shortname, - :site_name, - :site_subtitle, - :site_url, - :meta_description, - :meta_keyword, + :site_name, + :site_subtitle, + :site_url, + :meta_description, + :meta_keyword, - :show_rss_icon, + :show_rss_icon, - :twitter_username, - :twitter_locale, + :twitter_username, + :twitter_locale, - :facebook_like_locale, - :facebook_url, - :facebook_logo, #used in the open graph protocol to display an image when a post is liked + :facebook_like_locale, + :facebook_url, + :facebook_logo, #used in the open graph protocol to display an image when a post is liked + :facebook_app_id, - :google_plus_account_url, - :google_plusone_locale, + :google_plus_account_url, + :google_plusone_locale, - :linkedin_url, + :use_pinterest, #display pinterest? - :github_username, + :linkedin_url, - :admin_force_ssl, - :posts_per_page, - :google_analytics_id, - :gauge_analytics_site_id, - :layout, - :sidebar + :github_username, + + :admin_force_ssl, + :posts_per_page, + :admin_posts_per_page, + :google_analytics_id, + :gauge_analytics_site_id, + :layout, + :sidebar, + :preview_size + + def initialize + @preview_size = 1000; + end end diff --git a/lib/monologue/engine.rb b/lib/monologue/engine.rb index 846bb762..7033a64c 100644 --- a/lib/monologue/engine.rb +++ b/lib/monologue/engine.rb @@ -4,6 +4,7 @@ require "jquery-rails" require "sass-rails" require "coffee-rails" +require "responders" module Monologue class Engine < Rails::Engine @@ -20,6 +21,7 @@ class Engine < Rails::Engine app.config.assets.precompile += %w[ monologue/admin/ckeditor-config.js ckeditor/* + *.eot* *.woff *.ttf ] end diff --git a/lib/monologue/version.rb b/lib/monologue/version.rb index 46f8e3ef..ec480612 100644 --- a/lib/monologue/version.rb +++ b/lib/monologue/version.rb @@ -1,3 +1,3 @@ module Monologue - VERSION = "0.4.1" + VERSION = "0.5.0" end diff --git a/monologue.gemspec b/monologue.gemspec index e0486fa6..7eb214e6 100644 --- a/monologue.gemspec +++ b/monologue.gemspec @@ -15,14 +15,16 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib,vendor}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md", "deprecations.rb"] - s.add_dependency "rails", ">= 4.0.4" + s.add_dependency "rails", "= 4.2.7" s.add_dependency "bcrypt", '~> 3.1.7' - s.add_dependency "coffee-rails",'~> 4.0.0' - s.add_dependency "sass-rails",'~> 4.0.0' + s.add_dependency "coffee-rails",'>= 4.0.0' s.add_dependency "truncate_html" s.add_dependency "jquery-rails" - s.add_dependency "ckeditor",'~> 4.0.11' + s.add_dependency 'rails-i18n' + s.add_dependency "ckeditor",'~> 4.1.1' s.add_dependency 'select2-rails', '~> 3.2' + s.add_dependency "sass-rails",'~> 5.0.0' + s.add_dependency "responders", '~> 2.1.0' s.add_development_dependency "rspec-rails", "~> 2.8" s.add_development_dependency 'factory_girl_rails', '~> 1.4.0' diff --git a/spec/dummy/config/initializers/monologue.rb b/spec/dummy/config/initializers/monologue.rb index bf5e6464..4f451b47 100644 --- a/spec/dummy/config/initializers/monologue.rb +++ b/spec/dummy/config/initializers/monologue.rb @@ -29,6 +29,8 @@ c.twitter_username = "jipiboily" c.facebook_url = "https://www.facebook.com/jipiboily" c.facebook_logo = 'logo.png' + c.facebook_app_id="123465" + c.use_pinterest= true c.google_plus_account_url = "https://plus.google.com/u/1/115273180419164295760/posts" c.linkedin_url = "http://www.linkedin.com/in/jipiboily" c.github_username = "jipiboily" diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index a9688909..7fdd63ac 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -43,31 +43,79 @@ describe "social icons+links" do context "render if enabled" do it "generate rss tag for " do - helper.rss_head_link.should eq "" + helper.rss_head_link.should have_css( + "link", + href: "http://test.host/feed", + rel: "alternate", + title: "RSS", + type: "application/rss+xml" + ) end it "generate rss icon" do - helper.rss_icon.should eq "" + helper.rss_icon.should have_css( + "a", + href: "http://test.host/feed", + class: "social", + target: "_blank" + ) + + helper.rss_icon.should have_css("i", class: "foundicon-rss") end it "generate github" do - helper.github_icon.should eq "" + helper.github_icon.should have_css( + "a", + href: "http://github.com/#{Monologue::Config.github_username}", + class: "social", + target: "_blank" + ) + + helper.github_icon.should have_css("i", class: "foundicon-github") end it "generate twitter" do - helper.twitter_icon.should eq "" + helper.twitter_icon.should have_css( + "a", + href: "http://twitter.com/#{Monologue::Config.twitter_username}", + class: "social", + target: "_blank" + ) + + helper.twitter_icon.should have_css("i", class: "foundicon-twitter") end it "generate linkedin" do - helper.linkedin_icon.should eq "" + helper.linkedin_icon.should have_css( + "a", + href: "#{Monologue::Config.linkedin_url}", + class: "social", + target: "_blank" + ) + + helper.linkedin_icon.should have_css("i", class: "foundicon-linkedin") end it "generate googleplus" do - helper.googleplus_icon.should eq "" + helper.googleplus_icon.should have_css( + "a", + href: "#{Monologue::Config.google_plus_account_url}", + class: "social", + target: "_blank" + ) + + helper.googleplus_icon.should have_css("i", class: "foundicon-google-plus") end it "generate facebook" do - helper.facebook_icon.should eq "" + helper.facebook_icon.should have_css( + "a", + href: "#{Monologue::Config.facebook_url}", + class: "social", + target: "_blank" + ) + + helper.facebook_icon.should have_css("i", class: "foundicon-facebook") end end @@ -147,4 +195,4 @@ end end -end \ No newline at end of file +end diff --git a/spec/requests/admin/posts_spec.rb b/spec/requests/admin/posts_spec.rb index c89782f1..0adc94f0 100644 --- a/spec/requests/admin/posts_spec.rb +++ b/spec/requests/admin/posts_spec.rb @@ -10,6 +10,14 @@ visit admin_posts_path page.should have_content "Add a monologue" end + + it "can access post's admin with pagination" do + Factory(:post, title: "my first title") + Factory(:post, title: "my second title") + Monologue::Config.admin_posts_per_page = 1 + visit admin_posts_page_path page: 1 + page.should have_content "Older Posts" + end it "can create new post" do visit new_admin_post_path diff --git a/spec/requests/feed_spec.rb b/spec/requests/feed_spec.rb index d75a7ac5..626e1066 100644 --- a/spec/requests/feed_spec.rb +++ b/spec/requests/feed_spec.rb @@ -4,10 +4,33 @@ before(:each) do Factory(:post, url: "url/to/post") end - + # test to prevent regression for issue #72 it "should contain full" do visit feed_path page.should have_content "/monologue/url/to/post" end + + context "with tags param" do + before do + create(:post, title: "Feed Post").tag!(["feed"]) + create(:post, title: "Rss Post").tag!(["rss"]) + end + + context "with tags" do + it "returns posts tagged with tags" do + visit feed_path(tags: "feed,rss") + page.should have_content "Feed Post" + page.should have_content "Rss Post" + end + end + + context "without tags" do + it "returns all posts" do + visit feed_path(tags: "") + page.should have_content "Feed Post" + page.should have_content "Rss Post" + end + end + end end \ No newline at end of file diff --git a/spec/requests/posts_spec.rb b/spec/requests/posts_spec.rb index d423796c..e44a440c 100644 --- a/spec/requests/posts_spec.rb +++ b/spec/requests/posts_spec.rb @@ -5,9 +5,11 @@ end it "lists posts" do + Factory(:post, title: "post Y") visit "/monologue" page.should have_content("post X") + page.should have_content("post Y") end it "should route to a post" do @@ -31,4 +33,10 @@ visit root_path page.should_not have_content "I am Marty McFly" end -end \ No newline at end of file + + it "should not show an unpublished post" do + Factory(:post, published: false, title: "I am Marty McFly") + visit root_path + page.should_not have_content "I am Marty McFly" + end +end diff --git a/spec/support/gemfiles/rails4_0.gemfile b/spec/support/gemfiles/rails4_0.gemfile new file mode 100644 index 00000000..24b43003 --- /dev/null +++ b/spec/support/gemfiles/rails4_0.gemfile @@ -0,0 +1,18 @@ +source "https://rubygems.org" + +gemspec :path => "../../../" + +group :development, :test do + gem "thin" + gem 'rails', '>= 4.0.4' + gem 'pry' + + if RUBY_PLATFORM.downcase.include?("darwin") + gem 'rb-fsevent' + gem 'growl' + end +end + +gem 'coveralls', require: false + +gem 'pg' diff --git a/spec/support/gemfiles/rails4_1.gemfile b/spec/support/gemfiles/rails4_1.gemfile new file mode 100644 index 00000000..c568229c --- /dev/null +++ b/spec/support/gemfiles/rails4_1.gemfile @@ -0,0 +1,18 @@ +source "https://rubygems.org" + +gemspec :path => "../../../" + +group :development, :test do + gem "thin" + gem 'rails', '>= 4.1.0' + gem 'pry' + + if RUBY_PLATFORM.downcase.include?("darwin") + gem 'rb-fsevent' + gem 'growl' + end +end + +gem 'coveralls', require: false + +gem 'pg'