Browse files

pushing recent updates

  • Loading branch information...
1 parent b69da10 commit d71eeefc78b79799b7a0fa0915f44b0ea37bf4ba @actsasflinn committed Sep 5, 2008
View
1 app/controllers/application.rb
@@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base
before_filter :stats
def stats
+ @top_tags = Tag.with_snippets.paginate(:page => 1, :order => 'taggings_count desc')
@top_languages = Language.with_snippets.paginate(:page => 1, :conditions => "snippets_count > 0", :order => 'snippets_count desc')
end
end
View
6 app/controllers/snippets_controller.rb
@@ -3,15 +3,17 @@ class SnippetsController < ApplicationController
# GET /snippets.xml
def index
if params[:q].blank?
- @snippets = Snippet.language(params[:language_id]).paginate(:page => params[:page], :include => :language, :order => 'snippets.created_at desc')
+ @snippets = Snippet.language(params[:language_id]).tag(params[:tag_id]).paginate(:page => params[:page], :include => [:taggings, :language], :order => 'snippets.created_at desc')
else
- @snippets = Snippet.search params[:q]
+ @snippets = Snippet.search(params[:q]).compact
end
@language = Language.find(params[:language_id]) unless params[:language_id].blank?
+ @tag = Tag.find(params[:tag_id]) unless params[:tag_id].blank?
respond_to do |format|
format.html # index.html.erb
+ format.rss # index.rss.builder
format.xml { render :xml => @snippets }
format.json { render :json => @snippets, :callback => params[:callback] }
end
View
14 app/views/layouts/_sidebar.html.erb
@@ -11,3 +11,17 @@
<%= link_to('All Languages', languages_path) %>
</div>
</div>
+
+<div id="top_tags">
+ <h3>Top Tags</h3>
+ <% @top_tags.each do |tag| %>
+ <% div_for(tag) do %>
+ <%= link_to(tag.name, tag_snippets_path(tag)) -%>
+ <%= total_for(tag.taggings_count) -%>
+ <% end %>
+ <% end %>
+
+ <div class="all">
+ <%= link_to('All Tags', tags_path) %>
+ </div>
+</div>
View
1 app/views/layouts/application.html.erb
@@ -12,6 +12,7 @@
<![endif]-->
<%= javascript_include_tag :defaults %>
+ <%= auto_discovery_link_tag(:rss, { :controller => 'snippets', :format => :rss }) %>
</head>
<body>
<div id="header">
View
6 app/views/snippets/about.html.erb
@@ -7,16 +7,16 @@
<h2>Author</h2>
- <p>It was written by <a href="http://actsasflinn.com/articles/2008/09/03/snippy-is-a-freaking-ripoff-of-pastie">Flinn Mueller</a> using Ruby on Rails 2.1 as a weekend project. I felt like one of the best features of Pastie is code highlighting so I made it a priority. Code highlighting is accomplished using a custom renderer with <a href="http://ultraviolet.rubyforge.org/">Ultraviolet</a>. The <a href="http://ts.freelancing-gods.com/">Thinking Sphinx</a> plugin has been on my radar for a little while now so I felt like it was a good time to throw that in.</p>
+ <p>It was written by <a href="http://actsasflinn.com/articles/2008/09/03/snippy-a-pastie-clone">Flinn Mueller</a> using Ruby on Rails 2.1 as a weekend project. I felt like one of the best features of Pastie is code highlighting so I made it a priority. Code highlighting is accomplished using a custom renderer with <a href="http://ultraviolet.rubyforge.org/">Ultraviolet</a>. The <a href="http://ts.freelancing-gods.com/">Thinking Sphinx</a> plugin has been on my radar for a little while now so I felt like it was a good time to throw that in.</p>
<h2>On Github</h2>
- <p>Git has also been on my radar for a little while. So I figured I would host the project at Github - everyone wins. Get the source on <a href="http://github.com/actsasflinn/snippy/tree/master">Github</a>.</p>
+ <p>Git has also been on my radar for a little while. So I figured I would host the project at Github - everyone wins. Get the source on <a href="https://github.com/actsasflinn/snippy/tree/master">Github</a>.</p>
<h2>Install</h2>
<ol>
- <li>git clone git://github.com/actsasflinn/snippy.git</li>
+ <li>git clone git@github.com:actsasflinn/snippy.git</li>
<li>cd snippy</li>
<li>cp config/database.yml.example config/database.yml</li>
<li>rake db:create</li>
View
5 app/views/snippets/index.html.erb
@@ -2,8 +2,9 @@
<span class="right"><%= will_paginate(@snippets) -%></span>
<h1><%=h @language.name unless @language.blank? -%>
- <%= "All" if @language.blank? && params[:q].blank? %>
- Snippets <%= "(&lsquo;#{h(params[:q])}&rsquo;)" unless params[:q].blank? %>
+ <%= "All" if @language.blank? && @tag.blank? && params[:q].blank? %>
+ Snippets <%= "(#{h(@tag.name)})" unless @tag.blank? %>
+ <%= "(&lsquo;#{h(params[:q])}&rsquo;)" unless params[:q].blank? %>
<%= total_for(@snippets.total_entries) -%></h1>
<% @snippets.each do |snippet| %>
View
10 app/views/snippets/show.html.erb
@@ -23,6 +23,16 @@
<%= link_to('Edit', edit_snippet_path(@snippet)) -%> |
<%= link_to('View', formatted_snippet_path(@snippet, :txt)) -%>
</div>
+
+ <div id="taggings">
+ <h3 id="taggings_count"><%= pluralize(@snippet.taggings_count, 'Tags') %></h3>
+ <%= render :partial => 'taggings/tagging', :collection => @snippet.taggings %>
+ </div>
+
+ <fieldset id="add_tag">
+ <legend>Add Tag</legend>
+ <%= render :partial => "taggings/new", :locals => { :snippet_id => @snippet.id } %>
+ </fieldset>
<% end %>
<!-- Theme Observers -->
View
27 public/stylesheets/screen.css
@@ -105,7 +105,7 @@ h1 {
/* Show All Snippets */
-#snippets_page, #languages_page, #page {
+#snippets_page, #languages_page, #tags_page, #page {
padding:30px;
background:#fff;
}
@@ -193,4 +193,29 @@ h1 {
}
#themes select {
font-size:1em;
+}
+
+/* Tags */
+
+#add_tag {
+ margin:20px 0;
+ border:1px solid #fff;
+}
+#new_tagging {
+ margin:10px 0;
+}
+#new_tagging input[type=text] {
+ width:125px;
+ margin:0;
+}
+a.remove {
+ text-decoration:none;
+}
+.tag_5,
+.tag_6,
+.tag_7,
+.tag_8,
+.tag_9,
+.tag_10 {
+ font-weight:bold;
}

0 comments on commit d71eeef

Please sign in to comment.