Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/rss
File: image.rb
# frozen_string_literal: false
[0] Fix | Delete
require 'rss/1.0'
[1] Fix | Delete
require_relative 'dublincore'
[2] Fix | Delete
[3] Fix | Delete
module RSS
[4] Fix | Delete
[5] Fix | Delete
# The prefix for the Image XML namespace.
[6] Fix | Delete
IMAGE_PREFIX = 'image'
[7] Fix | Delete
# The URI for the Image specification.
[8] Fix | Delete
IMAGE_URI = 'http://purl.org/rss/1.0/modules/image/'
[9] Fix | Delete
[10] Fix | Delete
RDF.install_ns(IMAGE_PREFIX, IMAGE_URI)
[11] Fix | Delete
[12] Fix | Delete
# This constant holds strings which contain the names of
[13] Fix | Delete
# image elements, with the appropriate prefix.
[14] Fix | Delete
IMAGE_ELEMENTS = []
[15] Fix | Delete
[16] Fix | Delete
%w(item favicon).each do |name|
[17] Fix | Delete
class_name = Utils.to_class_name(name)
[18] Fix | Delete
BaseListener.install_class_name(IMAGE_URI, name, "Image#{class_name}")
[19] Fix | Delete
IMAGE_ELEMENTS << "#{IMAGE_PREFIX}_#{name}"
[20] Fix | Delete
end
[21] Fix | Delete
[22] Fix | Delete
module ImageModelUtils
[23] Fix | Delete
def validate_one_tag_name(ignore_unknown_element, name, tags)
[24] Fix | Delete
if !ignore_unknown_element
[25] Fix | Delete
invalid = tags.find {|tag| tag != name}
[26] Fix | Delete
raise UnknownTagError.new(invalid, IMAGE_URI) if invalid
[27] Fix | Delete
end
[28] Fix | Delete
raise TooMuchTagError.new(name, tag_name) if tags.size > 1
[29] Fix | Delete
end
[30] Fix | Delete
end
[31] Fix | Delete
[32] Fix | Delete
module ImageItemModel
[33] Fix | Delete
include ImageModelUtils
[34] Fix | Delete
extend BaseModel
[35] Fix | Delete
[36] Fix | Delete
def self.append_features(klass)
[37] Fix | Delete
super
[38] Fix | Delete
[39] Fix | Delete
klass.install_have_child_element("item", IMAGE_URI, "?",
[40] Fix | Delete
"#{IMAGE_PREFIX}_item")
[41] Fix | Delete
klass.install_must_call_validator(IMAGE_PREFIX, IMAGE_URI)
[42] Fix | Delete
end
[43] Fix | Delete
[44] Fix | Delete
class ImageItem < Element
[45] Fix | Delete
include RSS10
[46] Fix | Delete
include DublinCoreModel
[47] Fix | Delete
[48] Fix | Delete
@tag_name = "item"
[49] Fix | Delete
[50] Fix | Delete
class << self
[51] Fix | Delete
def required_prefix
[52] Fix | Delete
IMAGE_PREFIX
[53] Fix | Delete
end
[54] Fix | Delete
[55] Fix | Delete
def required_uri
[56] Fix | Delete
IMAGE_URI
[57] Fix | Delete
end
[58] Fix | Delete
end
[59] Fix | Delete
[60] Fix | Delete
install_must_call_validator(IMAGE_PREFIX, IMAGE_URI)
[61] Fix | Delete
[62] Fix | Delete
[
[63] Fix | Delete
["about", ::RSS::RDF::URI, true],
[64] Fix | Delete
["resource", ::RSS::RDF::URI, false],
[65] Fix | Delete
].each do |name, uri, required|
[66] Fix | Delete
install_get_attribute(name, uri, required, nil, nil,
[67] Fix | Delete
"#{::RSS::RDF::PREFIX}:#{name}")
[68] Fix | Delete
end
[69] Fix | Delete
[70] Fix | Delete
%w(width height).each do |tag|
[71] Fix | Delete
full_name = "#{IMAGE_PREFIX}_#{tag}"
[72] Fix | Delete
disp_name = "#{IMAGE_PREFIX}:#{tag}"
[73] Fix | Delete
install_text_element(tag, IMAGE_URI, "?",
[74] Fix | Delete
full_name, :integer, disp_name)
[75] Fix | Delete
BaseListener.install_get_text_element(IMAGE_URI, tag, full_name)
[76] Fix | Delete
end
[77] Fix | Delete
[78] Fix | Delete
alias width= image_width=
[79] Fix | Delete
alias width image_width
[80] Fix | Delete
alias height= image_height=
[81] Fix | Delete
alias height image_height
[82] Fix | Delete
[83] Fix | Delete
def initialize(*args)
[84] Fix | Delete
if Utils.element_initialize_arguments?(args)
[85] Fix | Delete
super
[86] Fix | Delete
else
[87] Fix | Delete
super()
[88] Fix | Delete
self.about = args[0]
[89] Fix | Delete
self.resource = args[1]
[90] Fix | Delete
end
[91] Fix | Delete
end
[92] Fix | Delete
[93] Fix | Delete
def full_name
[94] Fix | Delete
tag_name_with_prefix(IMAGE_PREFIX)
[95] Fix | Delete
end
[96] Fix | Delete
[97] Fix | Delete
private
[98] Fix | Delete
def maker_target(target)
[99] Fix | Delete
target.image_item
[100] Fix | Delete
end
[101] Fix | Delete
[102] Fix | Delete
def setup_maker_attributes(item)
[103] Fix | Delete
item.about = self.about
[104] Fix | Delete
item.resource = self.resource
[105] Fix | Delete
end
[106] Fix | Delete
end
[107] Fix | Delete
end
[108] Fix | Delete
[109] Fix | Delete
module ImageFaviconModel
[110] Fix | Delete
include ImageModelUtils
[111] Fix | Delete
extend BaseModel
[112] Fix | Delete
[113] Fix | Delete
def self.append_features(klass)
[114] Fix | Delete
super
[115] Fix | Delete
[116] Fix | Delete
unless klass.class == Module
[117] Fix | Delete
klass.install_have_child_element("favicon", IMAGE_URI, "?",
[118] Fix | Delete
"#{IMAGE_PREFIX}_favicon")
[119] Fix | Delete
klass.install_must_call_validator(IMAGE_PREFIX, IMAGE_URI)
[120] Fix | Delete
end
[121] Fix | Delete
end
[122] Fix | Delete
[123] Fix | Delete
class ImageFavicon < Element
[124] Fix | Delete
include RSS10
[125] Fix | Delete
include DublinCoreModel
[126] Fix | Delete
[127] Fix | Delete
@tag_name = "favicon"
[128] Fix | Delete
[129] Fix | Delete
class << self
[130] Fix | Delete
def required_prefix
[131] Fix | Delete
IMAGE_PREFIX
[132] Fix | Delete
end
[133] Fix | Delete
[134] Fix | Delete
def required_uri
[135] Fix | Delete
IMAGE_URI
[136] Fix | Delete
end
[137] Fix | Delete
end
[138] Fix | Delete
[139] Fix | Delete
[
[140] Fix | Delete
["about", ::RSS::RDF::URI, true, ::RSS::RDF::PREFIX],
[141] Fix | Delete
["size", IMAGE_URI, true, IMAGE_PREFIX],
[142] Fix | Delete
].each do |name, uri, required, prefix|
[143] Fix | Delete
install_get_attribute(name, uri, required, nil, nil,
[144] Fix | Delete
"#{prefix}:#{name}")
[145] Fix | Delete
end
[146] Fix | Delete
[147] Fix | Delete
AVAILABLE_SIZES = %w(small medium large)
[148] Fix | Delete
alias_method :set_size, :size=
[149] Fix | Delete
private :set_size
[150] Fix | Delete
def size=(new_value)
[151] Fix | Delete
if @do_validate and !new_value.nil?
[152] Fix | Delete
new_value = new_value.strip
[153] Fix | Delete
unless AVAILABLE_SIZES.include?(new_value)
[154] Fix | Delete
attr_name = "#{IMAGE_PREFIX}:size"
[155] Fix | Delete
raise NotAvailableValueError.new(full_name, new_value, attr_name)
[156] Fix | Delete
end
[157] Fix | Delete
end
[158] Fix | Delete
set_size(new_value)
[159] Fix | Delete
end
[160] Fix | Delete
[161] Fix | Delete
alias image_size= size=
[162] Fix | Delete
alias image_size size
[163] Fix | Delete
[164] Fix | Delete
def initialize(*args)
[165] Fix | Delete
if Utils.element_initialize_arguments?(args)
[166] Fix | Delete
super
[167] Fix | Delete
else
[168] Fix | Delete
super()
[169] Fix | Delete
self.about = args[0]
[170] Fix | Delete
self.size = args[1]
[171] Fix | Delete
end
[172] Fix | Delete
end
[173] Fix | Delete
[174] Fix | Delete
def full_name
[175] Fix | Delete
tag_name_with_prefix(IMAGE_PREFIX)
[176] Fix | Delete
end
[177] Fix | Delete
[178] Fix | Delete
private
[179] Fix | Delete
def maker_target(target)
[180] Fix | Delete
target.image_favicon
[181] Fix | Delete
end
[182] Fix | Delete
[183] Fix | Delete
def setup_maker_attributes(favicon)
[184] Fix | Delete
favicon.about = self.about
[185] Fix | Delete
favicon.size = self.size
[186] Fix | Delete
end
[187] Fix | Delete
end
[188] Fix | Delete
[189] Fix | Delete
end
[190] Fix | Delete
[191] Fix | Delete
class RDF
[192] Fix | Delete
class Channel; include ImageFaviconModel; end
[193] Fix | Delete
class Item; include ImageItemModel; end
[194] Fix | Delete
end
[195] Fix | Delete
[196] Fix | Delete
end
[197] Fix | Delete
[198] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function