Mercurial > hg > egg-tcls
diff quotedb.tcl @ 482:0e50c8440ea2
quotedb: Add img: image URL support.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 22 Oct 2019 17:45:22 +0300 |
parents | 32f0aba3ab9b |
children | f31cb0b7d0c0 |
line wrap: on
line diff
--- a/quotedb.tcl Tue Oct 22 17:43:51 2019 +0300 +++ b/quotedb.tcl Tue Oct 22 17:45:22 2019 +0300 @@ -288,7 +288,7 @@ #------------------------------------------------------------------------- -proc qdb_get {ufmt utable unick uchan uindex upublic} { +proc qdb_get {ufmt utable unick uchan uindex upublic urlprefix} { global qdb_handle qdb_msg_no_matches set usql "SELECT total(${utable}_votes.vote) AS uvote, ${utable}.id AS quoteID, ${utable}.utext AS utext, ${utable}.utime AS utime, ${utable}.user AS uuser FROM ${utable} LEFT JOIN ${utable}_votes ON ${utable}_votes.urlid = ${utable}.id" @@ -307,6 +307,9 @@ } qdb_handle eval $usql { + if {[string range $utext 0 3] == "img:"} { + set utext "${urlprefix}[string range $utext 4 end]" + } if {$ufmt != ""} { qdb_msg $upublic $unick $uchan $ufmt [list $quoteID $utext $uuser [utl_ctime $utime] $uvote] } else { @@ -389,7 +392,7 @@ #------------------------------------------------------------------------- -proc qdb_command {ucmd utable unick uhost uhand uchan utext upublic ufmt_get} { +proc qdb_command {ucmd utable unick uhost uhand uchan utext upublic ufmt_get urlprefix} { global qdb_msg_help qdb_channels if {$upublic && ![utl_match_delim_list $qdb_channels $uchan]} { @@ -400,16 +403,16 @@ if {$utext == "" || $utext == {}} { # No arguments, assume random query - qdb_get $ufmt_get $utable $unick $uchan -1 $upublic + qdb_get $ufmt_get $utable $unick $uchan -1 $upublic $urlprefix } elseif {[regexp {^(stat|stats|tilasto|tilastot)$} $utext umatch]} { # Statistics qdb_stats $utable $unick $uchan $upublic } elseif {[regexp {^(last|latest|uusin|viimeisin)$} $utext umatch]} { # Latest added - qdb_get $ufmt_get $utable $unick $uchan -2 $upublic + qdb_get $ufmt_get $utable $unick $uchan -2 $upublic $urlprefix } elseif {[regexp {^([0-9]+)$} $utext umatch unum]} { # Numeric argument, assume index query - qdb_get $ufmt_get $utable $unick $uchan $unum $upublic + qdb_get $ufmt_get $utable $unick $uchan $unum $upublic $urlprefix } elseif {[regexp {^top\s*([0-9]+)$} $utext umatch unum]} { # Toplist of quotes qdb_toplist $utable $unick $uchan $unum $upublic