diff --git a/Gemfile b/Gemfile index 989feb122..a8bfb1661 100644 --- a/Gemfile +++ b/Gemfile @@ -22,20 +22,22 @@ gem 'jquery-rails' # Optional support for eco templates gem 'eco' -gem "omniauth" -gem "omniauth-twitter" -gem "omniauth-facebook" -gem "omniauth-linkedin" -gem "omniauth-google-oauth2" +gem 'omniauth' +gem 'omniauth-twitter' +gem 'omniauth-facebook' +gem 'omniauth-linkedin' +gem 'omniauth-google-oauth2' -gem "twitter" -gem "koala" -gem "mail" +gem 'twitter' +gem 'koala' +gem 'mail' -gem "mime-types" +gem 'mime-types' gem 'delayed_job_active_record' -gem "daemons" +gem 'daemons' + +gem 'simple-rss' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' diff --git a/Gemfile.lock b/Gemfile.lock index 62dfe1f36..534e5616d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -127,6 +127,7 @@ GEM railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) + simple-rss (1.2.3) simple_oauth (0.1.5) sprockets (2.1.2) hike (~> 1.2) @@ -168,6 +169,7 @@ DEPENDENCIES omniauth-twitter rails (= 3.2.2) sass-rails (~> 3.2.4) + simple-rss sqlite3 twitter uglifier (>= 1.2.3) diff --git a/app/assets/javascripts/app/controllers/_dashboard/rss.js.coffee b/app/assets/javascripts/app/controllers/_dashboard/rss.js.coffee new file mode 100644 index 000000000..1636651cf --- /dev/null +++ b/app/assets/javascripts/app/controllers/_dashboard/rss.js.coffee @@ -0,0 +1,31 @@ +$ = jQuery.sub() + +class App.DashboardRss extends App.Controller + constructor: -> + super +# @log 'aaaa', @el + + @items = [] + + # get data + @ajax = new App.Ajax + @ajax.ajax( + type: 'GET', + url: '/rss_fetch', + data: { + limit: @limit, + url: @url, + } + processData: true, + success: (data, status, xhr) => + @items = data.items || [] + @render() + ) + + render: -> + html = App.view('dashboard/rss')( + head: @head, + items: @items + ) + html = $(html) + @html html diff --git a/app/assets/javascripts/app/controllers/dashboard.js.coffee b/app/assets/javascripts/app/controllers/dashboard.js.coffee index 7222706c1..f9c0ad82b 100644 --- a/app/assets/javascripts/app/controllers/dashboard.js.coffee +++ b/app/assets/javascripts/app/controllers/dashboard.js.coffee @@ -31,6 +31,23 @@ class Index extends App.Controller activity_stream: { controller: App.DashboardActivityStream, }, + rss_atom: { + controller: App.DashboardRss, + params: { + head: 'Heise ATOM', + url: 'http://www.heise.de/newsticker/heise-atom.xml', + limit: 5, + }, + }, +# rss_rdf: { +# controller: App.DashboardRss, +# params: { +# head: 'Heise RDF', +# url: 'http://www.heise.de/newsticker/heise.rdf', +# limit: 5, +# }, +# }, + # recent_viewed: { # controller: App.DashboardRecentViewed, # } diff --git a/app/assets/javascripts/app/views/dashboard/rss.jst.eco b/app/assets/javascripts/app/views/dashboard/rss.jst.eco new file mode 100644 index 000000000..1157b92a9 --- /dev/null +++ b/app/assets/javascripts/app/views/dashboard/rss.jst.eco @@ -0,0 +1,10 @@ +
+
+

<%= @head %>

+ +
+
\ No newline at end of file diff --git a/app/controllers/rss_controller.rb b/app/controllers/rss_controller.rb new file mode 100644 index 000000000..177983075 --- /dev/null +++ b/app/controllers/rss_controller.rb @@ -0,0 +1,24 @@ +class RssController < ApplicationController + before_filter :authentication_check + + # GET /rss_fetch + def fetch + url = params[:url] + limit = params[:limit] || 10 + response = Net::HTTP.get_response( URI.parse(url) ) + if response.code.to_s != '200' + render :json => { :message => "failed to fetch #{url}, code: #{response.code}"}, :status => :unprocessable_entity + return + end + rss = SimpleRSS.parse response.body + items = [] + fetched = 0 + rss.items.each { |item| + items.push item + fetched += 1 + break item if fetched == limit.to_i + } + render :json => { :items => items } + end + +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 38039cd83..1fe6422cc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -49,6 +49,9 @@ Zammad::Application.routes.draw do # getting_started match '/getting_started', :to => 'getting_started#index' + # getting_started + match '/rss_fetch', :to => 'rss#fetch' + # sessions resources :sessions, :only => [:create, :destroy, :show] match '/signin', :to => 'sessions#create'