diff options
author | Jochen Topf <jochen@topf.org> | 2013-01-18 20:08:39 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2013-01-18 20:08:39 +0100 |
commit | ab4f955593dfc671af4a4e75791324e0c205d64a (patch) | |
tree | a0bc16e857d81b3adab7c70ecad8a050573231a1 /sources | |
parent | 71e774e39117dc51e27902d64ee8a70341a08ef3 (diff) | |
download | taginfo-ab4f955593dfc671af4a4e75791324e0c205d64a.tar taginfo-ab4f955593dfc671af4a4e75791324e0c205d64a.tar.gz |
Add support for relation type images
Diffstat (limited to 'sources')
-rwxr-xr-x | sources/wiki/get_image_info.rb | 1 | ||||
-rwxr-xr-x | sources/wiki/get_wiki_data.rb | 23 |
2 files changed, 16 insertions, 8 deletions
diff --git a/sources/wiki/get_image_info.rb b/sources/wiki/get_image_info.rb index caaf952..1593bbe 100755 --- a/sources/wiki/get_image_info.rb +++ b/sources/wiki/get_image_info.rb @@ -80,6 +80,7 @@ until image_titles.empty? if normalized normalized.each do |n| db.execute('UPDATE wikipages SET image=? WHERE image=?', n['to'], n['from']) + db.execute('UPDATE relation_pages SET image=? WHERE image=?', n['to'], n['from']) end end diff --git a/sources/wiki/get_wiki_data.rb b/sources/wiki/get_wiki_data.rb index 2803d33..36f0fab 100755 --- a/sources/wiki/get_wiki_data.rb +++ b/sources/wiki/get_wiki_data.rb @@ -142,6 +142,16 @@ class WikiPage @parsed = false end + def set_image(ititle, db) + if !ititle.nil? && ititle.match(%r{^(file|image):(.*)$}i) + @image = "File:#{$2}" + else + puts "invalid image: page='#{title}' image='#{ititle}'" + db.execute('INSERT INTO invalid_image_titles (page_title, image_title) VALUES (?, ?)', title, ititle) + @image = '' + end + end + def parse_template(template, db) puts "Template: #{template.name} [#{template.parameters.join(',')}] #{template.named_parameters.inspect}" if template.name == 'Key' || template.name == 'Tag' @@ -165,14 +175,7 @@ class WikiPage end end if template.named_parameters['image'] - ititle = template.named_parameters['image'][0] - if !ititle.nil? && ititle.match(%r{^(file|image):(.*)$}i) - @image = "File:#{$2}" - else - puts "invalid image: page='#{title}' image='#{ititle}'" - db.execute('INSERT INTO invalid_image_titles (page_title, image_title) VALUES (?, ?)', title, ititle) - @image = '' - end + set_image(template.named_parameters['image'][0], db) end if template.named_parameters['group'] @group = template.named_parameters['group'][0] @@ -280,6 +283,10 @@ class RelationPage < WikiPage end end + def set_image(ititle, db) + @image = "File:#{ititle}" + end + def insert(db) db.execute( "INSERT INTO relation_pages (lang, rtype, title, body, tgroup, type, has_templ, parsed, description, image, tags_linked) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", |