+ getMetatag*(

This commit is contained in:
kelson42 2010-07-04 18:11:25 +00:00
parent 3555e4f918
commit 5891b91433
2 changed files with 178 additions and 171 deletions

View File

@ -45,29 +45,29 @@ namespace kiwix {
this->currentArticleOffset = this->firstArticleOffset; this->currentArticleOffset = this->firstArticleOffset;
} }
/* Get the count of articles which can be indexed/displayed */ /* Get the count of articles which can be indexed/displayed */
unsigned int Reader::getArticleCount() { unsigned int Reader::getArticleCount() {
return this->articleCount; return this->articleCount;
} }
/* Return the UID of the ZIM file */ /* Return the UID of the ZIM file */
string Reader::getId() { string Reader::getId() {
std::ostringstream s; std::ostringstream s;
s << this->zimFileHandler->getFileheader().getUuid(); s << this->zimFileHandler->getFileheader().getUuid();
return s.str(); return s.str();
} }
/* Return a random article URL */ /* Return a random article URL */
string Reader::getRandomPageUrl() { string Reader::getRandomPageUrl() {
zim::size_type idx = this->firstArticleOffset + zim::size_type idx = this->firstArticleOffset +
(zim::size_type)((double)rand() / ((double)RAND_MAX + 1) * this->articleCount); (zim::size_type)((double)rand() / ((double)RAND_MAX + 1) * this->articleCount);
zim::Article article = zimFileHandler->getArticle(idx); zim::Article article = zimFileHandler->getArticle(idx);
return article.getLongUrl().c_str(); return article.getLongUrl().c_str();
} }
/* Return the welcome page URL */ /* Return the welcome page URL */
string Reader::getMainPageUrl() { string Reader::getMainPageUrl() {
string url = ""; string url = "";
if (this->zimFileHandler->getFileheader().hasMainPage()) { if (this->zimFileHandler->getFileheader().hasMainPage()) {
@ -76,11 +76,19 @@ string Reader::getMainPageUrl() {
} }
return url; return url;
} }
/* Return the first page URL */ /* Return a metatag value */
string Reader::getFirstPageUrl() { bool Reader::getMetatag(const string &name, string &value) {
unsigned int contentLength = 0;
string contentType = "";
return this->getContentByUrl( "/M/" + name, value,
contentLength, contentType);
}
/* Return the first page URL */
string Reader::getFirstPageUrl() {
string url = ""; string url = "";
zim::size_type firstPageOffset = zimFileHandler->getNamespaceBeginOffset('A'); zim::size_type firstPageOffset = zimFileHandler->getNamespaceBeginOffset('A');
@ -90,7 +98,7 @@ string Reader::getFirstPageUrl() {
return url; return url;
} }
/* Get a content from a zim file */ /* Get a content from a zim file */
bool Reader::getContentByUrl(const string &urlStr, string &content, unsigned int &contentLength, string &contentType) { bool Reader::getContentByUrl(const string &urlStr, string &content, unsigned int &contentLength, string &contentType) {
bool retVal = false; bool retVal = false;
const char *url = urlStr.c_str(); const char *url = urlStr.c_str();
@ -173,9 +181,9 @@ string Reader::getFirstPageUrl() {
} }
return retVal; return retVal;
} }
/* Search titles by prefix*/ /* Search titles by prefix*/
bool Reader::searchSuggestions(const string &prefix, unsigned int suggestionsCount) { bool Reader::searchSuggestions(const string &prefix, unsigned int suggestionsCount) {
bool retVal = true; bool retVal = true;
@ -202,10 +210,10 @@ string Reader::getFirstPageUrl() {
this->suggestionsOffset = this->suggestions.begin(); this->suggestionsOffset = this->suggestions.begin();
return retVal; return retVal;
} }
/* Get next suggestion */ /* Get next suggestion */
bool Reader::getNextSuggestion(string &title) { bool Reader::getNextSuggestion(string &title) {
bool retVal = false; bool retVal = false;
if (this->suggestionsOffset != this->suggestions.end()) { if (this->suggestionsOffset != this->suggestions.end()) {
@ -219,7 +227,5 @@ bool Reader::getNextSuggestion(string &title) {
} }
return retVal; return retVal;
} }
} }

View File

@ -24,6 +24,7 @@ namespace kiwix {
string getRandomPageUrl(); string getRandomPageUrl();
string getFirstPageUrl(); string getFirstPageUrl();
string getMainPageUrl(); string getMainPageUrl();
bool getMetatag(const string &url, string &content);
bool getContentByUrl(const string &url, string &content, unsigned int &contentLength, string &contentType); bool getContentByUrl(const string &url, string &content, unsigned int &contentLength, string &contentType);
bool searchSuggestions(const string &prefix, unsigned int suggestionsCount); bool searchSuggestions(const string &prefix, unsigned int suggestionsCount);
bool getNextSuggestion(string &title); bool getNextSuggestion(string &title);