| | @@ -931,5 +931,144 @@ |
| 931 | 931 | g.zOpenRevision = 0; |
| 932 | 932 | blob_reset(&cacheKey); |
| 933 | 933 | cgi_set_content(&tarball); |
| 934 | 934 | cgi_set_content_type("application/x-compressed"); |
| 935 | 935 | } |
| 936 | + |
| 937 | +/* |
| 938 | +** This routine is called for each check-in on the /tarlist page to |
| 939 | +** construct the "extra" information after the description. |
| 940 | +*/ |
| 941 | +static void tarlist_extra( |
| 942 | + Stmt *pQuery, /* Current row of the timeline query */ |
| 943 | + int tmFlags, /* Flags to www_print_timeline() */ |
| 944 | + const char *zThisUser, /* Suppress links to this user */ |
| 945 | + const char *zThisTag /* Suppress links to this tag */ |
| 946 | +){ |
| 947 | + int rid = db_column_int(pQuery, 0); |
| 948 | + const char *zUuid = db_column_text(pQuery, 1); |
| 949 | + const char *zDate = db_column_text(pQuery, 2); |
| 950 | + char *zBrName = branch_of_rid(rid); |
| 951 | + static const char *zProject = 0; |
| 952 | + int nProject; |
| 953 | + char *zNm; |
| 954 | + |
| 955 | + if( zProject==0 ) zProject = db_get("project-name","unnamed"); |
| 956 | + zNm = mprintf("%s-%sZ-%.8s", zProject, zDate, zUuid); |
| 957 | + nProject = (int)strlen(zProject); |
| 958 | + zNm[nProject+11] = 'T'; |
| 959 | + @ <strong>%h(zBrName)</strong><br>\ |
| 960 | + @ %z(href("%R/timeline?c=%!S&y=ci&n=11",zUuid))<button>Context</button></a> |
| 961 | + @ %z(href("%R/tarball/%!S/%t.tar.gz",zUuid,zNm))\ |
| 962 | + @ <button>Tarball</button></a> |
| 963 | + @ %z(href("%R/zip/%!S/%t.zip",zUuid,zNm))\ |
| 964 | + @ <button>ZIP Archive</button></a> |
| 965 | + fossil_free(zBrName); |
| 966 | + fossil_free(zNm); |
| 967 | +} |
| 968 | + |
| 969 | +/* |
| 970 | +** SETTING: suggested-tarlist width=70 block-text |
| 971 | +** |
| 972 | +** This setting controls the suggested tarball/ZIP downloads on the |
| 973 | +** [[/tarlist]] page. The value is a TCL list. Each pair of items |
| 974 | +** defines a set of check-ins to be added to the suggestion list. |
| 975 | +** The first item of each pair is an integer count (N) and second |
| 976 | +** item is a tag GLOB pattern (PATTERN). For each pair, the most |
| 977 | +** recent N check-ins that have a tag matching PATTERN are added |
| 978 | +** to the list. The special pattern "OPEN-LEAF" matches any open |
| 979 | +** leaf check-in. |
| 980 | +** |
| 981 | +** Example: |
| 982 | +** |
| 983 | +** 3 OPEN-LEAF 3 release 1 trunk |
| 984 | +** |
| 985 | +** The value causes the /tarlist page to show the union of the 3 |
| 986 | +** most recent open leaves, the three most recent check-ins marked |
| 987 | +** "release", and the single most recent trunk check-in. |
| 988 | +*/ |
| 989 | + |
| 990 | +/* |
| 991 | +** WEBPAGE: /tarlist |
| 992 | +** |
| 993 | +** Show a special no-graph timeline of recent important check-ins with |
| 994 | +** an opportunity to pull tarballs and ZIPs. |
| 995 | +*/ |
| 996 | +void tarlist_page(void){ |
| 997 | + Stmt q; /* The actual timeline query */ |
| 998 | + const char *zTarlistCfg; /* Configuration string */ |
| 999 | + char **azItem; /* Decomposed elements of zTarlistCfg */ |
| 1000 | + int *anItem; /* Bytes in each term of azItem[] */ |
| 1001 | + int nItem; /* Number of terms in azItem[] */ |
| 1002 | + int i; /* Loop counter */ |
| 1003 | + int tmFlags; /* Timeline display flags */ |
| 1004 | + int n; /* Number of suggested downloads */ |
| 1005 | + |
| 1006 | + login_check_credentials(); |
| 1007 | + if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; } |
| 1008 | + |
| 1009 | + style_set_current_feature("timeline"); |
| 1010 | + style_header("Suggested Tarballs And ZIP Archives"); |
| 1011 | + |
| 1012 | + zTarlistCfg = db_get("suggested-tarlist","5 OPEN-LEAF"); |
| 1013 | + db_multi_exec( |
| 1014 | + "CREATE TEMP TABLE tarlist(rid INTEGER PRIMARY KEY);" |
| 1015 | + ); |
| 1016 | + if( !g.interp ) Th_FossilInit(0); |
| 1017 | + Th_SplitList(g.interp, zTarlistCfg, (int)strlen(zTarlistCfg), |
| 1018 | + &azItem, &anItem, &nItem); |
| 1019 | + for(i=0; i<nItem-1; i+=2){ |
| 1020 | + int cnt; |
| 1021 | + char *zLabel; |
| 1022 | + if( anItem[i]==1 && azItem[i][0]=='*' ){ |
| 1023 | + cnt = -1; |
| 1024 | + }else if( anItem[i]<1 ){ |
| 1025 | + cnt = 0; |
| 1026 | + }else{ |
| 1027 | + cnt = atoi(azItem[i]); |
| 1028 | + } |
| 1029 | + if( cnt==0 ) continue; |
| 1030 | + zLabel = fossil_strndup(azItem[i+1],anItem[i+1]); |
| 1031 | + if( fossil_strcmp("OPEN-LEAF",zLabel)==0 ){ |
| 1032 | + db_multi_exec( |
| 1033 | + "INSERT OR IGNORE INTO tarlist(rid)" |
| 1034 | + " SELECT leaf.rid FROM leaf, event" |
| 1035 | + " WHERE event.objid=leaf.rid" |
| 1036 | + " AND NOT EXISTS(SELECT 1 FROM tagxref" |
| 1037 | + " WHERE tagxref.rid=leaf.rid" |
| 1038 | + " AND tagid=%d AND tagtype>0)" |
| 1039 | + " ORDER BY event.mtime DESC LIMIT %d", TAG_CLOSED, cnt |
| 1040 | + ); |
| 1041 | + }else{ |
| 1042 | + db_multi_exec( |
| 1043 | + "WITH taglist(tid) AS" |
| 1044 | + " (SELECT tagid FROM tag WHERE tagname GLOB 'sym-%q')" |
| 1045 | + "INSERT OR IGNORE INTO tarlist(rid)" |
| 1046 | + " SELECT event.objid FROM event CROSS JOIN tagxref" |
| 1047 | + " WHERE event.type='ci'" |
| 1048 | + " AND tagxref.tagid IN taglist" |
| 1049 | + " AND tagtype>0" |
| 1050 | + " AND tagxref.rid=event.objid" |
| 1051 | + " ORDER BY event.mtime DESC LIMIT %d", zLabel, cnt |
| 1052 | + ); |
| 1053 | + } |
| 1054 | + fossil_free(zLabel); |
| 1055 | + } |
| 1056 | + Th_Free(g.interp, azItem); |
| 1057 | + |
| 1058 | + n = db_int(0, "SELECT count(*) FROM tarlist"); |
| 1059 | + if( n==0 ){ |
| 1060 | + @ <h2>No tarball/ZIP suggestions are available at this time</h2> |
| 1061 | + }else{ |
| 1062 | + @ <h2>%d(n) Tarball/ZIP Download Suggestions:</h2> |
| 1063 | + db_prepare(&q, |
| 1064 | + "%s AND blob.rid IN tarlist ORDER BY event.mtime DESC", |
| 1065 | + timeline_query_for_www() |
| 1066 | + ); |
| 1067 | + |
| 1068 | + tmFlags = TIMELINE_DISJOINT | TIMELINE_NOSCROLL | TIMELINE_COLUMNAR |
| 1069 | + | TIMELINE_BRCOLOR; |
| 1070 | + www_print_timeline(&q, tmFlags, 0, 0, 0, 0, 0, tarlist_extra); |
| 1071 | + db_finalize(&q); |
| 1072 | + } |
| 1073 | + style_finish_page(); |
| 1074 | +} |
| 936 | 1075 | |