Permalink
Browse files

Merge branch 'master' of github.com:jipiboily/monologue

Conflicts:
	README.md
  • Loading branch information...
2 parents 0b30084 + 0451e44 commit c0c68ecab0ccf951bb648715a2ecf6d31364ce65 Jean-Philippe Boily committed Oct 11, 2012
View
@@ -2,16 +2,19 @@
(for upgrade informations, see UPGRADE.md)
## 0.2.0.beta
+- **IMPORTANT: add cache management config and UI. [Please review the new config options](https://github.com/jipiboily/monologue/wiki/Configure-Monologue's-cache)!**
+- first extension available: [monologue-markdown](https://github.com/jipiboily/monologue-markdown)
- add tags
- add a UI to manage current user's account (welcome in 2012, you can now change your password!)
- add RSS icon
- add social icons
-- add Gauge (http://gaug.es) for analytics
+- add [Gaug.es](http://gaug.es) tags
- there is now a sidebar: you can put the latest posts, tweets or whatever you want! Kinda simple system but efficient enough for now. Included: tag cloud, categories (tag), latest posts and tweets.
- front page articles are now more cleverly truncated
- a few Deface hooks (data-monologue attribute) were added to the admin layout (for the menu)
- update admin UI with newest Twitter Boostrap (v2.1.1)
- visual look has been slightly updated **(Hey, designers, want to help on Monologue next design? You're "hired"!)** [Preview](http://screencast.com/t/6Ua49p2TdqP)
+- add support for Twitter Cards (https://dev.twitter.com/docs/cards)
- deprecate Ruby 1.8 (you should really upgrade, 2.0 is about to get real and Rails 4 won't run on Ruby 1.8)
- lot of bug fixed
View
@@ -10,20 +10,24 @@ Monologue is a basic mountable blogging engine in Rails built to be easily mount
[Issues and bugs](http://github.com/jipiboily/monologue/issues)
[Wiki](https://github.com/jipiboily/monologue/wiki/_pages)
-## Features
-- Rails mountable engine (fully named spaced)
+## Here are a few features
+- Rails mountable engine (fully named spaced and mountable in an already existing app)
- tested
- back to basics: few features
- it has post revisions (no UI to choose published revision yet, but it keeps your modification history)
+- tags (or categories)
+- RSS
+- support for Google Analytics and Gaug.es tags
- few external dependencies (no Devise or Sorcery, etc…) so we don't face problem integrating with existing Rails app.([Rails mountable engines: dependency nightmare?](http://jipiboily.com/2012/rails-mountable-engines-dependency-nightmare))
-- comments handled by disqus
-- enforcing [Rails cache](http://edgeguides.rubyonrails.org/caching_with_rails.html) for better performance (only support file store for now)
-- runs on Heroku
+- comments are handled by [disqus](http://disqus.com/)
+- enforcing [Rails cache](http://edgeguides.rubyonrails.org/caching_with_rails.html) for better performance (only support file store for now). [Read this to enable it](https://github.com/jipiboily/monologue/wiki/Configure-Monologue's-cache).
+- more in the [CHANGELOG](https://github.com/jipiboily/monologue/blob/master/CHANGELOG.md)
+
+- bonus: there is a `[monologue-markdown](https://github.com/jipiboily/monologue-markdown)` extension
### missing features
-- categories
- UI for posts revisions and to manage user
-- much more…see issues!
+- see [roadmap](https://github.com/jipiboily/monologue/wiki/Roadmap)!
## Installation
@@ -72,16 +76,7 @@ config.action_controller.perform_caching = false
```
## Enable caching
-Just turn perform_caching to true in your environment config file (`config/environment/{environment}.rb):
-```ruby
-config.action_controller.perform_caching = true
-```
-
-**IMPORTANT**: if monologue is mounted at root ("/"), you must also add that in your `routes.rb` file, before the monologue mount:
-
-```ruby
-root to: 'monologue/posts#index'
-```
+[See full caching doc here.](https://github.com/jipiboily/monologue/wiki/Configure-Monologue's-cache)
## Customization
See the [Wiki - Customizations](https://github.com/jipiboily/monologue/wiki/Customizations).
@@ -4,7 +4,6 @@ class window.TwitterWidget
@latest_tweets = $("#latest_tweets")
@callback: (data) ->
@dom_cache()
- console.log data
for tweet in data
@add_tweet(tweet)
@add_tweet: (tweet) ->
@@ -0,0 +1,27 @@
+class Monologue::Admin::CacheController < Monologue::Admin::BaseController
+ before_filter :prepare_file_list
+
+ def show
+ if ActionController::Base.perform_caching && Monologue::PageCache.enabled && Monologue::PageCache.wipe_enabled && ActionController::Base.page_cache_directory != Rails.public_path
+ render :show
+ else
+ render :how_to_enable
+ end
+ end
+
+ def destroy
+ Monologue::TotalSweeper.wipe_all
+ flash.notice = I18n.t("monologue.admin.cache.show.cache_wiped")
+ render :show
+ end
+
+ private
+ def prepare_file_list
+ @files = []
+ Dir.glob("#{ActionController::Base.page_cache_directory}/**/*").each do |file|
+ next if File.directory?(file)
+ @files << file.gsub(ActionController::Base.page_cache_directory,"")
+ end
+ @files
+ end
+end
@@ -25,13 +25,16 @@ def not_found
render :action => "404", :status => 404, :formats => [:html]
end
end
-
-
+
private
def current_user
@monologue_current_user ||= Monologue::User.find(session[:monologue_user_id]) if session[:monologue_user_id]
end
-
- helper_method :current_user
+
+ def monologue_page_cache_enabled?
+ current_user.nil? && Monologue::PageCache.enabled
+ end
+
+ helper_method :current_user, :monologue_page_cache_enabled?
end
@@ -1,11 +1,11 @@
class Monologue::PostsController < Monologue::ApplicationController
- caches_page :index, :show, :feed , :if => Proc.new { current_user.nil? }
+ caches_page :index, :show, :feed , :if => Proc.new { monologue_page_cache_enabled? }
def index
@page = params[:page].nil? ? 1 : params[:page]
@posts = Monologue::Post.published.page(@page)
end
-
+
def show
if current_user
post = Monologue::Post.default.where("monologue_posts_revisions.url = :url", {:url => params[:post_url]}).first
@@ -18,7 +18,7 @@ def show
end
@revision = post.active_revision
end
-
+
def feed
@posts = Monologue::Post.published.limit(25)
end
@@ -1,5 +1,5 @@
class Monologue::TagsController < Monologue::ApplicationController
- caches_page :show , :if => Proc.new { current_user.nil? }
+ caches_page :show , :if => Proc.new { monologue_page_cache_enabled? }
def show
@tag = Monologue::Tag.find_by_name(params[:tag])
if @tag
@@ -48,6 +48,11 @@ def facebook_icon
social_icon("facebook", Monologue.facebook_url, Monologue.facebook_url)
end
+ def absolute_image_url(url)
+ return url if url.starts_with? "http"
+ request.protocol + request.host + url
+ end
+
# TODO: That should be move in TagHelper if I manage to get that loaded
def tag_url(tag)
"#{Monologue::Engine.routes.url_helpers.root_path}tags/#{tag.name.downcase}"
@@ -1,8 +1,15 @@
class Monologue::PostsSweeper < ActionController::Caching::Sweeper
observe Monologue::Post
-
def sweep(post)
+ if ActionController::Base.perform_caching && Monologue::PageCache.enabled && Monologue::PageCache.wipe_enabled && Monologue::PageCache.wipe_after_save && (ActionController::Base.page_cache_directory != Rails.public_path)
+ Monologue::TotalSweeper.wipe_all
+ else
+ sweep_for_single_post post
+ end
+ end
+
+ def sweep_for_single_post post
return unless post.published
root_path = Monologue::Engine.routes.url_helpers.root_path if root_path.nil? # TODO: why do I have to do this to make tests pass? There must be something much more clean to make tests pass
page_cache_directory = Rails.public_path if page_cache_directory.nil? # TODO: we should not need this either...
@@ -0,0 +1,5 @@
+class Monologue::TotalSweeper
+ def self.wipe_all
+ FileUtils.rm_rf(Dir.glob("#{ActionController::Base.page_cache_directory}/*")) if ActionController::Base.perform_caching && Monologue::PageCache.enabled && Monologue::PageCache.wipe_enabled && (ActionController::Base.page_cache_directory != Rails.public_path)
+ end
+end
@@ -15,7 +15,11 @@
</li>
</ul>
<ul class="nav pull-right" data-monologue="nav-bar-right">
-
+ <% if ActionController::Base.perform_caching %>
+ <li class="<%= request.fullpath === admin_cache_path ? "active":"" %>">
+ <%= link_to t(".cache"), admin_cache_path %>
+ </li>
+ <% end %>
<li id="fat-menu" class="dropdown">
<a href="#" id="settings" data-toggle="dropdown"><%= t(".settings") %> <b class="caret"></b></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="settings">
@@ -1,4 +1,7 @@
<meta property="og:title" content="<%= monologue_accurate_title %>"/>
<meta property="og:type" content="<%= controller.action_name == "show" ? "article" : "blog" %>"/>
<meta property="og:url" content="http://<%= request.host_with_port %><%= request.path.gsub("//","/") %>"/>
-<meta property="og:site_name" content="<%= Monologue.site_name %>"/>
+<meta property="og:site_name" content="<%= Monologue.site_name %>"/>
+<% if Monologue.facebook_logo%>
+ <meta property="og:image" content="<%= absolute_image_url(image_path(Monologue.facebook_logo)) %>" />
+<% end %>
@@ -2,6 +2,7 @@
<meta charset="utf-8" />
<%= render "layouts/monologue/application/meta_description" %>
<%= render "layouts/monologue/application/fb_open_graph" %>
+<%= render "layouts/monologue/application/twitter_cards" %>
<meta name="keyword" content="<%=Monologue.meta_keyword%>">
<meta http-equiv="content-type" content="text/html;charset=utf-8">
@@ -0,0 +1,7 @@
+<meta name="twitter:card" content="summary">
+<% if Monologue.twitter_username %>
+ <meta name="twitter:site" content="<%= Monologue.twitter_username %>">
+<% end %>
+<meta name="twitter:url" content="http://<%= request.host_with_port %><%= request.path.gsub("//","/") %>">
+<meta name="twitter:title" content="<%= monologue_accurate_title %>">
+<meta name="twitter:description" content="<%= content_for?(:meta_description) ? yield(:meta_description) : Monologue.meta_description %>">
@@ -0,0 +1,18 @@
+<h1>Current config</h1>
+<p>Want to know more about those configs? See here: <%= link_to "Configure Monologue's cache (english only)", "https://github.com/jipiboily/monologue/wiki/Configure-Monologue's-cache", :target => "_blank" %></p>
+
+<div class="alert alert-<%= ActionController::Base.perform_caching ? "success" : "error" %>">
+ ActionController::Base.perform_caching = <%= ActionController::Base.perform_caching %>
+</div>
+
+<div class="alert alert-<%= ActionController::Base.page_cache_directory != Rails.public_path ? "success" : "error" %>">
+ ActionController::Base.page_cache_directory = <%= ActionController::Base.page_cache_directory %>
+</div>
+
+<div class="alert alert-<%= Monologue::PageCache.enabled ? "success" : "error" %>">
+ Monologue::PageCache.enabled = <%= Monologue::PageCache.enabled %>
+</div>
+
+<div class="alert alert-<%= Monologue::PageCache.wipe_enabled ? "success" : "error" %>">
+ Monologue::PageCache.wipe_enabled = <%= Monologue::PageCache.wipe_enabled %>
+</div>
@@ -0,0 +1,6 @@
+<div class="alert alert-block">
+ <h4><%= t(".warning") %></h4>
+ <%= t(".explanations") %>
+</div>
+
+<%= render "config" %>
@@ -0,0 +1,26 @@
+<h1><%= t(".title") %></h1>
+
+<p><%= t(".description") %></p>
+
+<hr>
+
+<h2><%= t(".delete") %></h2>
+<%= link_to t(".delete"), admin_cache_path, :data => {:confirm => t(".confirm")}, :method => :delete, :class => "btn btn-large btn-danger" %>
+
+<hr>
+
+<h2><%= t(".files_in_cache") %></h2>
+<% if @files.any? %>
+ <ul>
+ <% @files.each do |file| %>
+ <% next if File.directory?(file) %>
+ <li><%= file.gsub(ActionController::Base.page_cache_directory,"") %></li>
+ <% end %>
+ </ul>
+<% else %>
+ <p><%= t(".no_files_are_cached") %></p>
+<% end %>
+
+<hr>
+
+<%= render "config" %>
View
@@ -107,6 +107,18 @@ en:
show:
recent_comments:
"Recent comments"
+ cache:
+ show:
+ title: "Manage cache"
+ description: "You can completely wipe cache here."
+ files_in_cache: "Here are the files actually cached:"
+ no_files_are_cached: "There are actually no file in cache."
+ delete: "Completely wipe cache?"
+ confirm: 'Are you sure you want to competely clear cache?'
+ cache_wiped: "Cache was wiped!"
+ how_to_enable:
+ warning: "You can't manage cache!"
+ explanations: "There are certain settings that are not set correctly to be able to use Monologue's basic cache. Please review configuration documentation."
sessions:
new:
title:
@@ -134,6 +146,7 @@ en:
"List of monologues"
comments:
"Comments"
+ cache: "Manage cache"
edit_user_info: "My account"
settings: "Settings"
log_out:
View
@@ -103,6 +103,18 @@ fr:
"Aperçu"
tags:
"Catégories<br/><i>Séparer les catégories par des virgules</i>"
+ cache:
+ show:
+ title: "Gérer la cache"
+ description: "Vous pouvez complètement effacer la cache ici."
+ files_in_cache: "Voici les fichiers en cache:"
+ no_files_are_cached: "Il n'y a aucun fichier en cache."
+ delete: "Effacer complètement la cache?"
+ confirm: 'Voulez-vous vraiment effacer la cache?'
+ cache_wiped: "La cache a été effacée!"
+ how_to_enable:
+ warning: "Vous ne pouvez gérer la cache!"
+ explanations: "Il y a certaines configurations à effectuer pour utiliser la gestion de cache de base de Monologue. SVP voir la documentation ci-dessous (anglais seulement)."
comments:
show:
recent_comments:
@@ -134,6 +146,7 @@ fr:
"Liste des monologues"
comments:
"Commentaires"
+ cache: "Gérer la cache"
edit_user_info: "Mon compte"
settings: "Paramètres"
log_out:
View
@@ -13,6 +13,9 @@
resources :posts
resources :users
get "comments" => "comments#show", :as => "comments"
+
+ get "cache" => "cache#show", :as => "cache"
+ delete "cache" => "cache#destroy"
end
match "*post_url" => "posts#show", :as => "post"
View
@@ -15,6 +15,7 @@ module Monologue
:facebook_like_locale,
:facebook_url,
+ :facebook_logo, #used in the open graph protocol to display an image when a post is liked
:google_plus_account_url,
:google_plusone_locale,
@@ -29,4 +30,8 @@ module Monologue
:gauge_analytics_site_id,
:layout,
:sidebar
+end
+
+module Monologue::PageCache
+ mattr_accessor :enabled, :wipe_enabled, :wipe_after_save
end
Oops, something went wrong.

0 comments on commit c0c68ec

Please sign in to comment.