diff options
author | Manuel Silvoso <Manuel.Silvoso@eco.etat.lu> | 2013-03-01 10:33:59 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2013-03-01 10:33:59 +0100 |
commit | 7125e5f5ef96a8a8d74cc63b562fb57d2d8b4486 (patch) | |
tree | c2dbd7cdeb69f836420c2451a4f70ba1fc62b914 | |
parent | 5778139457e6cc35dfdbe7a5a7c2cf2ed0bcc8a6 (diff) | |
download | mlmmj-webarchiver-7125e5f5ef96a8a8d74cc63b562fb57d2d8b4486.tar.gz mlmmj-webarchiver-7125e5f5ef96a8a8d74cc63b562fb57d2d8b4486.tar.xz mlmmj-webarchiver-7125e5f5ef96a8a8d74cc63b562fb57d2d8b4486.zip |
Add a working search functionality.
-rw-r--r-- | ChangeLog | 5 | ||||
-rwxr-xr-x | mlmmj-webarchiver.sh | 10 | ||||
-rw-r--r-- | mlmmj-webarchiver/index.php.newlist | 4 | ||||
-rw-r--r-- | mlmmj-webarchiver/mhonarc/layout.mrc | 6 | ||||
-rw-r--r-- | mlmmj-webarchiver/mlmmj-webarchiver.conf | 6 | ||||
-rw-r--r-- | mlmmj-webarchiver/search.php.newlist | 75 | ||||
-rw-r--r-- | mlmmj-webarchiver/skel/index.php | 2 | ||||
-rw-r--r-- | mlmmj-webarchiver/skel/search.php | 48 |
8 files changed, 100 insertions, 56 deletions
@@ -1,5 +1,10 @@ mlmmj-webarchiver ChangeLog +2013-02-28 - version 0.90 + * Added search.php script + * Added date to every line + * Bugfixes + 2009-09-12 - version 0.80 * Added MHonArc support and removed hypermail. * Added a nice style based on roundcube.net. diff --git a/mlmmj-webarchiver.sh b/mlmmj-webarchiver.sh index d405e78..99b8e95 100755 --- a/mlmmj-webarchiver.sh +++ b/mlmmj-webarchiver.sh @@ -116,14 +116,12 @@ for wlist in $WEBARCHIVED_LISTS; do unset MLA_LABEL unset MHONARC_RC LIST_MHONARC_CMDS="$MHONARC_CMDS" - if [ ! -d "${WEBARCHIVE_OUT}" ]; then mkdir -p -m ${DIRMODES} "${WEBARCHIVE_OUT}" if [ -n "${SKEL}" ]; then cp -r ${SKEL}/* ${WEBARCHIVE_OUT}/ fi fi - # check if list already has a webarchive directory and create one if not # also copy the new index into the dir, if one was given. if [ ! -d "${WEBARCHIVE_OUT}/${wlist}" ]; then @@ -131,6 +129,9 @@ for wlist in $WEBARCHIVED_LISTS; do if [ -n "$NEW_LIST_INDEX" ]; then cp ${NEW_LIST_INDEX} ${WEBARCHIVE_OUT}/${wlist}/index.php fi + if [ -n "$NEW_LIST_SEARCH" ]; then + cat ${NEW_LIST_SEARCH} | perl -pe 's/##REL_LINK##/../g' | perl -pe "s/##MAX_RESULTS##/${MAX_RESULTS}/g" | perl -pe "s/##TITLE_LOCATION##/${wlist}/g" > ${WEBARCHIVE_OUT}/${wlist}/search.php + fi fi # if the archive should be protected, we need to create a .htaccess file @@ -199,6 +200,9 @@ for wlist in $WEBARCHIVED_LISTS; do if [ ! -d "${WEBARCHIVE_OUT}/${wlist}/${THISMONTH}" ]; then mkdir -m ${DIRMODES} "${WEBARCHIVE_OUT}/${wlist}/${THISMONTH}" + if [ -n "$NEW_LIST_SEARCH" ]; then + cat ${NEW_LIST_SEARCH} | perl -pe 's/##REL_LINK##/..\/../g' | perl -pe "s/##MAX_RESULTS##/${MAX_RESULTS}/g" | perl -pe "s/##TITLE_LOCATION##/${wlist}\/${THISMONTH}/g" > ${WEBARCHIVE_OUT}/${wlist}/${THISMONTH}/search.php + fi fi $MHONARC $LIST_MHONARC_CMDS -outdir ${WEBARCHIVE_OUT}/${wlist}/${THISMONTH} -add < \ @@ -218,7 +222,7 @@ for wlist in $WEBARCHIVED_LISTS; do # zip -9 -q -r -j "${WEBARCHIVE_OUT}/${wlist}/${wlist}-archive.zip" "${MLMMJ_LISTDIR}/${wlist}/archive" # fi - WEBARCHIVE_OUT=${WEBARCHIVE_TMP} + #WEBARCHIVE_OUT=${WEBARCHIVE_TMP} #Why? done rm /var/run/mlmmj-webarchiver.pid 2>/dev/null diff --git a/mlmmj-webarchiver/index.php.newlist b/mlmmj-webarchiver/index.php.newlist index 9acd78d..e760230 100644 --- a/mlmmj-webarchiver/index.php.newlist +++ b/mlmmj-webarchiver/index.php.newlist @@ -34,9 +34,9 @@ foreach($files as $k => $file) { <div id="topnav"> <a href="/">home</a> | - <a href="../search.php">search</a> - | <a href="..">other lists</a> + | + <a href="search.php">search</a> </div> </div> <div id="mailinglists"> diff --git a/mlmmj-webarchiver/mhonarc/layout.mrc b/mlmmj-webarchiver/mhonarc/layout.mrc index d087c6c..e39a241 100644 --- a/mlmmj-webarchiver/mhonarc/layout.mrc +++ b/mlmmj-webarchiver/mhonarc/layout.mrc @@ -30,6 +30,8 @@ <a href="$TIDXFNAME$#$MSGNUM$">thread index</a> | <a href="$IDXFNAME$#$MSGNUM$">date index</a> + | + <a href="search.php">search</a> </div> </div> <div id="mailinglists"> @@ -138,6 +140,8 @@ <a href="$TIDXFNAME$">thread index</a> | <a href="$IDXFNAME$">date index</a> + | + <a href="search.php">search</a> </div> </div> <div id="mailinglists"> @@ -189,6 +193,8 @@ <a href="$TIDXFNAME$">thread index</a> | <a href="$IDXFNAME$">date index</a> + | + <a href="search.php">search</a> </div> </div> <div id="mailinglists"> diff --git a/mlmmj-webarchiver/mlmmj-webarchiver.conf b/mlmmj-webarchiver/mlmmj-webarchiver.conf index 3cb5424..94907a7 100644 --- a/mlmmj-webarchiver/mlmmj-webarchiver.conf +++ b/mlmmj-webarchiver/mlmmj-webarchiver.conf @@ -27,9 +27,10 @@ DIRMODES="755" # type: path SKEL="/etc/mlmmj-webarchiver/skel" -# index file copied into new lists dir +# php files copied into new lists dir # type: file NEW_LIST_INDEX="/etc/mlmmj-webarchiver/index.php.newlist" +NEW_LIST_SEARCH="/etc/mlmmj-webarchiver/search.php.newlist" # create archive as maildir zip? # type: yes/no @@ -48,3 +49,6 @@ MHONARC_CMDS="" # type: string AUTHTYPE="Basic" +# Maximum number of results for the search +# type: integer +MAX_RESULTS="50" diff --git a/mlmmj-webarchiver/search.php.newlist b/mlmmj-webarchiver/search.php.newlist new file mode 100644 index 0000000..1606580 --- /dev/null +++ b/mlmmj-webarchiver/search.php.newlist @@ -0,0 +1,75 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html lang="en"> +<head> + <title>Mailing Lists Archives</title> + <link rel="stylesheet" type="text/css" media="screen" href="##REL_LINK##/style/screen.css"> +</head> +<body> + <div id="banner"> + <div id="header"> + <div class="banner-left"><img src="##REL_LINK##/images/banner_left.gif" width="17" height="56" border="0" alt="" /></div> + <div class="banner-text">Mailing List Archives</a></div> + <div class="banner-right"><img src="##REL_LINK##/images/banner_right.gif" width="10" height="56" alt="" /></div> + </div> + <div id="topnav"> + <a href="/">home</a> + | + <a href=".">archives</a> + | + <a href="<?php echo $_SERVER['PHP_SELF']; ?>">search</a> + </div> + </div> + <div id="mailinglists"> + <div id="main"> + <h1>search ##TITLE_LOCATION## (you can use POSIX regex)</h1> + <div class="listinfo"> + <p> +<?php + if (isset($_POST['words']) && !empty($_POST['words'])): + $words=str_replace("'","'\"'\"'",$_POST['words']); + $output=array(); + $html=array(); + $count=0; + $maxresults=##MAX_RESULTS##; + exec("find -type f -name '0*.html' | xargs egrep -roi '$words' | perl -pe 's/:.*//' | sort | uniq",&$output); + while(isset($output[$count]) && $count<$maxresults) + { + $file=$output[$count++]; + $content=file_get_contents($file); + $matches=array(); + if (preg_match('/<em>Subject<\/em>: ([^<]*)<\/li>[\S\s]+From<\/em>: ([^<]*)<\/li>[\S\s]+Date<\/em>: ([^<]*)<\/li>/',$content,&$matches)) + { + $html[]="<li><a href='$file'>$matches[1]</a>, $matches[2], $matches[3]</li>"; + } + } + + if (count($html)==0) + { + echo "No results!"; + } + else + { + if (count($output)>$maxresults) + { + echo "The first $maxresults results of ".count($output).":<br/>"; + } + else + { + echo count($html)." results:"; + } + echo "<ul>".implode($html)."</ul>"; + } +?> +<?php else:?> +<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> +<input type="text" size="30" name="words" value=""> +<input type="submit" value="Search"> +</form> +<?php endif; ?> +</p> + + </div> + </div> + </div> +</body> +</html> diff --git a/mlmmj-webarchiver/skel/index.php b/mlmmj-webarchiver/skel/index.php index d1e8e18..23c366f 100644 --- a/mlmmj-webarchiver/skel/index.php +++ b/mlmmj-webarchiver/skel/index.php @@ -24,8 +24,6 @@ </div> <div id="topnav"> <a href="/">home</a> - | - <a href="search.php">search</a> <?php echo $navlists; ?> </div> </div> diff --git a/mlmmj-webarchiver/skel/search.php b/mlmmj-webarchiver/skel/search.php deleted file mode 100644 index c9e65d2..0000000 --- a/mlmmj-webarchiver/skel/search.php +++ /dev/null @@ -1,48 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html lang="en"> -<head> - <title>Mailing Lists Archives</title> - <link rel="stylesheet" type="text/css" media="screen" href="style/screen.css"> -</head> -<body> - <div id="banner"> - <div id="header"> - <div class="banner-left"><img src="images/banner_left.gif" width="17" height="56" border="0" alt="" /></div> - <div class="banner-text">Mailing List Archives</div> - <div class="banner-right"><img src="images/banner_right.gif" width="10" height="56" alt="" /></div> - </div> - <div id="topnav"> - <a href="/">home</a> - | - <a href=".">archives</a> - | - <a href="search.php">search</a> - </div> - </div> - <div id="mailinglists"> - <div id="main"> - <h1>search archives</h1> - <div class="listinfo"> - <p> -disabled -<!-- -<form method="post" action="/cgi-bin/htsearch"> -<select name="restrict"> -<option value="" selected>Any Archive -<option value="csync-devel">csync-devel -</select> -<input type="hidden" name="restrict" value="csync-devel"> -<input type="hidden" name="matchesperpage" value="20"> -<input type="hidden" name="method" value="and"> -<input type="text" size="15" name="words" value=""> -<input type="hidden" name="config" value="mlmmj"> -<input type="submit" value="Search"> -</form> ---> -</p> - - </div> - </div> - </div> -</body> -</html> |