Skip to content

Commit

Permalink
Rename statuses as notes.
Browse files Browse the repository at this point in the history
Indie Web "Standards" use the term "note" for "status" as it is less linked to a particular silo and does not have the timely meanning.

Comes with a migration to move statuses to notes. Should I add one to rebuild all the perma short links as well?

Also fixes the push to Twitter that was broken.
  • Loading branch information
Frédéric de Villamil committed Aug 25, 2013
1 parent e8fdc91 commit 21fac3a
Show file tree
Hide file tree
Showing 28 changed files with 475 additions and 425 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def index
@statposts = Article.published.where("published_at > ?", today).count
@statsdrafts = Article.drafts.where("created_at > ?", today).count
@statspages = Page.where("published_at > ?", today).count
@statuses = Status.where("published_at > ?", today).count
@statuses = Note.where("published_at > ?", today).count
@statuserposts = Article.published.where("published_at > ?", today).count(conditions: {user_id: current_user.id})
@statcomments = Comment.where("created_at > ?", today).count
@presumedspam = Comment.presumed_spam.where("created_at > ?", today).count
Expand Down
67 changes: 67 additions & 0 deletions app/controllers/admin/notes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module Admin; end

class Admin::NotesController < Admin::ContentController
layout "administration"

def index; redirect_to :action => 'new' ; end
def new; new_or_edit; end
def edit; new_or_edit; end

def destroy
destroy_a(Note)
end

private
def get_or_build_status
id = params[:id]
return Note.find(id) if id

Note.new do |note|
note.text_filter = current_user.default_text_filter
note.published = true
note.published_at = Time.now
note.push_to_twitter = true
end
end

def update_status_attributes
@note.attributes = params[:note]
@note.published_at = parse_date_time params[:note][:published_at]
@note.set_author(current_user)
@note.text_filter ||= current_user.default_text_filter
end

def new_or_edit
@notes = Note.page(params[:page]).per(this_blog.limit_article_display)
@note = get_or_build_status

if request.post?
update_status_attributes

message = "created"
if @note.id
unless @note.access_by?(current_user)
flash[:error] = _("Error, you are not allowed to perform this action")
return(redirect_to :action => 'new')
end

message = "updated"
end

if @note.save
flash[:notice] = _("Note was successfully %s.", message)
if params[:note][:push_to_twitter] and params[:note][:push_to_twitter] != "0" and (@note.twitter_id.nil? or @note.twitter_id.empty?)
unless @note.send_to_twitter
flash[:notice] = nil
flash[:error] = _("Oooops something wrong happened")
end
end
redirect_to :action => 'new'
end
return
end

render 'new'
end

end
67 changes: 0 additions & 67 deletions app/controllers/admin/statuses_controller.rb

This file was deleted.

32 changes: 32 additions & 0 deletions app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class NotesController < ContentController
require 'json'

layout :theme_layout
cache_sweeper :blog_sweeper
caches_page :index, :show, :if => Proc.new {|c|
c.request.query_string == ''
}

def index
@notes = Note.published.page(params[:page]).per(this_blog.limit_article_display)
@keywords = this_blog.meta_keywords
@page_title = this_blog.statuses_title_template.to_title(@notes, this_blog, params)
@description = this_blog.statuses_desc_template.to_title(@notes, this_blog, params)
end

def show
if @note = Note.published.find_by_permalink(CGI.escape(params[:permalink]))
@keywords = this_blog.meta_keywords
@page_title = this_blog.status_title_template.to_title(@note, this_blog, params)
@description = this_blog.status_desc_template.to_title(@note, this_blog, params)
@canonical_url = @note.permalink_url

if @note.in_reply_to_message and !@note.in_reply_to_message.empty?
@reply = JSON.parse(@note.in_reply_to_message)
end

else
render "errors/404", :status => 404
end
end
end
32 changes: 0 additions & 32 deletions app/controllers/statuses_controller.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module StatusesHelper
module NotesHelper
def get_reply_context_url(reply)
begin
return reply['user']['entities']['url']['urls'][0]['expanded_url']
Expand Down
4 changes: 2 additions & 2 deletions app/models/blog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class Blog < ActiveRecord::Base
setting :archives_desc_template, :string, "Archives for %blog_name% %date% %page% %blog_subtitle%"
setting :search_title_template, :string, "Results for %search% | %blog_name% %page%"
setting :search_desc_template, :string, "Results for %search% | %blog_name% | %blog_subtitle% %page%"
setting :statuses_title_template, :string, "Statuses | %blog_name% %page%"
setting :statuses_desc_template, :string, "Statuses | %blog_name% | %blog_subtitle% %page%"
setting :statuses_title_template, :string, "Notes | %blog_name% %page%"
setting :statuses_desc_template, :string, "Notes | %blog_name% | %blog_subtitle% %page%"
setting :status_title_template, :string, "%body% | %blog_name%"
setting :status_desc_template, :string, "%excerpt%"

Expand Down
6 changes: 3 additions & 3 deletions app/models/status.rb → app/models/note.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Status < Content
class Note < Content
require 'twitter'
require 'json'
require 'uri'
Expand Down Expand Up @@ -71,7 +71,7 @@ def send_to_twitter
self.in_reply_to_message = twitter.status(self.in_reply_to_status_id).to_json
end

tweet = twitter.update(self.message, options)
tweet = twitter.update(self.twitter_message, options)
self.twitter_id = tweet.attrs[:id_str]

self.save
Expand All @@ -95,7 +95,7 @@ def access_by?(user)

def permalink_url(anchor=nil, only_path=false)
blog.url_for(
:controller => '/statuses',
:controller => '/notes',
:action => 'show',
:permalink => permalink,
:anchor => anchor,
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/dashboard/_welcome.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<p><%= link_to(sprintf("<strong>%d</strong> %s", @statuserposts, _("articles writen by you")).html_safe, :controller => 'admin/content', "search[user_id]" => current_user.id).html_safe %></p>
<p><%= link_to(sprintf("<strong>%d</strong> %s", @statsdrafts, pluralize(@statsdrafts, _("drafts"), _("draft"), _("drafts"))).html_safe, :controller => 'admin/content', "search[state]" => "drafts").html_safe %></p>
<p><%= link_to(sprintf("<strong>%d</strong> %s", @statspages, pluralize(@statspages, _("pages"), _("page"), _("pages"))).html_safe, :controller => 'admin/pages').html_safe %></p>
<p><%= link_to(sprintf("<strong>%d</strong> %s", @statuses, pluralize(@statspages, _("short statuses"), _("short status"), _("short statuses"))).html_safe, :controller => 'admin/statuses').html_safe %></p>
<p><%= link_to(sprintf("<strong>%d</strong> %s", @statuses, pluralize(@statspages, _("notes"), _("note"), _("notes"))).html_safe, :controller => 'admin/notes').html_safe %></p>
<% end %>
</div>
<div class='span6'>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% @page_heading = _('Short statuses') %>
<% @page_heading = _('Notes') %>
<div>
<div class='span4'>
<%= form_tag :action=>"edit", :id => @status.id do %>
<%= form_tag :action=>"edit", :id => @note.id do %>
<input type="hidden" name="status[text_filter]" id="status_textfilter" value="<%= current_user.text_filter_name %>" />
<div id='quicktags'>
<script type="text/javascript">//edToolbar('status_body');</script>
Expand Down Expand Up @@ -41,8 +41,8 @@
</tr>
</thead>
<tbody>
<%= render_void_table(@statuses.size, 3) %>
<% for status in @statuses %>
<%= render_void_table(@notes.size, 3) %>
<% for status in @notes %>
<tr>
<td>
<strong><%= link_to_edit h(status.body), status %></strong>
Expand All @@ -54,7 +54,7 @@
</td>
</tr>
<% end %>
<%= display_pagination(@statuses, 3, 'first', 'last')%>
<%= display_pagination(@notes, 3, 'first', 'last')%>
</tbody>
</table>

Expand Down
18 changes: 18 additions & 0 deletions app/views/notes/_note.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class='h-entry hentry h-as-note well well-small'>
<% if @reply %>
<%= render :partial => "note_reply_context", :object => @reply %>
<% end %>

<article class='status'>
<%= author_picture note %>
<div class='p-name entry-title e-content entry-content article'><%= note.html(:body) %></div>
<footer>
<small>
<%= link_to_permalink(note, display_date_and_time(note.published_at)) %> |
<%= link_to note.redirects.first.to_url, note.redirects.first.to_url %> |
<%= author_link note %>
<%= view_on_twitter note %>
</small>
</footer>
</article>
</div>
15 changes: 15 additions & 0 deletions app/views/notes/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="hfeed">
<% for note in @notes -%>
<div class='h-entry hentry h-as-note'>
<article>
<p class='p-name entry-title e-content entry-content article'><%= note.html(:body) %></p>
<footer>
<small><%= link_to_permalink(note, display_date_and_time(note.published_at)) %></small>
</footer>
</article>
<hr />
</div>
<% end -%>
</div>

<%= paginate @notes, :next_label => "#{_("Next page")} &raquo;", :previous_label => "&laquo; #{_('Previous page')}" %>
3 changes: 3 additions & 0 deletions app/views/notes/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="hfeed">
<%= render :partial => "note", :object => @note %>
</div>
18 changes: 0 additions & 18 deletions app/views/statuses/_status.html.erb

This file was deleted.

15 changes: 0 additions & 15 deletions app/views/statuses/index.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions app/views/statuses/show.html.erb

This file was deleted.

6 changes: 3 additions & 3 deletions config/initializers/access_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
project.submenu "Cache", { :controller => "admin/cache", :action => "index" }
end

map.project_module :statuses, nil do |project|
project.menu "Short statuses", { :controller => "admin/statuses", :action => "index" }
project.submenu "All statuses", { :controller => "admin/statuses", :action => "new" }
map.project_module :notes, nil do |project|
project.menu "Notes", { :controller => "admin/notes", :action => "index" }
project.submenu "All notes", { :controller => "admin/notes", :action => "new" }
end

map.project_module :seo, nil do |project|
Expand Down
Loading

0 comments on commit 21fac3a

Please sign in to comment.