プロジェクト

全般

プロフィール

バグ #624 » openimg-20131102.diff

hycon miyagi, 2013-11-02 15:37

差分を表示:

core/plugin/openimg/openimg.rb
def get_tag_by_attributes(tag)
attribute = {}
tag.each_matches(/([a-zA-Z0-9]+?)=(['"])(.*?)\2/){ |pair, pos|
tag.each_matches(/\s*([^=]+)=(['"])(.*?)\2/){ |pair, pos|
key, val = pair[1], pair[3]
attribute[key] = val }
attribute.freeze end
......
attribute = {}
catch(:imgtag_match){
dom.gsub("\n", ' ').each_matches(Regexp.new("<#{tag_name}.*?>")){ |str, pos|
attr = get_tag_by_attributes(str.to_s)
attr = get_tag_by_attributes(str.to_s[tag_name.length + 1 .. -1])
if element_rule.all?{ |k, v| v === attr[k] }
attribute = attr.freeze
throw :imgtag_match end } }
......
t = fetch(url)
/^(http:\/\/[^\/]+\/)post(\/\d+)/ =~ t
if $~
imgurlresolver($1 + "image" + $2, 'id' => 'content-image')
imgurlresolver($1 + "image" + $2, {'id' => 'content-image', 'attribute' => 'data-src'})
else
warn "たんぶらの記事ページじゃないっぽい"
nil
core/plugin/openimg/pattern_file.json
"Tumblr image": {
"url": "^http://[-0-9a-z]+\\.tumblr\\.com/image/\\d+",
"attribute": {
"id": "content-image"
"id": "content-image",
"attribute": "data-src",
}
},
"はてなフォトライフ": {
(1-1/3)