Merge pull request #245 from fsmanuel/rss_feed + 1
This commit is contained in:
commit
69a29b8296
16 changed files with 171 additions and 6 deletions
BIN
lib/foodsoft_wiki/app/assets/images/icons/feed-icon-14x14.png
Executable file
BIN
lib/foodsoft_wiki/app/assets/images/icons/feed-icon-14x14.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 689 B |
BIN
lib/foodsoft_wiki/app/assets/images/icons/feed-icon-28x28.png
Executable file
BIN
lib/foodsoft_wiki/app/assets/images/icons/feed-icon-28x28.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
|
|
@ -1,6 +1,14 @@
|
|||
# encoding: utf-8
|
||||
class PagesController < ApplicationController
|
||||
|
||||
skip_before_filter :authenticate, :only => :all
|
||||
before_filter :only => :all do
|
||||
authenticate_or_token(['wiki', 'all'])
|
||||
end
|
||||
before_filter do
|
||||
content_for :head, view_context.rss_meta_tag
|
||||
end
|
||||
|
||||
def index
|
||||
@page = Page.find_by_permalink "Home"
|
||||
|
||||
|
|
@ -114,6 +122,10 @@ class PagesController < ApplicationController
|
|||
end
|
||||
@pages.order(order)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.rss { render :layout => false }
|
||||
end
|
||||
end
|
||||
|
||||
def version
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
module PagesHelper
|
||||
include WikiCloth
|
||||
|
||||
def rss_meta_tag
|
||||
tag('link', :rel => "alternate", :type => "application/rss+xml", :title => "RSS", :href => all_pages_rss_url).html_safe
|
||||
end
|
||||
|
||||
def wikified_body(body, title = nil)
|
||||
render_opts = {:locale => I18n.locale} # workaround for wikicloth 0.8.0 https://github.com/nricciar/wikicloth/pull/59
|
||||
WikiCloth.new({:data => body+"\n", :link_handler => Wikilink.new, :params => {:referer => title}}).to_html(render_opts).html_safe
|
||||
|
|
@ -59,4 +63,10 @@ module PagesHelper
|
|||
Array.new
|
||||
end
|
||||
end
|
||||
|
||||
# return url for all_pages rss feed
|
||||
def all_pages_rss_url(options={})
|
||||
token = TokenVerifier.new(['wiki', 'all']).generate
|
||||
all_pages_url({:format => 'rss', :token => token}.merge(options))
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -33,6 +33,24 @@ class Page < ActiveRecord::Base
|
|||
self.permalink = Page.count == 0 ? "Home" : Page.permalink(title)
|
||||
end
|
||||
end
|
||||
|
||||
def diff
|
||||
current = versions.latest
|
||||
old = versions.where(["page_id = ? and lock_version < ?", current.page_id, current.lock_version]).order('lock_version DESC').first
|
||||
|
||||
if old
|
||||
o = ''
|
||||
Diffy::Diff.new(old.body, current.body).each do |line|
|
||||
case line
|
||||
when /^\+/ then o += "#{line.chomp}<br />" unless line.chomp == "+"
|
||||
when /^-/ then o += "#{line.chomp}<br />" unless line.chomp == "-"
|
||||
end
|
||||
end
|
||||
o
|
||||
else
|
||||
current.body
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
%li= link_to t('.recent_changes'), all_pages_path(:view => 'recent_changes')
|
||||
%li= link_to t('.title_list'), all_pages_path(:view => 'title_list')
|
||||
%li= link_to t('.site_map'), all_pages_path(:view => 'site_map')
|
||||
%li= link_to image_tag('icons/feed-icon-14x14.png', :alt => 'RSS Feed'), all_pages_rss_url
|
||||
= form_tag all_pages_path, method: :get, class: 'form-search pull-right' do
|
||||
= text_field_tag :name, params[:name], class: 'input-medium search-query',
|
||||
placeholder: t('.search.placeholder')
|
||||
|
|
|
|||
19
lib/foodsoft_wiki/app/views/pages/all.rss.builder
Normal file
19
lib/foodsoft_wiki/app/views/pages/all.rss.builder
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.rss :version => "2.0" do
|
||||
xml.channel do
|
||||
xml.title FoodsoftConfig[:name] + " Wiki"
|
||||
xml.description ""
|
||||
xml.link FoodsoftConfig[:homepage]
|
||||
|
||||
for page in @pages
|
||||
xml.item do
|
||||
xml.title page.title
|
||||
xml.description page.diff, :type => "html"
|
||||
xml.author User.find(page.updated_by).display
|
||||
xml.pubDate page.updated_at.to_s(:rfc822)
|
||||
xml.link wiki_page_path(page.permalink)
|
||||
xml.guid page.updated_at.to_i
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|||
s.add_dependency "rails", "~> 3.2.15"
|
||||
s.add_dependency 'wikicloth'
|
||||
s.add_dependency 'acts_as_versioned' # need git version, make sure that is included in foodsoft's Gemfile
|
||||
|
||||
s.add_dependency 'diffy'
|
||||
s.add_dependency 'content_for_in_controllers'
|
||||
s.add_development_dependency "sqlite3"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
require 'wikicloth'
|
||||
require 'acts_as_versioned'
|
||||
require 'diffy'
|
||||
require 'content_for_in_controllers'
|
||||
require 'foodsoft_wiki/engine'
|
||||
|
||||
module FoodsoftWiki
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue