Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

@keating
CreatedMay 20, 2013 15:44
    • Star(0)You must be signed in to star a gist
    • Fork(0)You must be signed in to fork a gist
    Save keating/5613080 to your computer and use it in GitHub Desktop.
    blog_feed
    require 'rss/2.0'
    require 'open-uri'
    require 'timeout'
    module PagesHelper
    def blog_feed
    html = ""
    begin
    status = Timeout::timeout(5) {
    source = BLOG_URL # url or local file
    content = "" # raw content of rss feed will be loaded here
    open(source) do |s|
    content = s.read
    end
    rss = RSS::Parser.parse(content, false)
    rss.items.first(5).each do |i|
    html << "<div class='pills-content'>"
    html << "<div>#{i.title}</div><div class='pills-content-link'><a href='#{i.link}' target='_blank'>View More</a></div>"
    html << "</div>"
    end
    }
    rescue Timeout::Error
    html << "That took too long, exiting..."
    end
    html
    end
    end
    Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

    [8]ページ先頭

    ©2009-2025 Movatter.jp