晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
| DIR:/opt/alt/ruby27/share/ruby/rss/ |
| Current File : //opt/alt/ruby27/share/ruby/rss/1.0.rb |
# frozen_string_literal: false
require_relative "parser"
module RSS
##
# = RSS 1.0 support
#
# RSS has three different versions. This module contains support for version
# 1.0[http://web.resource.org/rss/1.0/]
#
# == Producing RSS 1.0
#
# Producing our own RSS feeds is easy as well. Let's make a very basic feed:
#
# require "rss"
#
# rss = RSS::Maker.make("1.0") do |maker|
# maker.channel.language = "en"
# maker.channel.author = "matz"
# maker.channel.about = "About my feed."
# maker.channel.updated = Time.now.to_s
# maker.channel.link = "http://www.ruby-lang.org/en/feeds/news.rss"
# maker.channel.title = "Example Feed"
# maker.channel.description = "A longer description of my feed."
# maker.items.new_item do |item|
# item.link = "http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/"
# item.title = "Ruby 1.9.2-p136 is released"
# item.updated = Time.now.to_s
# end
# end
#
# puts rss
#
# As you can see, this is a very Builder-like DSL. This code will spit out an
# RSS 1.0 feed with one item. If we needed a second item, we'd make another
# block with maker.items.new_item and build a second one.
module RSS10
NSPOOL = {}
ELEMENTS = []
def self.append_features(klass)
super
klass.install_must_call_validator('', ::RSS::URI)
end
end
class RDF < Element
include RSS10
include RootElementMixin
class << self
def required_uri
URI
end
end
@tag_name = 'RDF'
PREFIX = 'rdf'
URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
install_ns('', ::RSS::URI)
install_ns(PREFIX, URI)
[
["channel", nil],
["image", "?"],
["item", "+", :children],
["textinput", "?"],
].each do |tag, occurs, type|
type ||= :child
__send__("install_have_#{type}_element", tag, ::RSS::URI, occurs)
end
alias_method(:rss_version, :feed_version)
def initialize(version=nil, encoding=nil, standalone=nil)
super('1.0', version, encoding, standalone)
@feed_type = "rss"
end
def full_name
tag_name_with_prefix(PREFIX)
end
class Li < Element
include RSS10
class << self
def required_uri
URI
end
end
[
["resource", [URI, ""], true]
].each do |name, uri, required|
install_get_attribute(name, uri, required)
end
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
else
super()
self.resource = args[0]
end
end
def full_name
tag_name_with_prefix(PREFIX)
end
end
class Seq < Element
include RSS10
Li = ::RSS::RDF::Li
class << self
def required_uri
URI
end
end
@tag_name = 'Seq'
install_have_children_element("li", URI, "*")
install_must_call_validator('rdf', ::RSS::RDF::URI)
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
else
super()
@li = args[0] if args[0]
end
end
def full_name
tag_name_with_prefix(PREFIX)
end
def setup_maker(target)
lis.each do |li|
target << li.resource
end
end
end
class Bag < Element
include RSS10
Li = ::RSS::RDF::Li
class << self
def required_uri
URI
end
end
@tag_name = 'Bag'
install_have_children_element("li", URI, "*")
install_must_call_validator('rdf', URI)
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
else
super()
@li = args[0] if args[0]
end
end
def full_name
tag_name_with_prefix(PREFIX)
end
def setup_maker(target)
lis.each do |li|
target << li.resource
end
end
end
class Channel < Element
include RSS10
class << self
def required_uri
::RSS::URI
end
end
[
["about", URI, true]
].each do |name, uri, required|
install_get_attribute(name, uri, required, nil, nil,
"#{PREFIX}:#{name}")
end
[
['title', nil, :text],
['link', nil, :text],
['description', nil, :text],
['image', '?', :have_child],
['items', nil, :have_child],
['textinput', '?', :have_child],
].each do |tag, occurs, type|
__send__("install_#{type}_element", tag, ::RSS::URI, occurs)
end
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
else
super()
self.about = args[0]
end
end
private
def maker_target(maker)
maker.channel
end
def setup_maker_attributes(channel)
channel.about = about
end
class Image < Element
include RSS10
class << self
def required_uri
::RSS::URI
end
end
[
["resource", URI, true]
].each do |name, uri, required|
install_get_attribute(name, uri, required, nil, nil,
"#{PREFIX}:#{name}")
end
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
else
super()
self.resource = args[0]
end
end
end
class Textinput < Element
include RSS10
class << self
def required_uri
::RSS::URI
end
end
[
["resource", URI, true]
].each do |name, uri, required|
install_get_attribute(name, uri, required, nil, nil,
"#{PREFIX}:#{name}")
end
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
else
super()
self.resource = args[0]
end
end
end
class Items < Element
include RSS10
Seq = ::RSS::RDF::Seq
class << self
def required_uri
::RSS::URI
end
end
install_have_child_element("Seq", URI, nil)
install_must_call_validator('rdf', URI)
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
else
super()
self.Seq = args[0]
end
self.Seq ||= Seq.new
end
def resources
if @Seq
@Seq.lis.collect do |li|
li.resource
end
else
[]
end
end
end
end
class Image < Element
include RSS10
class << self
def required_uri
::RSS::URI
end
end
[
["about", URI, true]
].each do |name, uri, required|
install_get_attribute(name, uri, required, nil, nil,
"#{PREFIX}:#{name}")
end
%w(title url link).each do |name|
install_text_element(name, ::RSS::URI, nil)
end
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
else
super()
self.about = args[0]
end
end
private
def maker_target(maker)
maker.image
end
end
class Item < Element
include RSS10
class << self
def required_uri
::RSS::URI
end
end
[
["about", URI, true]
].each do |name, uri, required|
install_get_attribute(name, uri, required, nil, nil,
"#{PREFIX}:#{name}")
end
[
["title", nil],
["link", nil],
["description", "?"],
].each do |tag, occurs|
install_text_element(tag, ::RSS::URI, occurs)
end
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
else
super()
self.about = args[0]
end
end
private
def maker_target(items)
if items.respond_to?("items")
# For backward compatibility
items = items.items
end
items.new_item
end
end
class Textinput < Element
include RSS10
class << self
def required_uri
::RSS::URI
end
end
[
["about", URI, true]
].each do |name, uri, required|
install_get_attribute(name, uri, required, nil, nil,
"#{PREFIX}:#{name}")
end
%w(title description name link).each do |name|
install_text_element(name, ::RSS::URI, nil)
end
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
else
super()
self.about = args[0]
end
end
private
def maker_target(maker)
maker.textinput
end
end
end
RSS10::ELEMENTS.each do |name|
BaseListener.install_get_text_element(URI, name, name)
end
module ListenerMixin
private
def initial_start_RDF(tag_name, prefix, attrs, ns)
check_ns(tag_name, prefix, ns, RDF::URI, false)
@rss = RDF.new(@version, @encoding, @standalone)
@rss.do_validate = @do_validate
@rss.xml_stylesheets = @xml_stylesheets
@last_element = @rss
pr = Proc.new do |text, tags|
@rss.validate_for_stream(tags, @ignore_unknown_element) if @do_validate
end
@proc_stack.push(pr)
end
end
end
|