+ manage with the homepage

This commit is contained in:
kelson42 2010-01-19 19:51:59 +00:00
parent b071218ce6
commit 8e10f94cd7

View File

@ -48,28 +48,6 @@ function iecompattest(){ \n \
return (document.compatMode && document.compatMode!=\"BackCompat\")? document.documentElement : document.body \n \ return (document.compatMode && document.compatMode!=\"BackCompat\")? document.documentElement : document.body \n \
} \n \ } \n \
\n \ \n \
function get_cookie(Name) { \n \
var search = Name + \"=\" \n \
var returnvalue = \"\"; \n \
if (document.cookie.length > 0) { \n \
offset = document.cookie.indexOf(search) \n \
if (offset != -1) { \n \
offset += search.length \n \
end = document.cookie.indexOf(\";\", offset); \n \
if (end == -1) \n \
end = document.cookie.length; \n \
returnvalue=unescape(document.cookie.substring(offset, end)) \n \
} \n \
} \n \
return returnvalue; \n \
} \n \
\n \
function closebar(){ \n \
if (persistclose) \n \
document.cookie=\"remainclosed=1\" \n \
document.getElementById(\"topbar\").style.visibility=\"hidden\" \n \
} \n \
\n \
function staticbar(){ \n \ function staticbar(){ \n \
barheight=document.getElementById(\"topbar\").offsetHeight \n \ barheight=document.getElementById(\"topbar\").offsetHeight \n \
var ns = (navigator.appName.indexOf(\"Netscape\") != -1) || window.opera; \n \ var ns = (navigator.appName.indexOf(\"Netscape\") != -1) || window.opera; \n \
@ -133,10 +111,10 @@ static void appendToFirstOccurence(string &content, const string regex, const st
regex_t regexp; regex_t regexp;
regcomp(&regexp, regex.data(), REG_ICASE); regcomp(&regexp, regex.data(), REG_ICASE);
regexec(&regexp, content.data(), 1, matchs, 0); if (!regexec(&regexp, content.data(), 1, matchs, 0)) {
if (matchs[0].rm_so > 0) if (matchs[0].rm_so > 0)
content.replace(matchs[0].rm_eo, 0, replacement); content.insert(matchs[0].rm_eo, replacement);
}
regfree(&regexp); regfree(&regexp);
} }
@ -201,6 +179,15 @@ static int accessHandlerCallback(void *cls,
/* Mutex lock */ /* Mutex lock */
pthread_mutex_lock(&lock); pthread_mutex_lock(&lock);
/* Main page */
if (strcmp(title, "") == 0 && strcmp(ns, "") == 0) {
if (zimFileHandler->getFileheader().hasMainPage()) {
zim::Article article = zimFileHandler->getArticle(zimFileHandler->getFileheader().getMainPage());
ns[0] = article.getNamespace();
strcpy(title, article.getUrl().c_str());
}
}
/* Load the article from the ZIM file */ /* Load the article from the ZIM file */
cout << "Loading '" << title << "' in namespace '" << ns << "'... " << endl; cout << "Loading '" << title << "' in namespace '" << ns << "'... " << endl;
try { try {
@ -232,6 +219,7 @@ static int accessHandlerCallback(void *cls,
if (mimeType == "text/html") { if (mimeType == "text/html") {
appendToFirstOccurence(content, "<head>", HTMLScripts); appendToFirstOccurence(content, "<head>", HTMLScripts);
appendToFirstOccurence(content, "<body[^>]*>", HTMLDiv); appendToFirstOccurence(content, "<body[^>]*>", HTMLDiv);
contentLength = content.size();
} }
} else { } else {