forked from publify/publify
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a quick (and dirty) sidebar plugin that displays the 5 latest pu…
…blish statuses. This one should probably be renamed and we need to work on the overall statuses wording.
- Loading branch information
Frédéric de Villamil
committed
Aug 9, 2013
1 parent
0ec9868
commit a897e46
Showing
5 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
desc 'Default: run unit tests.' | ||
task :default => :test | ||
|
||
desc 'Test the statuses_sidebar plugin.' | ||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = true | ||
end | ||
|
||
desc 'Generate documentation for the statuses_sidebar plugin.' | ||
Rake::RDocTask.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'ArchivesSidebar' | ||
rdoc.options << '--line-numbers' << '--inline-source' | ||
rdoc.rdoc_files.include('README') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end |
17 changes: 17 additions & 0 deletions
17
lib/statuses_sidebar/app/views/statuses_sidebar/_content.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<% unless sidebar.statuses.blank? %> | ||
<style type='text/css'> | ||
.statuses_sidebar { | ||
border-bottom: #eee 1px solid; | ||
font-size: 0.9em; | ||
} | ||
</style> | ||
<h3 class="sidebar-title"><%= sidebar.title %></h3> | ||
<% sidebar.statuses.each do |status| %> | ||
<div class='statuses_sidebar'> | ||
<%= author_picture status %> | ||
<%= status.html(:body) %> | ||
<%= link_to_permalink(status, display_date_and_time(status.published_at)) %> | ||
<%= view_on_twitter status %> | ||
</div> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'sidebar' | ||
require 'statuses_sidebar' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class StatusesSidebar < Sidebar | ||
description 'Displays the latest statuses' | ||
setting :title, 'Statuses' | ||
setting :count, 5, :label => 'Number of statuses' | ||
|
||
attr_accessor :statuses | ||
|
||
def parse_request(contents, params) | ||
@statuses = Status.published.page(params[:page]).per(count) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'test/unit' | ||
require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
|
||
class ArchivesSidebarTest < Test::Unit::TestCase | ||
def test_sidebar_is_available | ||
assert Sidebar.available_sidebars.include?(ArchivesSidebar) | ||
end | ||
end |