mimemap processing recentered in rclconfig. Handle directory-local suffix to mime-type definitions. Implement gaim log handling
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.9 2005-11-18 15:19:14 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.10 2005-11-21 14:31:24 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
@@ -102,7 +102,7 @@ FileInterner::FileInterner(const std::string &f, RclConfig *cnf,
|
||||
|
||||
// We need to run mime type identification in any case to check
|
||||
// for a compressed file.
|
||||
m_mime = mimetype(m_fn, m_cfg->getMimeMap(), usfci);
|
||||
m_mime = mimetype(m_fn, m_cfg, usfci);
|
||||
|
||||
// If identification fails, try to use the input parameter. Note that this
|
||||
// is normally not a compressed type (it's the mime type from the db)
|
||||
@@ -118,14 +118,14 @@ FileInterner::FileInterner(const std::string &f, RclConfig *cnf,
|
||||
// uncompressed file, and rerun the mime type identification, then do the
|
||||
// rest with the temp file.
|
||||
list<string>ucmd;
|
||||
if (getUncompressor(m_mime, m_cfg->getMimeConf(), ucmd)) {
|
||||
if (m_cfg->getUncompressor(m_mime, ucmd)) {
|
||||
if (!uncompressfile(m_cfg, m_fn, ucmd, m_tdir, m_tfile)) {
|
||||
return;
|
||||
}
|
||||
LOGDEB(("internfile: after ucomp: m_tdir %s, tfile %s\n",
|
||||
m_tdir.c_str(), m_tfile.c_str()));
|
||||
m_fn = m_tfile;
|
||||
m_mime = mimetype(m_fn, m_cfg->getMimeMap(), usfci);
|
||||
m_mime = mimetype(m_fn, m_cfg, usfci);
|
||||
if (m_mime.empty() && imime)
|
||||
m_mime = *imime;
|
||||
if (m_mime.empty()) {
|
||||
@@ -136,7 +136,7 @@ FileInterner::FileInterner(const std::string &f, RclConfig *cnf,
|
||||
}
|
||||
|
||||
// Look for appropriate handler
|
||||
m_handler = getMimeHandler(m_mime, m_cfg->getMimeConf());
|
||||
m_handler = getMimeHandler(m_mime, m_cfg);
|
||||
if (!m_handler) {
|
||||
// No handler for this type, for now :(
|
||||
LOGDEB(("FileInterner::FileInterner: %s: no handler\n",
|
||||
|
||||
@@ -110,13 +110,12 @@ MimeHandlerHtml::mkDoc(RclConfig *conf, const string &,
|
||||
}
|
||||
}
|
||||
|
||||
Rcl::Doc out;
|
||||
out.origcharset = charset;
|
||||
out.text = pres.dump;
|
||||
docout.origcharset = charset;
|
||||
docout.text = pres.dump;
|
||||
// LOGDEB(("textHtmlToDoc: dump : %s\n", pres.dump.c_str()));
|
||||
out.title = pres.title;
|
||||
out.keywords = pres.keywords;
|
||||
out.abstract = pres.sample;
|
||||
docout = out;
|
||||
docout.title = pres.title;
|
||||
docout.keywords = pres.keywords;
|
||||
docout.abstract = pres.sample;
|
||||
docout.dmtime = pres.dmtime;
|
||||
return MimeHandler::MHDone;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.12 2005-11-18 13:23:46 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.13 2005-11-21 14:31:24 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
@@ -31,14 +31,12 @@ static MimeHandler *mhFactory(const string &mime)
|
||||
/**
|
||||
* Return handler object for given mime type:
|
||||
*/
|
||||
MimeHandler *getMimeHandler(const string &mtype, ConfTree *mhandlers)
|
||||
MimeHandler *getMimeHandler(const string &mtype, RclConfig *cfg)
|
||||
{
|
||||
// Return handler definition for mime type
|
||||
string hs;
|
||||
if (!mhandlers->get(mtype, hs, "index")) {
|
||||
LOGDEB(("getMimeHandler: no handler for '%s'\n", mtype.c_str()));
|
||||
// Get handler definition for mime type
|
||||
string hs = cfg->getMimeHandlerDef(mtype);
|
||||
if (hs.empty())
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Break definition into type and name
|
||||
list<string> toks;
|
||||
@@ -68,47 +66,3 @@ MimeHandler *getMimeHandler(const string &mtype, ConfTree *mhandlers)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return external viewer exec string for given mime type
|
||||
*/
|
||||
string getMimeViewer(const string &mtype, ConfTree *mhandlers)
|
||||
{
|
||||
string hs;
|
||||
mhandlers->get(mtype, hs, "view");
|
||||
return hs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return icon name
|
||||
*/
|
||||
string getMimeIconName(const string &mtype, ConfTree *mhandlers)
|
||||
{
|
||||
string hs;
|
||||
mhandlers->get(mtype, hs, "icons");
|
||||
return hs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return decompression command line for given mime type
|
||||
*/
|
||||
bool getUncompressor(const string &mtype, ConfTree *mhandlers,
|
||||
list<string>& cmd)
|
||||
{
|
||||
string hs;
|
||||
|
||||
mhandlers->get(mtype, hs, "");
|
||||
if (hs.empty())
|
||||
return false;
|
||||
list<string> tokens;
|
||||
ConfTree::stringToStrings(hs, tokens);
|
||||
if (tokens.empty()) {
|
||||
LOGERR(("getUncompressor: empty spec for mtype %s\n", mtype.c_str()));
|
||||
return false;
|
||||
}
|
||||
if (stringlowercmp("uncompress", tokens.front()))
|
||||
return false;
|
||||
list<string>::iterator it = tokens.begin();
|
||||
cmd.assign(++it, tokens.end());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef _MIMEHANDLER_H_INCLUDED_
|
||||
#define _MIMEHANDLER_H_INCLUDED_
|
||||
/* @(#$Id: mimehandler.h,v 1.9 2005-11-18 15:19:14 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: mimehandler.h,v 1.10 2005-11-21 14:31:24 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
@@ -53,25 +53,6 @@ class MimeHandler {
|
||||
* Return indexing handler object for the given mime type
|
||||
* returned pointer should be deleted by caller
|
||||
*/
|
||||
extern MimeHandler *getMimeHandler(const std::string &mtyp, ConfTree *mhdlers);
|
||||
|
||||
/**
|
||||
* Return external viewer exec string for given mime type
|
||||
*/
|
||||
extern std::string getMimeViewer(const std::string &mtyp, ConfTree *mhandlers);
|
||||
|
||||
/**
|
||||
* Return icon name
|
||||
*/
|
||||
extern std::string getMimeIconName(const std::string &mtyp, ConfTree *mhandlers);
|
||||
|
||||
|
||||
/**
|
||||
* Return command to uncompress the given type. The returned command has
|
||||
* substitutable places for input file name and temp dir name, and will
|
||||
* return output name
|
||||
*/
|
||||
bool getUncompressor(const std::string &mtype, ConfTree *mhandlers,
|
||||
std::list<std::string>& cmd);
|
||||
extern MimeHandler *getMimeHandler(const std::string &mtyp, RclConfig *cfg);
|
||||
|
||||
#endif /* _MIMEHANDLER_H_INCLUDED_ */
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* USA
|
||||
* -----END-LICENCE-----
|
||||
*/
|
||||
#include <time.h>
|
||||
|
||||
#include "myhtmlparse.h"
|
||||
|
||||
@@ -135,6 +136,19 @@ MyHtmlParser::opening_tag(const string &tag, const map<string,string> &p)
|
||||
string tmp = i->second;
|
||||
decode_entities(tmp);
|
||||
keywords += tmp;
|
||||
} else if (name == "date") {
|
||||
// Yes this doesnt exist. It's output by filters
|
||||
// And the format isn't even standard http/html
|
||||
// FIXME
|
||||
string tmp = i->second;
|
||||
decode_entities(tmp);
|
||||
struct tm tm;
|
||||
if (strptime(tmp.c_str(),
|
||||
" %Y-%m-%d %H:%M:%S ", &tm)) {
|
||||
char ascuxtime[100];
|
||||
sprintf(ascuxtime, "%ld", (long)mktime(&tm));
|
||||
dmtime = ascuxtime;
|
||||
}
|
||||
} else if (name == "robots") {
|
||||
string val = i->second;
|
||||
decode_entities(val);
|
||||
|
||||
@@ -33,7 +33,7 @@ class MyHtmlParser : public HtmlParser {
|
||||
bool in_script_tag;
|
||||
bool in_style_tag;
|
||||
bool pending_space;
|
||||
string title, sample, keywords, dump;
|
||||
string title, sample, keywords, dump, dmtime;
|
||||
string ocharset; // This is the charset our user thinks the doc was
|
||||
string charset; // This is the charset it was supposedly converted to
|
||||
string doccharset; // Set this to value of charset parameter in header
|
||||
|
||||
Reference in New Issue
Block a user