GUI: allow setting the snippet separator inside abstract (now a real html ellipsis by default)
This commit is contained in:
+21
-4
@@ -93,10 +93,21 @@ class DocSequence {
|
||||
/** Get abstract for document. This is special because it may take time.
|
||||
* The default is to return the input doc's abstract fields, but some
|
||||
* sequences can compute a better value (ie: docseqdb) */
|
||||
virtual string getAbstract(Rcl::Doc& doc) {
|
||||
return doc.meta[Rcl::Doc::keyabs];
|
||||
virtual bool getAbstract(Rcl::Doc& doc, vector<string>& abs) {
|
||||
abs.push_back(doc.meta[Rcl::Doc::keyabs]);
|
||||
return true;
|
||||
}
|
||||
virtual string getAbstract(Rcl::Doc& doc) {
|
||||
vector<string> v;
|
||||
getAbstract(doc, v);
|
||||
string abstract;
|
||||
for (vector<string>::const_iterator it = v.begin();
|
||||
it != v.end(); it++) {
|
||||
abstract += *it;
|
||||
abstract += "... ";
|
||||
}
|
||||
return abstract;
|
||||
}
|
||||
|
||||
virtual bool getEnclosing(Rcl::Doc&, Rcl::Doc&) = 0;
|
||||
|
||||
/** Get estimated total count in results */
|
||||
@@ -152,7 +163,13 @@ public:
|
||||
{}
|
||||
virtual ~DocSeqModifier() {}
|
||||
|
||||
virtual string getAbstract(Rcl::Doc& doc)
|
||||
virtual bool getAbstract(Rcl::Doc& doc, vector<string>& abs)
|
||||
{
|
||||
if (m_seq.isNull())
|
||||
return false;
|
||||
return m_seq->getAbstract(doc, abs);
|
||||
}
|
||||
virtual string getAbstract(Rcl::Doc& doc)
|
||||
{
|
||||
if (m_seq.isNull())
|
||||
return "";
|
||||
|
||||
+8
-11
@@ -71,20 +71,17 @@ int DocSequenceDb::getResCnt()
|
||||
return m_rescnt;
|
||||
}
|
||||
|
||||
string DocSequenceDb::getAbstract(Rcl::Doc &doc)
|
||||
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<string>& vabs)
|
||||
{
|
||||
setQuery();
|
||||
if (!m_q->whatDb())
|
||||
return doc.meta[Rcl::Doc::keyabs];
|
||||
string abstract;
|
||||
if (m_q->whatDb() &&
|
||||
m_queryBuildAbstract && (doc.syntabs || m_queryReplaceAbstract)) {
|
||||
m_q->whatDb()->makeDocAbstract(doc, m_q.getptr(), vabs);
|
||||
}
|
||||
if (vabs.empty())
|
||||
vabs.push_back(doc.meta[Rcl::Doc::keyabs]);
|
||||
|
||||
if (m_queryBuildAbstract && (doc.syntabs || m_queryReplaceAbstract)) {
|
||||
m_q->whatDb()->makeDocAbstract(doc, m_q.getptr(), abstract);
|
||||
} else {
|
||||
abstract = doc.meta[Rcl::Doc::keyabs];
|
||||
}
|
||||
|
||||
return abstract.empty() ? doc.meta[Rcl::Doc::keyabs] : abstract;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DocSequenceDb::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
|
||||
|
||||
@@ -34,7 +34,7 @@ class DocSequenceDb : public DocSequence {
|
||||
vector<vector<string> >& groups,
|
||||
vector<int>& gslks);
|
||||
virtual void getUTerms(vector<string>& terms);
|
||||
virtual string getAbstract(Rcl::Doc &doc);
|
||||
virtual bool getAbstract(Rcl::Doc &doc, vector<string>&);
|
||||
virtual bool getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc);
|
||||
virtual string getDescription();
|
||||
virtual list<string> expand(Rcl::Doc &doc);
|
||||
|
||||
@@ -177,15 +177,22 @@ void ResListPager::displayDoc(RclConfig *config,
|
||||
sizebuf = displayableBytes(fsize);
|
||||
}
|
||||
|
||||
string abstract;
|
||||
if (m_docSource.isNotNull())
|
||||
abstract = m_docSource->getAbstract(doc);
|
||||
string richabst;
|
||||
bool needabstract = parFormat().find("%A") != string::npos;
|
||||
if (needabstract && m_docSource.isNotNull()) {
|
||||
vector<string> vabs;
|
||||
m_docSource->getAbstract(doc, vabs);
|
||||
|
||||
// No need to call escapeHtml(), plaintorich handles it
|
||||
list<string> lr;
|
||||
m_hiliter->set_inputhtml(false);
|
||||
m_hiliter->plaintorich(abstract, lr, hdata);
|
||||
string richabst = lr.front();
|
||||
for (vector<string>::const_iterator it = vabs.begin();
|
||||
it != vabs.end(); it++) {
|
||||
// No need to call escapeHtml(), plaintorich handles it
|
||||
list<string> lr;
|
||||
m_hiliter->set_inputhtml(false);
|
||||
m_hiliter->plaintorich(*it, lr, hdata);
|
||||
richabst += lr.front();
|
||||
richabst += absSep();
|
||||
}
|
||||
}
|
||||
|
||||
// Links;
|
||||
ostringstream linksbuf;
|
||||
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
virtual void suggest(const vector<string>, vector<string>&sugg) {
|
||||
sugg.clear();
|
||||
}
|
||||
|
||||
virtual string absSep() {return "…";}
|
||||
private:
|
||||
int m_pagesize;
|
||||
int m_newpagesize;
|
||||
|
||||
Reference in New Issue
Block a user