diff options
author | Jochen Topf <jochen@topf.org> | 2012-01-24 10:33:34 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2012-01-24 10:33:34 +0100 |
commit | 535ae8974e2405934c44f7c9316d1fdecbc94b13 (patch) | |
tree | ebe8a8bd62aec643955fd512f0615682a36bb037 /web/lib | |
parent | 012bbc09592463b476c5a342bfee960bfa4bb12d (diff) | |
download | taginfo-535ae8974e2405934c44f7c9316d1fdecbc94b13.tar taginfo-535ae8974e2405934c44f7c9316d1fdecbc94b13.tar.gz |
If a tag has no wiki page, but the corresponding key has, suggest looking there on the wiki tab of the tag page.
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/ui/keys_tags.rb | 5 | ||||
-rw-r--r-- | web/lib/utils.rb | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/web/lib/ui/keys_tags.rb b/web/lib/ui/keys_tags.rb index 2782be9..f0a233d 100644 --- a/web/lib/ui/keys_tags.rb +++ b/web/lib/ui/keys_tags.rb @@ -98,7 +98,10 @@ class Taginfo < Sinatra::Base @sel = Hash.new('') @sel[@filter_type] = ' selected="selected"' - @wiki_count = @db.count('wiki.wikipages').condition('value=?', @value).condition('key=?', @key).get_first_value().to_i + @wiki_count = @db.count('wiki.wikipages').condition('key=?', @key).condition('value=?', @value).get_first_value().to_i + if @wiki_count == 0 + @wiki_count_key = @db.count('wiki.wikipages').condition('key=?', @key).condition('value IS NULL').get_first_value().to_i + end @count_all = @db.select('SELECT count_all FROM db.tags').condition('key = ? AND value = ?', @key, @value).get_first_value().to_i @desc = h(@db.select("SELECT description FROM wiki.wikipages WHERE lang=? AND key=? AND value=?", r18n.locale.code, @key, @value).get_first_value()) diff --git a/web/lib/utils.rb b/web/lib/utils.rb index 731f765..c384940 100644 --- a/web/lib/utils.rb +++ b/web/lib/utils.rb @@ -129,13 +129,13 @@ def pp_value(value) return escape_html(value).gsub(/ /, '␣').gsub(/\s/, '<span class="whitespace"> </span>') end -def link_to_key(key) +def link_to_key(key, tab='') k = escape(key) if key.match(/[=\/]/) - return '<a href="/keys/?key=' + k + '">' + pp_key(key) + '</a>' + return '<a href="/keys/?key=' + k + tab + '">' + pp_key(key) + '</a>' else - return '<a href="/keys/' + k + '">' + pp_key(key) + '</a>' + return '<a href="/keys/' + k + tab + '">' + pp_key(key) + '</a>' end end |