result list: show preview and edit links only when they can be used

This commit is contained in:
dockes 2006-03-29 13:08:08 +00:00
parent 516a588d04
commit b42df0c260
9 changed files with 93 additions and 17 deletions

View File

@ -1 +1 @@
1.3.1
1.3.1pre2

View File

@ -1,4 +1,4 @@
# @(#$Id: Makefile,v 1.9 2006-01-19 12:01:42 dockes Exp $ (C) 2005 J.F.Dockes
# @(#$Id: Makefile,v 1.10 2006-03-29 13:08:08 dockes Exp $ (C) 2005 J.F.Dockes
depth = ..
include $(depth)/mk/sysconf
@ -32,6 +32,14 @@ trinternfile.o : internfile.cpp
$(CXX) $(ALL_CXXFLAGS) -DTEST_INTERNFILE -c -o trinternfile.o \
internfile.cpp
RCLCONFIG_OBJS= trrclconfig.o $(BIGLIB) $(MIMELIB)
rclconfig : $(RCLCONFIG_OBJS)
$(CXX) $(ALL_CXXFLAGS) -o rclconfig $(RCLCONFIG_OBJS) \
$(LIBICONV) $(LIBSYS)
trrclconfig.o : rclconfig.cpp
$(CXX) $(ALL_CXXFLAGS) -DTEST_RCLCONFIG -c -o trrclconfig.o \
rclconfig.cpp
clean:
rm -f *.o $(PROGS)

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.25 2006-03-29 11:18:14 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.26 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -17,6 +17,7 @@ static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.25 2006-03-29 11:18:14 dockes E
* Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef TEST_RCLCONFIG
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
@ -384,3 +385,39 @@ void RclConfig::initFrom(const RclConfig& r)
defcharset = r.defcharset;
guesscharset = r.guesscharset;
}
#else // -> Test
#include <stdio.h>
#include <signal.h>
#include <sys/stat.h>
#include <iostream>
#include <list>
#include <string>
using namespace std;
#include "debuglog.h"
#include "rclinit.h"
#include "rclconfig.h"
int main(int, const char **)
{
string reason;
RclConfig *config = recollinit(0, 0, reason);
if (config == 0 || !config->ok()) {
cerr << "Configuration problem: " << reason << endl;
exit(1);
}
list<string> names = config->getConfNames("");
names.sort();
names.unique();
for (list<string>::iterator it = names.begin(); it != names.end();it++) {
string value;
config->getConfParam(*it, value);
cout << *it << " -> [" << value << "]" << endl;
}
}
#endif // TEST_RCLCONFIG

View File

@ -16,7 +16,7 @@
*/
#ifndef _RCLCONFIG_H_INCLUDED_
#define _RCLCONFIG_H_INCLUDED_
/* @(#$Id: rclconfig.h,v 1.18 2006-03-29 11:18:14 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: rclconfig.h,v 1.19 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes */
#include <list>
@ -110,7 +110,10 @@ class RclConfig {
}
return *this;
}
std::list<string> getConfNames(const string &sk) {
return m_conf->getNames(sk);
}
private:
int m_ok;
string m_reason; // Explanation for bad state

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.17 2006-03-20 16:05:41 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.18 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -98,3 +98,15 @@ MimeHandler *getMimeHandler(const string &mtype, RclConfig *cfg)
return 0;
}
}
/// Can this mime type be interned (according to config) ?
bool canIntern(const std::string mtype, RclConfig *cfg)
{
if (mtype.empty())
return false;
string hs = cfg->getMimeHandlerDef(mtype);
if (hs.empty())
return false;
return true;
}

View File

@ -16,7 +16,7 @@
*/
#ifndef _MIMEHANDLER_H_INCLUDED_
#define _MIMEHANDLER_H_INCLUDED_
/* @(#$Id: mimehandler.h,v 1.11 2006-01-30 11:15:27 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: mimehandler.h,v 1.12 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include <list>
@ -71,4 +71,7 @@ class MimeHandler {
*/
extern MimeHandler *getMimeHandler(const std::string &mtyp, RclConfig *cfg);
/// Can this mime type be interned ?
extern bool canIntern(const std::string mimetype, RclConfig *cfg);
#endif /* _MIMEHANDLER_H_INCLUDED_ */

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclreslist.cpp,v 1.6 2006-03-29 11:18:14 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclreslist.cpp,v 1.7 2006-03-29 13:08:08 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
#include <time.h>
@ -21,6 +21,7 @@ static char rcsid[] = "@(#$Id: rclreslist.cpp,v 1.6 2006-03-29 11:18:14 dockes E
#include "docseq.h"
#include "transcode.h"
#include "pathut.h"
#include "mimehandler.h"
#include "rclreslist.h"
#include "moc_rclreslist.cpp"
@ -316,12 +317,19 @@ void RclResList::showResultPage()
result += string(perbuf) + sizebuf + "<b>" + doc.title + "</b><br>";
result += doc.mimetype + "&nbsp;";
result += string(datebuf) + "&nbsp;&nbsp;&nbsp;";
// Set up the preview and edit links
char vlbuf[100];
sprintf(vlbuf, "\"P%d\"", m_winfirst+i);
result += string("<a href=") + vlbuf + ">" + "Preview" + "</a>"
+ "&nbsp;&nbsp;";
sprintf(vlbuf, "E%d", m_winfirst+i);
result += string("<a href=") + vlbuf + ">" + "Edit" + "</a>";
if (canIntern(doc.mimetype, rclconfig)) {
sprintf(vlbuf, "\"P%d\"", m_winfirst+i);
result += string("<a href=") + vlbuf + ">" + "Preview" + "</a>"
+ "&nbsp;&nbsp;";
}
if (!rclconfig->getMimeViewerDef(doc.mimetype).empty()) {
sprintf(vlbuf, "E%d", m_winfirst+i);
result += string("<a href=") + vlbuf + ">" + "Edit" + "</a>";
}
result += string("<br>");
if (!img_name.empty()) {

View File

@ -1,4 +1,4 @@
# @(#$Id: mimeconf,v 1.14 2006-03-28 09:38:12 dockes Exp $ (C) 2004 J.F.Dockes
# @(#$Id: mimeconf,v 1.15 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes
# Recoll : associations of mime types to processing filters.
# There are different sections for decompression, 'interning' for indexing
@ -75,6 +75,8 @@ image/vnd.djvu = djview %f
application/x-dvi = xdvi %f
audio/mpeg = xmms %f
image/png = xv %f
image/jpeg = xv %f
# Icons to be used in the result list.
[icons]

View File

@ -1,4 +1,4 @@
# @(#$Id: mimemap,v 1.13 2006-03-28 09:38:13 dockes Exp $ (C) 2004 J.F.Dockes
# @(#$Id: mimemap,v 1.14 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes
# Recoll: associations of file name extensions to mime types
.txt = text/plain
@ -50,16 +50,19 @@
.rtf = text/rtf
.mp3 = audio/mpeg
.png = image/png
.jpg = image/jpeg
# A list of stuff that we don't want to touch at all (for now). Having the
# suffixes listed in there speeds up things quite a lot by avoiding
# unneeded decompression or 'file' calls
# unneeded decompression or 'file' calls. File names still get indexed if
# indexallfilenames is set
recoll_noindex = .tar.gz .tgz .tar.bz2 .tbz .log.gz .md5 .map \
.c .h .cpp .m4 .tcl .js .sh .pl .awk .php .php3 \
.o .lib .dll .a \
.dat .bak .rdf .log .db .ini .msf \
.gnm .gnumeric .tex \
.jpg .gif .bmp .xpm .png \
.gif .bmp .xpm \
,v ~ #
[~/.gaim]