Fossil

Check-in [a1028240]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update src/rss.c with latest version from dg-misc branch (original at [01e85ec4]).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | timeline-rss-ticket
Files: files | file ages | folders
SHA1:a10282407c3013153c670e4276e3a1aabe3d93ce
User & Date: dg 2013-02-12 16:57:55
Context
2013-02-18
21:45
/info/TICKET_UUID now only shows the ticket title if the ticket db has a title field. Closed-Leaf check-in: 1c46835e user: stephan tags: timeline-rss-ticket
2013-02-12
16:57
Update src/rss.c with latest version from dg-misc branch (original at [01e85ec4]). check-in: a1028240 user: dg tags: timeline-rss-ticket
10:08
timeline.rss with single-ticket support, based on David Given's patch. check-in: 1bc09124 user: stephan tags: timeline-rss-ticket
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/rss.c.

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49



50
51
52
53
54
55
56
57
58
59
60
61
62

63
64
65
66
67
68
69
...
104
105
106
107
108
109
110
111
112



113
114
115





116
117
118





119


120








121
122
123
124
125
126
127
128
** This file contains code used to create a RSS feed for the CGI interface.
*/
#include "config.h"
#include <time.h>
#include "rss.h"
#include <assert.h>

static int append_tag_filter(Blob* bSQL, const char* zName, const char* zType)
{
  if ( zName ){
    int nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB '%s-%q*'",
      zType, zName);
    if ( nTagId == 0 ){
      return 0;
    }
    blob_appendf(bSQL, " AND objid IN (SELECT rid FROM tagxref WHERE tagid=%d)", nTagId);
  }
  return 1;
}

/*
** WEBPAGE: timeline.rss
** URL:  /timeline.rss/y=TYPE&n=LIMIT&tkt=UUID&tag=TAG&name=FILENAME&wiki=NAME
**
** Produce an RSS feed of the timeline.
**
** TYPE may be: all, ci (show checkins only), t (show tickets only),
** w (show wiki only). LIMIT is the number of items to show.
**
** tkt=UUID filters for only those events for the specified ticket. tag=TAG
** filters for a tag, and name=FILENAME for a file. Some combinations may be
** used.



*/

void page_timeline_rss(void){
  Stmt q;
  int nLine=0;
  char *zPubDate, *zProjectName, *zProjectDescr, *zFreeProjectName=0;
  Blob bSQL;
  const char *zType = PD("y","all"); /* Type of events.  All if NULL */
  const char *zTicketUuid = PD("tkt",NULL);
  const char *zTag = PD("tag",NULL);
  const char *zFilename = PD("name",NULL);
  const char *zWiki = PD("wiki",NULL);
  int nLimit = atoi(PD("n","20"));

  const char zSQL1[] =
    @ SELECT
    @   blob.rid,
    @   uuid,
    @   event.mtime,
    @   coalesce(ecomment,comment),
    @   coalesce(euser,user),
................................................................................
      }
    }else if( !g.perm.RdTkt ){
      assert( !g.perm.RdTkt &&& g.perm.Read && g.perm.RdWiki );
      blob_append(&bSQL, " AND event.type!='t'", -1);
    }
  }

  if( !append_tag_filter(&bSQL, zTicketUuid, "tkt") ){
    return;



  }
  if( !append_tag_filter(&bSQL, zTag, "sym") ){
    return;





  }
  if( !append_tag_filter(&bSQL, zWiki, "wiki") ){
    return;





  }











  if ( zFilename ){
    blob_appendf(&bSQL,
      " AND (SELECT mlink.fnid FROM mlink WHERE event.objid=mlink.mid) IN (SELECT fnid FROM filename WHERE name=%Q %s)",
        zFilename, filename_collation()
    );
  }

  blob_append( &bSQL, " ORDER BY event.mtime DESC", -1 );







<
<
<
<
<
<
<
<
<
<
<
<
<


|







|
|
>
>
>













>







 







|
|
>
>
>
|
<
<
>
>
>
>
>
|
<
<
>
>
>
>
>
|
>
>
|
>
>
>
>
>
>
>
>
|







18
19
20
21
22
23
24













25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
95
96
97
98
99
100
101
102
103
104
105
106
107


108
109
110
111
112
113


114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
** This file contains code used to create a RSS feed for the CGI interface.
*/
#include "config.h"
#include <time.h>
#include "rss.h"
#include <assert.h>














/*
** WEBPAGE: timeline.rss
** URL:  /timeline.rss/y=TYPE&n=LIMIT&tkt=UUID&tag=TAG&wiki=NAME&name=FILENAME
**
** Produce an RSS feed of the timeline.
**
** TYPE may be: all, ci (show checkins only), t (show tickets only),
** w (show wiki only). LIMIT is the number of items to show.
**
** tkt=UUID filters for only those events for the specified ticket. tag=TAG
** filters for a tag, and wiki=NAME for a wiki page. Only one may be used.
**
** In addition, name=FILENAME filters for a specific file. This may be
** combined with one of the other filters (useful for looking at a specific
** branch).
*/

void page_timeline_rss(void){
  Stmt q;
  int nLine=0;
  char *zPubDate, *zProjectName, *zProjectDescr, *zFreeProjectName=0;
  Blob bSQL;
  const char *zType = PD("y","all"); /* Type of events.  All if NULL */
  const char *zTicketUuid = PD("tkt",NULL);
  const char *zTag = PD("tag",NULL);
  const char *zFilename = PD("name",NULL);
  const char *zWiki = PD("wiki",NULL);
  int nLimit = atoi(PD("n","20"));
  int nTagId;
  const char zSQL1[] =
    @ SELECT
    @   blob.rid,
    @   uuid,
    @   event.mtime,
    @   coalesce(ecomment,comment),
    @   coalesce(euser,user),
................................................................................
      }
    }else if( !g.perm.RdTkt ){
      assert( !g.perm.RdTkt &&& g.perm.Read && g.perm.RdWiki );
      blob_append(&bSQL, " AND event.type!='t'", -1);
    }
  }

  if( zTicketUuid ){
    nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",
      zTicketUuid);
    if ( nTagId==0 ){
      nTagId = -1;
    }


  }else if( zTag ){
    nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'sym-%q*'",
      zTag);
    if ( nTagId==0 ){
      nTagId = -1;
    }


  }else if( zWiki ){
    nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'wiki-%q*'",
      zWiki);
    if ( nTagId==0 ){
      nTagId = -1;
    }
  }else{
    nTagId = 0;
  }

  if( nTagId==-1 ){
    blob_appendf(&bSQL, " AND 0");
  }else if( nTagId!=0 ){
    blob_appendf(&bSQL, " AND (EXISTS(SELECT 1 FROM tagxref"
      " WHERE tagid=%d AND tagtype>0 AND rid=blob.rid))", nTagId);
  }

  if( zFilename ){
    blob_appendf(&bSQL,
      " AND (SELECT mlink.fnid FROM mlink WHERE event.objid=mlink.mid) IN (SELECT fnid FROM filename WHERE name=%Q %s)",
        zFilename, filename_collation()
    );
  }

  blob_append( &bSQL, " ORDER BY event.mtime DESC", -1 );