Re: [fossil-users] CGI issues

2010-05-20 Thread Stephan Beal
On Thu, May 20, 2010 at 2:00 AM, Michal Suchanek hramr...@centrum.czwrote:

 I tried installing fossil as CGI on Apache 1.3 and there is some
 difference form what is in the docs.

 Firstly I had to use a script like this:

 #!/path-to-fossil/fossil cgi
 repository: /path-to-repo.fossil

 Note the cgi parameter. Without that the server would just report an
 internal error.


Is your script named something.cgi? i've sometimes had problems (on Apache
1.3) with the web server requiring that extension (but it is configurable).


 Is the cgi feature well tested?


i host more than a dozen sites with it and haven't had any problems at all.


 Did anybody else try with Apache 1.3? I don't have access to the
 server logs so I am not sure what is going on when something breaks.


Apache 1.3 has been obsoleted since... 8 years (April 6, 2002, according to
Google). Perhaps it's time to change hosters?

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] CGI issues

2010-05-20 Thread Michal Suchanek
On 20 May 2010 08:58, Stephan Beal sgb...@googlemail.com wrote:
 On Thu, May 20, 2010 at 2:00 AM, Michal Suchanek hramr...@centrum.cz
 wrote:

 I tried installing fossil as CGI on Apache 1.3 and there is some
 difference form what is in the docs.

 Firstly I had to use a script like this:

 #!/path-to-fossil/fossil cgi
 repository: /path-to-repo.fossil

 Note the cgi parameter. Without that the server would just report an
 internal error.

 Is your script named something.cgi? i've sometimes had problems (on Apache
 1.3) with the web server requiring that extension (but it is configurable).

Well, if it required the suffix it would just serve the source, right?



 Is the cgi feature well tested?

 i host more than a dozen sites with it and haven't had any problems at all.


 Did anybody else try with Apache 1.3? I don't have access to the
 server logs so I am not sure what is going on when something breaks.

 Apache 1.3 has been obsoleted since... 8 years (April 6, 2002, according to
 Google). Perhaps it's time to change hosters?

I somewhat like this setup as it uses a central server and a bunch of
quite powerful machines that run the scripts. And I can see why they
did not upgrade the server. Apache 1.3 works, 2.0 does not offer any
additional features for CGI configurations and it is not patched to
support this setup.

Still putting the repository elsewhere is an option.

Thanks

Michal
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] implementing search

2010-05-20 Thread zachtodd
Hello All,

This patch adds a complete seach mechanism for wikis, tickets, checkins, and 
code.  This functionality is only available if you are logged in.  

diff -rup ../fossil-src-20100318142033/src/db.c ./src/db.c
--- ../fossil-src-20100318142033/src/db.c   2010-03-18 10:20:53.0 
-0400
+++ ./src/db.c  2010-05-20 18:00:46.681326571 -0400
@@ -1041,6 +1041,79 @@ static void db_sql_user(
 }
 
 /*
+** Make the content_get function available within a SQL query.
+*/
+static void db_sql_content_get(
+  sqlite3_context *context,
+  int argc,
+  sqlite3_value **argv
+){
+  int rid;
+  Blob content;
+  
+  if( argc != 1 ) return;
+  rid = sqlite3_value_int(argv[0]);
+  content_get(rid, content);
+  sqlite3_result_text(context, blob_str(content), -1, SQLITE_TRANSIENT);
+}
+  
+/*
+** Retrieve the most recent revision ID of a file prior to a given DATETIME.
+** If the DATETIME is given as 0, then find the most recent RID.
+*/
+static void db_sql_get_file_rid(
+  sqlite3_context *context,
+  int argc,
+  sqlite3_value **argv
+){
+  const unsigned char *fnid;
+  const unsigned char *datetime;
+  int rid;
+  Stmt q;
+  
+  if ( argc != 2 ) return;
+  fnid = sqlite3_value_text(argv[0]);
+  datetime = sqlite3_value_text(argv[1]);
+  
+  if (strcmp((const char*)datetime, 0) == 0){
+db_prepare(q, SELECT fid FROM mlink WHERE fnid=%Q and mid= 
+   (SELECT objid FROM (SELECT objid, mtime FROM event WHERE 
objid IN 
+   (SELECT mid FROM mlink WHERE fnid=%Q) 
+   ORDER BY mtime DESC) LIMIT 1);, fnid, fnid);
+
+db_step(q);
+rid = db_column_int(q, 0);
+sqlite3_result_int(context, rid);
+  }
+}
+
+/*
+** Retrieve the most recent revision ID of a wiki entry prior to a given 
DATETIME.
+** If the DATETIME is given as 0, then find the most recent RID.
+*/
+static void db_sql_get_wiki_rid(
+  sqlite3_context *context,
+  int argc,
+  sqlite3_value **argv
+){
+  const unsigned char *tagid;
+  const unsigned char *datetime;
+  int rid;
+  Stmt q;
+  
+  if ( argc != 2 ) return;
+  tagid = sqlite3_value_text(argv[0]);
+  datetime = sqlite3_value_text(argv[1]);
+  
+  if (strcmp((const char*)datetime, 0) == 0){
+db_prepare(q, SELECT rid FROM tagxref WHERE tagid=%Q ORDER BY mtime DESC 
LIMIT 1, tagid);
+db_step(q);
+rid = db_column_int(q, 0);
+sqlite3_result_int(context, rid);
+  }
+}
+
+/*
 ** Implement the cgi() SQL function.  cgi() takes a an argument which is
 ** a name of CGI query parameter. The value of that parameter is returned, 
 ** if available. optional second argument will be returned if the first
@@ -1156,9 +1229,10 @@ LOCAL void db_connection_init(void){
   sqlite3_create_function(g.db, cgi, 1, SQLITE_ANY, 0, db_sql_cgi, 0, 0);
   sqlite3_create_function(g.db, cgi, 2, SQLITE_ANY, 0, db_sql_cgi, 0, 0);
   sqlite3_create_function(g.db, print, -1, SQLITE_UTF8, 0,db_sql_print,0,0);
-  sqlite3_create_function(
-g.db, file_is_selected, 1, SQLITE_UTF8, 0, file_is_selected,0,0
-  );
+  sqlite3_create_function(g.db, content_get, 1, SQLITE_ANY, 0, 
db_sql_content_get, 0, 0);
+  sqlite3_create_function(g.db, get_file_rid, 2, SQLITE_ANY, 0, 
db_sql_get_file_rid, 0, 0);
+  sqlite3_create_function(g.db, get_wiki_rid, 2, SQLITE_ANY, 0, 
db_sql_get_wiki_rid, 0, 0);
+  sqlite3_create_function(g.db, file_is_selected, 1, SQLITE_UTF8, 0, 
file_is_selected,0,0);
   if( g.fSqlTrace ){
 sqlite3_trace(g.db, db_sql_trace, 0);
   }
Only in ./src: fossil_patch
diff -rup ../fossil-src-20100318142033/src/search.c ./src/search.c
--- ../fossil-src-20100318142033/src/search.c   2010-03-18 10:20:53.0 
-0400
+++ ./src/search.c  2010-05-20 16:03:31.584325769 -0400
@@ -172,6 +172,104 @@ void search_sql_setup(Search *p){
 }
 
 /*
+** WEBPAGE: search
+** URL: /search
+*/
+void search(void){
+  const char *zType;
+  const char *zSrchType;
+  const char *zTitle;
+  const char *zContent;
+  const char *zSrch;
+  const char *zUuid;
+  const char *zRid;
+  char zrn[4];
+  char zshUuid[10];
+  int zScore;
+  int zSrchTypeFlag;
+  
+  Search *zSrchpat;
+  Stmt q;
+
+  zSrch = PD(search, );
+  zSrchType = PD(type, );
+  zSrchpat = search_init(zSrch);
+  search_sql_setup(zSrchpat);
+
+  login_check_credentials();
+  
+  if( !g.okHistory ){ login_needed(); return; }
+  
+  db_prepare(q, SELECT type, rid, title, content, score(content) AS score 
FROM 
+  

+ (SELECT 'checkin' AS type, objid AS rid, coalesce(ecomment, 
comment) AS title, 
+ coalesce(ecomment, comment) AS content FROM event WHERE 
type='ci' UNION ALL 
+ SELECT 'code' AS type, rid, title, content FROM 
+ (SELECT title, rid, content_get(rid) as content FROM 
+ (SELECT name AS title, get_file_rid(fnid, '0') AS rid FROM 
+ (SELECT name, fnid FROM filename))) UNION ALL 
+