forked from lobsters/lobsters
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first stab at planet rss aggregation
could probably use a prettier layout and auto-posting a weblog url to the main site (carrying tags)
- Loading branch information
Showing
17 changed files
with
407 additions
and
101 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
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
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
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
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,24 @@ | ||
class WeblogsController < ApplicationController | ||
before_filter { @page = page } | ||
|
||
WEBLOGS_PER_PAGE = 10 | ||
|
||
def index | ||
@pages = (Weblog.count / WEBLOGS_PER_PAGE.to_f).ceil | ||
if @page > @pages | ||
@page = @pages | ||
end | ||
@show_more = @page < @pages | ||
|
||
@weblogs = Weblog.order("created_at DESC"). | ||
offset((@page - 1) * WEBLOGS_PER_PAGE). | ||
limit(WEBLOGS_PER_PAGE) | ||
|
||
render :action => "index" | ||
end | ||
|
||
private | ||
def page | ||
params[:page].to_i > 0 ? params[:page].to_i : 1 | ||
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
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
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,9 @@ | ||
class Weblog < ActiveRecord::Base | ||
belongs_to :user | ||
|
||
serialize :tags, Array | ||
|
||
def sanitized_content | ||
Loofah.fragment(self.content).scrub!(:strip).scrub!(:nofollow).to_s.html_safe | ||
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
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,63 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | ||
<link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon.png" /> | ||
<link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon.png" /> | ||
<link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-144.png" /> | ||
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144.png" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="robots" content="noarchive,noodp,noydir" /> | ||
<meta name="referrer" content="always" /> | ||
<% if @short_url %> | ||
<link rev="canonical" rel="self alternate shorter shorturl shortlink" | ||
href="<%= @short_url %>" /> | ||
<% end %> | ||
<title><%= @title.present? ? "#{@title} | " : "" %>Planet <%= | ||
Rails.application.name %></title> | ||
<%= stylesheet_link_tag "application", :media => "all" %> | ||
<% if @user %> | ||
<%= javascript_include_tag "application" %> | ||
<script> | ||
Lobsters.curUser = '<%= @user.id %>'; | ||
</script> | ||
<% end %> | ||
<%= csrf_meta_tags %> | ||
</head> | ||
<body> | ||
<div id="wrapper"> | ||
<div id="header"> | ||
<div id="headerleft"> | ||
<a id="l_holder" style="background-color: #<%= sprintf("%02x%02x%02x", | ||
[ 255, (@traffic * 7).floor + 50.0 ].min, 0, 0) %>;" href="/" | ||
title="<%= Rails.application.name %> (<%= @traffic.to_i %>)"></a> | ||
<span id="headertitle"> | ||
<a href="/">Planet <%= Rails.application.name %></a> | ||
</span> | ||
</div> | ||
|
||
<div id="headerright"> | ||
<span class="headerlinks"> | ||
<a href="<%= main_root_url %>"><%= Rails.application.name %></a> | ||
</span> | ||
</div> | ||
|
||
<div class="clear"></div> | ||
</div> | ||
|
||
<div id="inside"> | ||
<% if flash[:error] %> | ||
<div class="flash-error"><%= flash[:error] %></div> | ||
<% elsif flash[:success] %> | ||
<div class="flash-success"><%= flash[:success] %></div> | ||
<% end %> | ||
|
||
<%= yield %> | ||
|
||
<div class="clear"></div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
|
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
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,44 @@ | ||
<ol class="stories list"> | ||
<% @weblogs.each do |weblog| %> | ||
<li class="story"> | ||
<div class="story_liner"> | ||
<div class="details"> | ||
<span class="link"> | ||
<a href="<%= weblog.url %>"><%= weblog.title %></a> | ||
</span> | ||
<span class="tags"> | ||
<% weblog.tags.map{|t| t.downcase }.sort.each do |tag| %> | ||
<a href="<%= main_root_url %>t/<%= tag %>" class="tag"><%= tag %></a> | ||
<% end %> | ||
</span> | ||
<span class="domain"> | ||
<a href="<%= weblog.site_url %>"><%= weblog.site_title %></a> | ||
</span> | ||
<div class="byline"> | ||
by <a href="<%= main_root_url %>u/<%= weblog.user.username %>"><%= | ||
weblog.user.username %></a> | ||
<%= raw(time_ago_in_words_label(weblog.created_at). | ||
gsub(/^about /, "")) %> ago | ||
</div> | ||
</div> | ||
</div> | ||
<div class="story_content weblog_content shorten_first_p"> | ||
<%= weblog.sanitized_content %> | ||
</div> | ||
</li> | ||
<% end %> | ||
</ol> | ||
|
||
<div class="morelink"> | ||
<% if @page && @page > 1 %> | ||
<a href="/<%= @page == 2 ? "" : "page/#{@page - 1}" %>"><< Page | ||
<%= @page - 1 %></a> | ||
<% end %> | ||
|
||
<% if @show_more %> | ||
<% if @page && @page > 1 %> | ||
| | ||
<% end %> | ||
<a href="/page/<%= @page + 1 %>">Page <%= @page + 1 %> >></a> | ||
<% end %> | ||
</div> |
Oops, something went wrong.