CVSTrac Legacy Code

Check-in [340df5c3bf]
Login

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

Overview
Comment:(#791) fine tune the report RSS output. This makes it reasonably functional, although I'm not entirely happy with how dates are(n't) managed.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:340df5c3bfde3e12d4961208d08c042d07606a30
User & Date: cpb 2009-03-14 02:07:41
Context
2009-03-27
13:40
add support for incoming {link:http://trac.edgewall.org/wiki/InterTrac InterTrac} links. This allows Trac sites to reference CVSTrac objects most naturally.

Outgoing InterTrac links _from_ a CVSTrac install can be accomplished with custom markup, as in:

{quote:%x}

which would be referenced via something like:

{quote:{<markup>: ticket:451 #451}} {quote:{trac: wiki:InterTrac InterTrac}}
check-in: ede2546f24 user: cpb tags: trunk
2009-03-14
02:07
(#791) fine tune the report RSS output. This makes it reasonably functional, although I'm not entirely happy with how dates are(n't) managed. check-in: 340df5c3bf user: cpb tags: trunk
2009-03-13
02:22
(#783) direct inspections to the appropriate positions in chngview from both the timeline, RSS, as well as after sumitting them. check-in: 3b02e5ca7d user: cpb tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to view.c.

702
703
704
705
706
707
708
















709
710
711
712
713
714
715
...
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
...
952
953
954
955
956
957
958


959
960
961
962
963
964
965
966
967
968
969
970

971

972
973

974
975


976

977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002


1003

1004
1005



1006
1007
1008
1009
1010
1011
1012
  @    wiki(substr(description,0,80)) AS 'Description'
  @  FROM ticket
  @ </pre></blockquote>
  @
}

/*********************************************************************/
















static void output_report_field(const char *zData,int rn){
  const char *zWkey = wiki_key();
  const char *zTkey = tkt_key();
  const char *zCkey = chng_key();

  if( !strncmp(zData,zWkey,strlen(zWkey)) ){
    output_formatted(&zData[strlen(zWkey)],0);
................................................................................
  char **azArg,    /* Text of data in all columns */
  char **azName    /* Names of the columns */
){
  struct GenerateHTML* pState = (struct GenerateHTML*)pUser;
  int i;
  int rn;            /* Report number */
  int iBg = -1;      /* Index of column that determines background color */
  char *zTitle = NULL;
  char *zDesc = NULL;

  /* Get the report number
  */
  rn = pState->rn;

  /* Figure out the column that determines background color */
................................................................................
  if( azArg==0 ){
    return 0;
  }

  ++pState->nCount;

  /* Output the data for this entry from the database


  */
  {
    /* we'll need to restore this later */
    int n=0, n2=0;
    char *zContent = cgi_extract_content(&n);

    for(i=0; i<nArg; i++){
      char *zData = azArg[i];
      if( zData == NULL ) continue;
      if( i==iBg ) continue;

      if( azName[i][0] == '_' ) {

        if( zData[0] ){

          output_formatted("\n----\n", NULL);
          output_formatted(zData, 0);

        }
      }else if( azName[i][0]=='#' ){


        output_ticket(atoi(zData),rn);

      }else{
        if( zTitle==NULL ){
          @ %h(zData)
        }else{
          @ %h(azName[i]): \
          output_report_field(zData,rn);
        }
      }
      if( zTitle==NULL ){
        /* first "good" column will be the title. The content of the
        ** title won't be found in the body.
        */
        zTitle = cgi_extract_content(&n2);
      }else {
        @ <br />
      }
    }

    zDesc = cgi_extract_content(&n2);

    /* restore the original buffer */
    cgi_append_content(zContent,n);
    if( zContent ) free(zContent);
  }

  @ <item>


  @ <title>%h(zTitle)</title>

  @ <description>%h(zDesc)</description>
  @ </item>




  return 0;
}

/*
** Output the text given in the argument.  Convert tabs and newlines into
** spaces.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







>
>












>

>


>


>
>

>

|
<
<
|
|
<
<
<
<
<
<
<
<
|











>
>
|
>


>
>
>







702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
...
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
...
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002


1003
1004








1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
  @    wiki(substr(description,0,80)) AS 'Description'
  @  FROM ticket
  @ </pre></blockquote>
  @
}

/*********************************************************************/
static char* format_report_field(const char *zData){
  const char *zWkey = wiki_key();
  const char *zTkey = tkt_key();
  const char *zCkey = chng_key();

  if( !strncmp(zData,zWkey,strlen(zWkey)) ){
    /* FIXME: might be better to concatenate this or something? */
    return strdup(&zData[strlen(zWkey)]);
  }else if( !strncmp(zData,zTkey,strlen(zTkey)) ){
    return mprintf("#%s", &zData[strlen(zTkey)]);
  }else if( !strncmp(zData,zCkey,strlen(zCkey)) ){
    return mprintf("[%s]", &zData[strlen(zCkey)]);
  }
  return strdup(zData);
}

static void output_report_field(const char *zData,int rn){
  const char *zWkey = wiki_key();
  const char *zTkey = tkt_key();
  const char *zCkey = chng_key();

  if( !strncmp(zData,zWkey,strlen(zWkey)) ){
    output_formatted(&zData[strlen(zWkey)],0);
................................................................................
  char **azArg,    /* Text of data in all columns */
  char **azName    /* Names of the columns */
){
  struct GenerateHTML* pState = (struct GenerateHTML*)pUser;
  int i;
  int rn;            /* Report number */
  int iBg = -1;      /* Index of column that determines background color */
  const char *zTitle = NULL;
  char *zDesc = NULL;

  /* Get the report number
  */
  rn = pState->rn;

  /* Figure out the column that determines background color */
................................................................................
  if( azArg==0 ){
    return 0;
  }

  ++pState->nCount;

  /* Output the data for this entry from the database
  ** FIXME: it might be useful to recognize the common forms of
  ** sdate and ldate results so we can calculate RSS timestamps.
  */
  {
    /* we'll need to restore this later */
    int n=0, n2=0;
    char *zContent = cgi_extract_content(&n);

    for(i=0; i<nArg; i++){
      char *zData = azArg[i];
      if( zData == NULL ) continue;
      if( i==iBg ) continue;

      if( azName[i][0] == '_' ) {
        /* This probably isn't useful as a title */
        if( zData[0] ){
          @ <div class="wiki">
          output_formatted("\n----\n", NULL);
          output_formatted(zData, 0);
          @ </div>
        }
      }else if( azName[i][0]=='#' ){
        if( zTitle==NULL ) zTitle = mprintf("#%s",zData);
        @ <div>Ticket: \
        output_ticket(atoi(zData),rn);
        @ </div>
      }else{
        if( zTitle==NULL ) zTitle = format_report_field(zData);


        @ <div>%h(azName[i]): \
        output_report_field(zData,rn);








        @ </div>
      }
    }

    zDesc = cgi_extract_content(&n2);

    /* restore the original buffer */
    cgi_append_content(zContent,n);
    if( zContent ) free(zContent);
  }

  @ <item>
  if( zTitle ) {
    output_trim_message(zTitle, MN_CKIN_MSG, MX_CKIN_MSG);
    @ <title>%h(zTitle)</title>
  }
  @ <description>%h(zDesc)</description>
  @ </item>

  if( zTitle ) free(zTitle);
  if( zDesc ) free(zDesc);

  return 0;
}

/*
** Output the text given in the argument.  Convert tabs and newlines into
** spaces.