[Xfce4-commits] <moka:master> Add untested identi.ca announcement feature.
Jannis Pohlmann
noreply at xfce.org
Mon Jan 17 17:32:01 CET 2011
Updating branch refs/heads/master
to 85735226cf713bd244d72b7841efaf59b840f548 (commit)
from 121f0e9788aa2422eb52154f56e2abb86bab2346 (commit)
commit 85735226cf713bd244d72b7841efaf59b840f548
Author: Jannis Pohlmann <jannis at xfce.org>
Date: Mon Jan 17 17:31:43 2011 +0100
Add untested identi.ca announcement feature.
lib/controllers/announcements.rb | 41 ++++++++++++++++++++++++++++++++++++++
lib/moka.rb | 4 ++-
lib/views/announcements.erb | 9 ++++++++
3 files changed, 53 insertions(+), 1 deletions(-)
diff --git a/lib/controllers/announcements.rb b/lib/controllers/announcements.rb
new file mode 100755
index 0000000..e7ce341
--- /dev/null
+++ b/lib/controllers/announcements.rb
@@ -0,0 +1,41 @@
+module Moka
+ module Controllers
+ module Announcements
+ include Moka::Models
+
+ def self.registered(app)
+ app.get '/announcements' do
+ authentication_required
+
+ view :announcements
+ end
+
+ app.post '/announcements/identica' do
+ authentication_required
+
+ unless env['identica']
+ error_set(:text, 'Posting announcements on identi.ca is not supported.')
+ end
+
+ unless error_set?
+ if params[:text].size > 140
+ error_set(:text, 'Message length is limited to 140 characters.')
+ end
+ end
+
+ unless error_set?
+ if env['identica'].group.nil?
+ status = params[:text]
+ else
+ status = "#{params[:text]} !#{env['identica'].group}"
+ end
+
+ env['identica'].post(status)
+ end
+
+ view :announcements
+ end
+ end
+ end
+ end
+end
diff --git a/lib/moka.rb b/lib/moka.rb
index 614b969..f324c5b 100755
--- a/lib/moka.rb
+++ b/lib/moka.rb
@@ -21,6 +21,7 @@ require File.join(directory, 'models', 'archive')
require File.join(directory, 'helpers', 'general')
+require File.join(directory, 'controllers', 'announcements')
require File.join(directory, 'controllers', 'authentication')
require File.join(directory, 'controllers', 'collections')
require File.join(directory, 'controllers', 'projects')
@@ -37,6 +38,7 @@ module Moka
register Moka::Helpers::General
+ register Moka::Controllers::Announcements
register Moka::Controllers::Authentication
register Moka::Controllers::Projects
register Moka::Controllers::Collections
@@ -46,7 +48,7 @@ module Moka
get '/stylesheet.css' do
content_type 'text/css', :charset => 'utf-8'
-
+
directory = File.join(File.expand_path(File.dirname(__FILE__)), 'views')
template = File.read(File.join(directory, 'stylesheet.sass'))
diff --git a/lib/views/announcements.erb b/lib/views/announcements.erb
new file mode 100644
index 0000000..92b0c56
--- /dev/null
+++ b/lib/views/announcements.erb
@@ -0,0 +1,9 @@
+<%= header :title => "Announcements" %>
+<% if env['identica'] %>
+<h2>Publish an announcement on identi.ca</h2>
+<form method="post" action="/announcements/identica">
+ <p><textarea rows="3" cols="30" name="text"></textarea></p>
+ <p><input type="submit" value="Publish"/></p>
+</form>
+<% end %>
+<%= footer %>
More information about the Xfce4-commits
mailing list