Hex Artifact Content
Not logged in

Artifact 73b17a9efb460735e92edf43fff8c9eb5f4043a4:

File src/tagview.c part of check-in [908009fdc4] - Fix a couple of C++-isms in my_page.c and tagview.c. Remove the return value from autosync(). by drh on 2008-05-07 17:38:57.

0000: 2f 2a 0a 2a 2a 20 43 6f 70 79 72 69 67 68 74 20  /*.** Copyright 
0010: 28 63 29 20 32 30 30 37 20 44 2e 20 52 69 63 68  (c) 2007 D. Rich
0020: 61 72 64 20 48 69 70 70 0a 2a 2a 20 43 6f 70 79  ard Hipp.** Copy
0030: 72 69 67 68 74 20 28 63 29 20 32 30 30 38 20 53  right (c) 2008 S
0040: 74 65 70 68 61 6e 20 42 65 61 6c 0a 2a 2a 0a 2a  tephan Beal.**.*
0050: 2a 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69  * This program i
0060: 73 20 66 72 65 65 20 73 6f 66 74 77 61 72 65 3b  s free software;
0070: 20 79 6f 75 20 63 61 6e 20 72 65 64 69 73 74 72   you can redistr
0080: 69 62 75 74 65 20 69 74 20 61 6e 64 2f 6f 72 0a  ibute it and/or.
0090: 2a 2a 20 6d 6f 64 69 66 79 20 69 74 20 75 6e 64  ** modify it und
00a0: 65 72 20 74 68 65 20 74 65 72 6d 73 20 6f 66 20  er the terms of 
00b0: 74 68 65 20 47 4e 55 20 47 65 6e 65 72 61 6c 20  the GNU General 
00c0: 50 75 62 6c 69 63 0a 2a 2a 20 4c 69 63 65 6e 73  Public.** Licens
00d0: 65 20 61 73 20 70 75 62 6c 69 73 68 65 64 20 62  e as published b
00e0: 79 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 77  y the Free Softw
00f0: 61 72 65 20 46 6f 75 6e 64 61 74 69 6f 6e 3b 20  are Foundation; 
0100: 65 69 74 68 65 72 0a 2a 2a 20 76 65 72 73 69 6f  either.** versio
0110: 6e 20 32 20 6f 66 20 74 68 65 20 4c 69 63 65 6e  n 2 of the Licen
0120: 73 65 2c 20 6f 72 20 28 61 74 20 79 6f 75 72 20  se, or (at your 
0130: 6f 70 74 69 6f 6e 29 20 61 6e 79 20 6c 61 74 65  option) any late
0140: 72 20 76 65 72 73 69 6f 6e 2e 0a 2a 2a 0a 2a 2a  r version..**.**
0150: 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73   This program is
0160: 20 64 69 73 74 72 69 62 75 74 65 64 20 69 6e 20   distributed in 
0170: 74 68 65 20 68 6f 70 65 20 74 68 61 74 20 69 74  the hope that it
0180: 20 77 69 6c 6c 20 62 65 20 75 73 65 66 75 6c 2c   will be useful,
0190: 0a 2a 2a 20 62 75 74 20 57 49 54 48 4f 55 54 20  .** but WITHOUT 
01a0: 41 4e 59 20 57 41 52 52 41 4e 54 59 3b 20 77 69  ANY WARRANTY; wi
01b0: 74 68 6f 75 74 20 65 76 65 6e 20 74 68 65 20 69  thout even the i
01c0: 6d 70 6c 69 65 64 20 77 61 72 72 61 6e 74 79 20  mplied warranty 
01d0: 6f 66 0a 2a 2a 20 4d 45 52 43 48 41 4e 54 41 42  of.** MERCHANTAB
01e0: 49 4c 49 54 59 20 6f 72 20 46 49 54 4e 45 53 53  ILITY or FITNESS
01f0: 20 46 4f 52 20 41 20 50 41 52 54 49 43 55 4c 41   FOR A PARTICULA
0200: 52 20 50 55 52 50 4f 53 45 2e 20 20 53 65 65 20  R PURPOSE.  See 
0210: 74 68 65 20 47 4e 55 0a 2a 2a 20 47 65 6e 65 72  the GNU.** Gener
0220: 61 6c 20 50 75 62 6c 69 63 20 4c 69 63 65 6e 73  al Public Licens
0230: 65 20 66 6f 72 20 6d 6f 72 65 20 64 65 74 61 69  e for more detai
0240: 6c 73 2e 0a 2a 2a 0a 2a 2a 20 59 6f 75 20 73 68  ls..**.** You sh
0250: 6f 75 6c 64 20 68 61 76 65 20 72 65 63 65 69 76  ould have receiv
0260: 65 64 20 61 20 63 6f 70 79 20 6f 66 20 74 68 65  ed a copy of the
0270: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62   GNU General Pub
0280: 6c 69 63 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 61  lic.** License a
0290: 6c 6f 6e 67 20 77 69 74 68 20 74 68 69 73 20 6c  long with this l
02a0: 69 62 72 61 72 79 3b 20 69 66 20 6e 6f 74 2c 20  ibrary; if not, 
02b0: 77 72 69 74 65 20 74 6f 20 74 68 65 0a 2a 2a 20  write to the.** 
02c0: 46 72 65 65 20 53 6f 66 74 77 61 72 65 20 46 6f  Free Software Fo
02d0: 75 6e 64 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c 20  undation, Inc., 
02e0: 35 39 20 54 65 6d 70 6c 65 20 50 6c 61 63 65 20  59 Temple Place 
02f0: 2d 20 53 75 69 74 65 20 33 33 30 2c 0a 2a 2a 20  - Suite 330,.** 
0300: 42 6f 73 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31  Boston, MA  0211
0310: 31 2d 31 33 30 37 2c 20 55 53 41 2e 0a 2a 2a 0a  1-1307, USA..**.
0320: 2a 2a 20 41 75 74 68 6f 72 20 63 6f 6e 74 61 63  ** Author contac
0330: 74 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 2a  t information:.*
0340: 2a 20 20 20 64 72 68 40 68 77 61 63 69 2e 63 6f  *   drh@hwaci.co
0350: 6d 0a 2a 2a 20 20 20 68 74 74 70 3a 2f 2f 77 77  m.**   http://ww
0360: 77 2e 68 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f  w.hwaci.com/drh/
0370: 0a 2a 2a 0a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  .**.************
0380: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0390: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
03a0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
03b0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
03c0: 2a 2a 2a 0a 2a 2a 0a 2a 2a 20 49 6d 70 6c 65 6d  ***.**.** Implem
03d0: 65 6e 74 61 74 69 6f 6e 20 6f 66 20 74 68 65 20  entation of the 
03e0: 54 61 67 20 56 69 65 77 20 70 61 67 65 0a 2a 2f  Tag View page.*/
03f0: 0a 23 69 6e 63 6c 75 64 65 20 3c 61 73 73 65 72  .#include <asser
0400: 74 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 22 63  t.h>.#include "c
0410: 6f 6e 66 69 67 2e 68 22 0a 23 69 6e 63 6c 75 64  onfig.h".#includ
0420: 65 20 22 74 61 67 76 69 65 77 2e 68 22 0a 0a 0a  e "tagview.h"...
0430: 23 69 66 20 31 0a 23 20 20 64 65 66 69 6e 65 20  #if 1.#  define 
0440: 54 41 47 56 49 45 57 5f 44 45 46 41 55 4c 54 5f  TAGVIEW_DEFAULT_
0450: 46 49 4c 54 45 52 20 22 41 4e 44 20 74 2e 74 61  FILTER "AND t.ta
0460: 67 6e 61 6d 65 20 4e 4f 54 20 47 4c 4f 42 20 27  gname NOT GLOB '
0470: 77 69 6b 69 2d 2a 27 20 22 0a 23 65 6c 73 65 0a  wiki-*' ".#else.
0480: 23 20 20 64 65 66 69 6e 65 20 54 41 47 56 49 45  #  define TAGVIE
0490: 57 5f 44 45 46 41 55 4c 54 5f 46 49 4c 54 45 52  W_DEFAULT_FILTER
04a0: 0a 23 65 6e 64 69 66 0a 0a 2f 2a 0a 2a 2a 20 4c  .#endif../*.** L
04b0: 69 73 74 73 20 61 6c 6c 20 74 61 67 73 20 6d 61  ists all tags ma
04c0: 74 63 68 69 6e 67 20 74 68 65 20 67 69 76 65 6e  tching the given
04d0: 20 4c 49 4b 45 20 63 6c 61 75 73 65 20 28 77 68   LIKE clause (wh
04e0: 69 63 68 0a 2a 2a 20 6d 61 79 20 62 65 20 30 29  ich.** may be 0)
04f0: 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 76 6f 69 64  ..*/.static void
0500: 20 74 61 67 76 69 65 77 5f 70 61 67 65 5f 6c 69   tagview_page_li
0510: 73 74 5f 74 61 67 73 28 63 6f 6e 73 74 20 63 68  st_tags(const ch
0520: 61 72 20 2a 7a 4c 69 6b 65 29 7b 0a 20 20 63 68  ar *zLike){.  ch
0530: 61 72 20 2a 7a 4c 69 6b 65 43 6c 61 75 73 65 20  ar *zLikeClause 
0540: 3d 20 30 3b 0a 20 20 63 6f 6e 73 74 20 69 6e 74  = 0;.  const int
0550: 20 6c 69 6d 69 74 20 3d 20 31 30 3b 0a 20 20 63   limit = 10;.  c
0560: 68 61 72 20 2a 7a 4c 69 6d 69 74 20 3d 20 30 3b  har *zLimit = 0;
0570: 0a 20 20 63 68 61 72 20 2a 7a 53 71 6c 3b 0a 0a  .  char *zSql;..
0580: 20 20 69 66 28 20 7a 4c 69 6b 65 20 26 26 20 7a    if( zLike && z
0590: 4c 69 6b 65 5b 30 5d 20 29 7b 0a 20 20 20 20 7a  Like[0] ){.    z
05a0: 4c 69 6b 65 43 6c 61 75 73 65 20 3d 20 6d 70 72  LikeClause = mpr
05b0: 69 6e 74 66 28 20 22 41 4e 44 20 74 2e 74 61 67  intf( "AND t.tag
05c0: 6e 61 6d 65 20 4c 49 4b 45 20 27 25 25 25 71 25  name LIKE '%%%q%
05d0: 25 27 22 2c 20 7a 4c 69 6b 65 20 29 3b 0a 20 20  %'", zLike );.  
05e0: 20 20 7a 4c 69 6d 69 74 20 3d 20 22 22 3b 0a 20    zLimit = "";. 
05f0: 20 20 20 40 20 3c 68 32 3e 54 61 67 73 20 6d 61     @ <h2>Tags ma
0600: 74 63 68 69 6e 67 20 5b 25 68 28 7a 4c 69 6b 65  tching [%h(zLike
0610: 43 6c 61 75 73 65 29 5d 3a 3c 2f 68 32 3e 0a 20  Clause)]:</h2>. 
0620: 20 7d 65 6c 73 65 7b 0a 20 20 20 20 7a 4c 69 6d   }else{.    zLim
0630: 69 74 20 3d 20 6d 70 72 69 6e 74 66 28 20 22 4c  it = mprintf( "L
0640: 49 4d 49 54 20 25 64 22 2c 20 6c 69 6d 69 74 20  IMIT %d", limit 
0650: 29 3b 0a 20 20 20 20 7a 4c 69 6b 65 43 6c 61 75  );.    zLikeClau
0660: 73 65 20 3d 20 22 22 3b 0a 20 20 20 20 40 20 3c  se = "";.    @ <
0670: 68 32 3e 25 64 28 6c 69 6d 69 74 29 20 6d 6f 73  h2>%d(limit) mos
0680: 74 20 72 65 63 65 6e 74 20 74 61 67 73 3a 3c 2f  t recent tags:</
0690: 68 32 3e 0a 20 20 7d 0a 20 20 7a 53 71 6c 20 3d  h2>.  }.  zSql =
06a0: 20 6d 70 72 69 6e 74 66 28 20 0a 20 20 20 20 22   mprintf( .    "
06b0: 53 45 4c 45 43 54 20 22 0a 20 20 20 20 22 20 20  SELECT ".    "  
06c0: 20 6c 69 6e 6b 74 61 67 69 64 28 74 2e 74 61 67   linktagid(t.tag
06d0: 69 64 29 20 41 53 20 27 54 61 67 20 49 44 27 2c  id) AS 'Tag ID',
06e0: 22 0a 20 20 20 20 22 20 20 20 6c 69 6e 6b 74 61  ".    "   linkta
06f0: 67 6e 61 6d 65 28 74 2e 74 61 67 6e 61 6d 65 29  gname(t.tagname)
0700: 20 41 53 20 27 4e 61 6d 65 27 2c 22 0a 20 20 20   AS 'Name',".   
0710: 20 22 20 20 20 44 41 54 45 54 49 4d 45 28 74 78   "   DATETIME(tx
0720: 2e 6d 74 69 6d 65 29 20 41 53 20 27 54 69 6d 65  .mtime) AS 'Time
0730: 73 74 61 6d 70 27 2c 22 0a 20 20 20 20 22 20 20  stamp',".    "  
0740: 20 6c 69 6e 6b 75 75 69 64 28 62 2e 75 75 69 64   linkuuid(b.uuid
0750: 29 20 41 53 20 27 56 65 72 73 69 6f 6e 27 22 0a  ) AS 'Version'".
0760: 20 20 20 20 22 20 20 46 52 4f 4d 20 74 61 67 20      "  FROM tag 
0770: 74 2c 20 74 61 67 78 72 65 66 20 74 78 2c 20 62  t, tagxref tx, b
0780: 6c 6f 62 20 62 20 22 0a 20 20 20 20 22 20 57 48  lob b ".    " WH
0790: 45 52 45 20 74 2e 74 61 67 69 64 3d 74 78 2e 74  ERE t.tagid=tx.t
07a0: 61 67 69 64 20 41 4e 44 20 74 78 2e 73 72 63 69  agid AND tx.srci
07b0: 64 3d 62 2e 72 69 64 22 0a 20 20 20 20 22 20 20  d=b.rid".    "  
07c0: 20 41 4e 44 20 74 78 2e 74 61 67 74 79 70 65 21   AND tx.tagtype!
07d0: 3d 30 20 25 73 20 22 0a 20 20 20 20 54 41 47 56  =0 %s ".    TAGV
07e0: 49 45 57 5f 44 45 46 41 55 4c 54 5f 46 49 4c 54  IEW_DEFAULT_FILT
07f0: 45 52 0a 20 20 20 20 22 20 4f 52 44 45 52 20 42  ER.    " ORDER B
0800: 59 20 74 78 2e 6d 74 69 6d 65 20 44 45 53 43 20  Y tx.mtime DESC 
0810: 25 73 22 2c 0a 20 20 20 20 7a 4c 69 6b 65 43 6c  %s",.    zLikeCl
0820: 61 75 73 65 2c 20 7a 4c 69 6d 69 74 0a 20 20 29  ause, zLimit.  )
0830: 3b 0a 20 20 64 62 5f 67 65 6e 65 72 69 63 5f 71  ;.  db_generic_q
0840: 75 65 72 79 5f 76 69 65 77 28 7a 53 71 6c 2c 20  uery_view(zSql, 
0850: 31 29 3b 0a 20 20 66 72 65 65 28 7a 53 71 6c 29  1);.  free(zSql)
0860: 3b 0a 20 20 69 66 28 20 7a 4c 69 6b 65 43 6c 61  ;.  if( zLikeCla
0870: 75 73 65 5b 30 5d 20 29 20 66 72 65 65 28 7a 4c  use[0] ) free(zL
0880: 69 6b 65 43 6c 61 75 73 65 29 3b 0a 20 20 69 66  ikeClause);.  if
0890: 28 20 7a 4c 69 6d 69 74 5b 30 5d 20 29 20 66 72  ( zLimit[0] ) fr
08a0: 65 65 28 7a 4c 69 6d 69 74 29 3b 0a 7d 0a 0a 2f  ee(zLimit);.}../
08b0: 2a 0a 2a 2a 20 41 20 73 6d 61 6c 6c 20 73 65 61  *.** A small sea
08c0: 72 63 68 20 66 6f 72 6d 20 77 68 69 63 68 20 66  rch form which f
08d0: 6f 72 77 61 72 64 73 20 74 6f 20 3f 6c 69 6b 65  orwards to ?like
08e0: 3d 53 45 41 52 43 48 5f 53 54 52 49 4e 47 0a 2a  =SEARCH_STRING.*
08f0: 2f 0a 73 74 61 74 69 63 20 76 6f 69 64 20 74 61  /.static void ta
0900: 67 76 69 65 77 5f 70 61 67 65 5f 73 65 61 72 63  gview_page_searc
0910: 68 5f 6d 69 6e 69 66 6f 72 6d 28 76 6f 69 64 29  h_miniform(void)
0920: 7b 0a 20 20 63 68 61 72 20 63 6f 6e 73 74 20 2a  {.  char const *
0930: 20 6c 69 6b 65 20 3d 20 50 28 22 6c 69 6b 65 22   like = P("like"
0940: 29 3b 0a 20 20 40 20 3c 64 69 76 20 73 74 79 6c  );.  @ <div styl
0950: 65 3d 27 66 6f 6e 74 2d 73 69 7a 65 3a 73 6d 61  e='font-size:sma
0960: 6c 6c 65 72 27 3e 0a 20 20 40 20 3c 66 6f 72 6d  ller'>.  @ <form
0970: 20 61 63 74 69 6f 6e 3d 27 2f 74 61 67 76 69 65   action='/tagvie
0980: 77 27 20 6d 65 74 68 6f 64 3d 27 70 6f 73 74 27  w' method='post'
0990: 3e 0a 20 20 40 20 53 65 61 72 63 68 20 66 6f 72  >.  @ Search for
09a0: 20 74 61 67 73 3a 20 0a 20 20 40 20 3c 69 6e 70   tags: .  @ <inp
09b0: 75 74 20 74 79 70 65 3d 27 74 65 78 74 27 20 6e  ut type='text' n
09c0: 61 6d 65 3d 27 6c 69 6b 65 27 20 76 61 6c 75 65  ame='like' value
09d0: 3d 27 25 68 28 28 6c 69 6b 65 3f 6c 69 6b 65 3a  ='%h((like?like:
09e0: 22 22 29 29 27 20 73 69 7a 65 3d 27 31 30 27 2f  ""))' size='10'/
09f0: 3e 0a 20 20 40 20 3c 69 6e 70 75 74 20 74 79 70  >.  @ <input typ
0a00: 65 3d 27 73 75 62 6d 69 74 27 2f 3e 0a 20 20 40  e='submit'/>.  @
0a10: 20 3c 2f 66 6f 72 6d 3e 0a 20 20 40 20 3c 2f 64   </form>.  @ </d
0a20: 69 76 3e 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 74 61 67  iv>.}../*.** tag
0a30: 76 69 65 77 5f 70 61 67 65 5f 64 65 66 61 75 6c  view_page_defaul
0a40: 74 28 29 20 72 65 6e 64 65 72 73 20 74 68 65 20  t() renders the 
0a50: 64 65 66 61 75 6c 74 20 70 61 67 65 20 66 6f 72  default page for
0a60: 20 74 61 67 76 69 65 77 5f 70 61 67 65 28 29 2e   tagview_page().
0a70: 0a 2a 2f 0a 73 74 61 74 69 63 20 76 6f 69 64 20  .*/.static void 
0a80: 74 61 67 76 69 65 77 5f 70 61 67 65 5f 64 65 66  tagview_page_def
0a90: 61 75 6c 74 28 76 6f 69 64 29 7b 0a 20 20 74 61  ault(void){.  ta
0aa0: 67 76 69 65 77 5f 70 61 67 65 5f 6c 69 73 74 5f  gview_page_list_
0ab0: 74 61 67 73 28 20 30 20 29 3b 0a 7d 0a 0a 2f 2a  tags( 0 );.}../*
0ac0: 0a 2a 2a 20 4c 69 73 74 73 20 61 6c 6c 20 74 61  .** Lists all ta
0ad0: 67 73 20 6d 61 74 63 68 69 6e 67 20 74 68 65 20  gs matching the 
0ae0: 67 69 76 65 6e 20 74 61 67 69 64 2e 0a 2a 2f 0a  given tagid..*/.
0af0: 73 74 61 74 69 63 20 76 6f 69 64 20 74 61 67 76  static void tagv
0b00: 69 65 77 5f 70 61 67 65 5f 74 61 67 5f 62 79 5f  iew_page_tag_by_
0b10: 69 64 28 20 69 6e 74 20 74 61 67 69 64 20 29 7b  id( int tagid ){
0b20: 0a 20 20 63 68 61 72 20 2a 7a 53 71 6c 3b 0a 20  .  char *zSql;. 
0b30: 20 40 20 3c 68 32 3e 54 61 67 20 23 25 64 28 74   @ <h2>Tag #%d(t
0b40: 61 67 69 64 29 3a 3c 2f 68 32 3e 0a 20 20 7a 53  agid):</h2>.  zS
0b50: 71 6c 20 3d 20 6d 70 72 69 6e 74 66 28 20 0a 20  ql = mprintf( . 
0b60: 20 20 20 22 53 45 4c 45 43 54 20 44 49 53 54 49     "SELECT DISTI
0b70: 4e 43 54 22 0a 20 20 20 20 22 20 20 20 20 20 20  NCT".    "      
0b80: 20 6c 69 6e 6b 74 61 67 6e 61 6d 65 28 74 2e 74   linktagname(t.t
0b90: 61 67 6e 61 6d 65 29 20 41 53 20 27 54 61 67 20  agname) AS 'Tag 
0ba0: 4e 61 6d 65 27 2c 22 0a 20 20 20 20 22 20 20 20  Name',".    "   
0bb0: 20 20 20 20 44 41 54 45 54 49 4d 45 28 74 78 2e      DATETIME(tx.
0bc0: 6d 74 69 6d 65 29 20 41 53 20 27 54 69 6d 65 73  mtime) AS 'Times
0bd0: 74 61 6d 70 27 2c 22 0a 20 20 20 20 22 20 20 20  tamp',".    "   
0be0: 20 20 20 20 6c 69 6e 6b 75 75 69 64 28 62 2e 75      linkuuid(b.u
0bf0: 75 69 64 29 20 41 53 20 27 56 65 72 73 69 6f 6e  uid) AS 'Version
0c00: 27 22 0a 20 20 20 20 22 20 20 46 52 4f 4d 20 74  '".    "  FROM t
0c10: 61 67 20 74 2c 20 74 61 67 78 72 65 66 20 74 78  ag t, tagxref tx
0c20: 2c 20 62 6c 6f 62 20 62 22 0a 20 20 20 20 22 20  , blob b".    " 
0c30: 57 48 45 52 45 20 74 2e 74 61 67 69 64 3d 25 64  WHERE t.tagid=%d
0c40: 20 41 4e 44 20 74 2e 74 61 67 69 64 3d 74 78 2e   AND t.tagid=tx.
0c50: 74 61 67 69 64 20 41 4e 44 20 74 78 2e 73 72 63  tagid AND tx.src
0c60: 69 64 3d 62 2e 72 69 64 20 22 0a 20 20 20 20 54  id=b.rid ".    T
0c70: 41 47 56 49 45 57 5f 44 45 46 41 55 4c 54 5f 46  AGVIEW_DEFAULT_F
0c80: 49 4c 54 45 52 0a 20 20 20 20 22 20 4f 52 44 45  ILTER.    " ORDE
0c90: 52 20 42 59 20 74 78 2e 6d 74 69 6d 65 20 44 45  R BY tx.mtime DE
0ca0: 53 43 22 2c 0a 20 20 20 20 74 61 67 69 64 0a 20  SC",.    tagid. 
0cb0: 20 29 3b 0a 20 20 64 62 5f 67 65 6e 65 72 69 63   );.  db_generic
0cc0: 5f 71 75 65 72 79 5f 76 69 65 77 28 7a 53 71 6c  _query_view(zSql
0cd0: 2c 20 31 29 3b 0a 20 20 66 72 65 65 28 7a 53 71  , 1);.  free(zSq
0ce0: 6c 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 4c 69 73  l);.}../*.** Lis
0cf0: 74 73 20 61 6c 6c 20 74 61 67 73 20 6d 61 74 63  ts all tags matc
0d00: 68 69 6e 67 20 74 68 65 20 67 69 76 65 6e 20 74  hing the given t
0d10: 61 67 20 6e 61 6d 65 2e 0a 2a 2f 0a 73 74 61 74  ag name..*/.stat
0d20: 69 63 20 76 6f 69 64 20 74 61 67 76 69 65 77 5f  ic void tagview_
0d30: 70 61 67 65 5f 74 61 67 5f 62 79 5f 6e 61 6d 65  page_tag_by_name
0d40: 28 20 63 68 61 72 20 63 6f 6e 73 74 20 2a 20 74  ( char const * t
0d50: 61 67 6e 61 6d 65 20 29 7b 0a 20 20 63 68 61 72  agname ){.  char
0d60: 20 2a 7a 53 71 6c 3b 0a 20 20 40 20 3c 68 32 3e   *zSql;.  @ <h2>
0d70: 54 61 67 20 27 25 73 28 74 61 67 6e 61 6d 65 29  Tag '%s(tagname)
0d80: 27 3a 3c 2f 68 32 3e 0a 20 20 7a 53 71 6c 20 3d  ':</h2>.  zSql =
0d90: 20 6d 70 72 69 6e 74 66 28 20 0a 20 20 20 20 22   mprintf( .    "
0da0: 53 45 4c 45 43 54 20 44 49 53 54 49 4e 43 54 22  SELECT DISTINCT"
0db0: 0a 20 20 20 20 22 20 20 20 20 20 20 20 6c 69 6e  .    "       lin
0dc0: 6b 74 61 67 69 64 28 74 2e 74 61 67 69 64 29 20  ktagid(t.tagid) 
0dd0: 41 53 20 27 54 61 67 20 49 44 27 2c 22 0a 20 20  AS 'Tag ID',".  
0de0: 20 20 22 20 20 20 20 20 20 20 44 41 54 45 54 49    "       DATETI
0df0: 4d 45 28 74 78 2e 6d 74 69 6d 65 29 20 41 53 20  ME(tx.mtime) AS 
0e00: 27 54 69 6d 65 73 74 61 6d 70 27 2c 22 0a 20 20  'Timestamp',".  
0e10: 20 20 22 20 20 20 20 20 20 20 6c 69 6e 6b 75 75    "       linkuu
0e20: 69 64 28 62 2e 75 75 69 64 29 20 41 53 20 27 56  id(b.uuid) AS 'V
0e30: 65 72 73 69 6f 6e 27 22 0a 20 20 20 20 22 20 20  ersion'".    "  
0e40: 46 52 4f 4d 20 74 61 67 20 74 2c 20 74 61 67 78  FROM tag t, tagx
0e50: 72 65 66 20 74 78 2c 20 62 6c 6f 62 20 62 20 22  ref tx, blob b "
0e60: 0a 20 20 20 20 22 20 57 48 45 52 45 20 74 2e 74  .    " WHERE t.t
0e70: 61 67 6e 61 6d 65 3d 27 25 71 27 20 41 4e 44 20  agname='%q' AND 
0e80: 74 2e 74 61 67 69 64 3d 74 78 2e 74 61 67 69 64  t.tagid=tx.tagid
0e90: 20 41 4e 44 20 74 78 2e 73 72 63 69 64 3d 62 2e   AND tx.srcid=b.
0ea0: 72 69 64 20 22 0a 20 20 20 20 54 41 47 56 49 45  rid ".    TAGVIE
0eb0: 57 5f 44 45 46 41 55 4c 54 5f 46 49 4c 54 45 52  W_DEFAULT_FILTER
0ec0: 0a 20 20 20 20 22 20 4f 52 44 45 52 20 42 59 20  .    " ORDER BY 
0ed0: 74 78 2e 6d 74 69 6d 65 20 44 45 53 43 22 2c 0a  tx.mtime DESC",.
0ee0: 20 20 20 20 74 61 67 6e 61 6d 65 29 3b 0a 20 20      tagname);.  
0ef0: 64 62 5f 67 65 6e 65 72 69 63 5f 71 75 65 72 79  db_generic_query
0f00: 5f 76 69 65 77 28 7a 53 71 6c 2c 20 31 29 3b 0a  _view(zSql, 1);.
0f10: 20 20 66 72 65 65 28 7a 53 71 6c 29 3b 0a 7d 0a    free(zSql);.}.
0f20: 0a 0a 2f 2a 0a 2a 2a 20 57 45 42 50 41 47 45 3a  ../*.** WEBPAGE:
0f30: 20 2f 74 61 67 76 69 65 77 0a 2a 2f 0a 76 6f 69   /tagview.*/.voi
0f40: 64 20 74 61 67 76 69 65 77 5f 70 61 67 65 28 76  d tagview_page(v
0f50: 6f 69 64 29 7b 0a 20 20 63 68 61 72 20 63 6f 6e  oid){.  char con
0f60: 73 74 20 2a 20 63 68 65 63 6b 20 3d 20 30 3b 0a  st * check = 0;.
0f70: 20 20 6c 6f 67 69 6e 5f 63 68 65 63 6b 5f 63 72    login_check_cr
0f80: 65 64 65 6e 74 69 61 6c 73 28 29 3b 0a 20 20 69  edentials();.  i
0f90: 66 28 20 21 67 2e 6f 6b 52 64 57 69 6b 69 20 29  f( !g.okRdWiki )
0fa0: 7b 0a 20 20 20 20 6c 6f 67 69 6e 5f 6e 65 65 64  {.    login_need
0fb0: 65 64 28 29 3b 0a 20 20 7d 0a 20 20 73 74 79 6c  ed();.  }.  styl
0fc0: 65 5f 68 65 61 64 65 72 28 22 54 61 67 73 22 29  e_header("Tags")
0fd0: 3b 0a 20 20 6c 6f 67 69 6e 5f 61 6e 6f 6e 79 6d  ;.  login_anonym
0fe0: 6f 75 73 5f 61 76 61 69 6c 61 62 6c 65 28 29 3b  ous_available();
0ff0: 0a 20 20 74 61 67 76 69 65 77 5f 70 61 67 65 5f  .  tagview_page_
1000: 73 65 61 72 63 68 5f 6d 69 6e 69 66 6f 72 6d 28  search_miniform(
1010: 29 3b 0a 20 20 40 20 3c 68 72 2f 3e 0a 20 20 69  );.  @ <hr/>.  i
1020: 66 28 20 30 20 21 3d 20 28 63 68 65 63 6b 20 3d  f( 0 != (check =
1030: 20 50 28 22 74 61 67 69 64 22 29 29 20 29 7b 0a   P("tagid")) ){.
1040: 20 20 20 20 74 61 67 76 69 65 77 5f 70 61 67 65      tagview_page
1050: 5f 74 61 67 5f 62 79 5f 69 64 28 20 61 74 6f 69  _tag_by_id( atoi
1060: 28 63 68 65 63 6b 29 20 29 3b 0a 20 20 7d 65 6c  (check) );.  }el
1070: 73 65 20 69 66 28 20 30 20 21 3d 20 28 63 68 65  se if( 0 != (che
1080: 63 6b 20 3d 20 50 28 22 6c 69 6b 65 22 29 29 20  ck = P("like")) 
1090: 29 7b 0a 20 20 20 20 74 61 67 76 69 65 77 5f 70  ){.    tagview_p
10a0: 61 67 65 5f 6c 69 73 74 5f 74 61 67 73 28 20 63  age_list_tags( c
10b0: 68 65 63 6b 20 29 3b 0a 20 20 7d 65 6c 73 65 20  heck );.  }else 
10c0: 69 66 28 20 30 20 21 3d 20 28 63 68 65 63 6b 20  if( 0 != (check 
10d0: 3d 20 50 28 22 6e 61 6d 65 22 29 29 20 29 7b 0a  = P("name")) ){.
10e0: 20 20 20 20 74 61 67 76 69 65 77 5f 70 61 67 65      tagview_page
10f0: 5f 74 61 67 5f 62 79 5f 6e 61 6d 65 28 20 63 68  _tag_by_name( ch
1100: 65 63 6b 20 29 3b 0a 20 20 7d 65 6c 73 65 7b 0a  eck );.  }else{.
1110: 20 20 20 20 74 61 67 76 69 65 77 5f 70 61 67 65      tagview_page
1120: 5f 64 65 66 61 75 6c 74 28 29 3b 0a 20 20 7d 0a  _default();.  }.
1130: 20 20 73 74 79 6c 65 5f 66 6f 6f 74 65 72 28 29    style_footer()
1140: 3b 0a 7d 0a 0a 23 75 6e 64 65 66 20 54 41 47 56  ;.}..#undef TAGV
1150: 49 45 57 5f 44 45 46 41 55 4c 54 5f 46 49 4c 54  IEW_DEFAULT_FILT
1160: 45 52 0a                                         ER.