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

View File

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