📄 refere~1.c
字号:
string localComment = trim(comment); for (int i = 0; i < NUMFORMATVARS; i++){ //if this %VAR is not in template, try next. if (outputString.find(FORMATVARS[i]) == string::npos) continue; if ((FORMATVARS[i] == "%URL") || (FORMATVARS[i] == "%NOACCENTURL")){ if (isFolder()){ string myURL; if (isAliasof()) myURL = url; else if (varValues[SUBDIRSEP] == "/") myURL = name2url(dirname) + varValues[SUBDIRSEP] + varValues[INDEX]; else {//flat file system. myURL = url.substr(varValues[SEARCHTOROOTPATH].size(), url.size()- varValues[SEARCHTOROOTPATH].size()); } if (FORMATVARS[i] == "%URL") replaceAll(outputString, "%URL", myURL); else { string newurl = replaceAccents(myURL); replaceAll(outputString, "%NOACCENTURL", newurl); } } else{ //not a folder if (FORMATVARS[i] == "%URL") replaceAll(outputString, "%URL", url); else { string newurl = replaceAccents(url); replaceAll(outputString, "%NOACCENTURL", newurl); }; } } else if (FORMATVARS[i] == "%TITLE"){ string pt = title; if (children && isAliasof()) pt += "@"; replaceAll(outputString, "%TITLE", pt); } else if (FORMATVARS[i] == "%NOACCENTTITLE"){ string pt = title; if (children && isAliasof()) pt += "@"; string ptn = replaceAccents(pt); replaceAll(outputString, "%NOACCENTTITLE", ptn); } else if (FORMATVARS[i] == "%COMMENT"){ replaceAll(outputString, "%COMMENT", localComment); } else if (FORMATVARS[i] == "%FILLCOMMENT"){ string copylocalComment = localComment; replaceAll(copylocalComment, "<BR>", " "); autoFill(copylocalComment); replaceAll(outputString, "%FILLCOMMENT", copylocalComment); } else if (FORMATVARS[i] == "%LONGCOMMENT"){ string copylocalComment = localComment; replaceAll(copylocalComment, "<BR>", " "); replaceAll(copylocalComment, "\n", " "); replaceAll(copylocalComment, "\t", " "); replaceAll(copylocalComment, "\r", " "); replaceAll(outputString, "%LONGCOMMENT", copylocalComment); } else if (FORMATVARS[i] == "%NOACCENTCOMMENT"){ autoFill(localComment); string newComment = replaceAccents(localComment); replaceAll(newComment, "<BR>", " "); replaceAll(outputString, "%NOACCENTCOMMENT", newComment); } else if (FORMATVARS[i] == "%NHCOMMENT"){ string commentnohtml = localComment; replaceAll(commentnohtml, "<BR>", " "); removeHTML(commentnohtml); autoFill(commentnohtml); replaceAll(outputString, "%NHCOMMENT", commentnohtml); } else if (FORMATVARS[i] == "%SHORTCOMMENT("){ string::size_type start; if ((start = outputString.find("%SHORTCOMMENT(")) != string::npos){ string::size_type end = outputString.find(")", start); string fullmatch = outputString.substr(start, end-start+1); string match = outputString.substr(start+14,end - (start+14)); string::size_type numChars = atoi(match.c_str()); string comm = localComment.substr(0,numChars); replaceAll(comm, "<BR>", " "); replaceAll(comm, "\n", " "); replaceAll(comm, "\t", " "); replaceAll(comm, "\r", " "); // autoFill(comm); replaceAll(outputString, fullmatch, comm); } } else if (FORMATVARS[i] == "%FSCOMMENT"){ string::size_type end; string mycomment = localComment; replaceAll(mycomment, "<BR>", " "); if ((end = fullstop(mycomment, ". ")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("? ")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("! ")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = fullstop(mycomment, ".\t")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = fullstop(mycomment, ".\n")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = fullstop(mycomment, ".\r")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("?\t")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("?\n")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("?\r")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("!\t")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("!\n")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("!\r")) != string::npos){ mycomment = mycomment.substr(0,end+1); }; replaceAll(outputString, "%FSCOMMENT", mycomment); } else if (FORMATVARS[i] == "%JSCOMMENT"){ string copylocalComment = javaScriptEscape(localComment); replaceAll(copylocalComment, "<BR>", " "); replaceAll(outputString, "%JSCOMMENT", copylocalComment); } else if (FORMATVARS[i] == "%JSFSCOMMENT"){ string::size_type end; string mycomment = localComment; replaceAll(mycomment, "<BR>", " "); if ((end = fullstop(mycomment, ". ")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("? ")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("! ")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = fullstop(mycomment, ".\t")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = fullstop(mycomment, ".\n")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = fullstop(mycomment, ".\r")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("?\t")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("?\n")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("?\r")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("!\t")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("!\n")) != string::npos){ mycomment = mycomment.substr(0,end+1); } else if ((end = mycomment.find("!\r")) != string::npos){ mycomment = mycomment.substr(0,end+1); }; mycomment = javaScriptEscape(mycomment); replaceAll(outputString, "%JSFSCOMMENT", mycomment); } else if (FORMATVARS[i] == "%HITS"){ string t = myItoa(hits); replaceAll(outputString, "%HITS", t); } else if (FORMATVARS[i] == "%DAYCRE"){ time_t li = creationTime; struct tm * t = localtime(&li); string ti = myItoa(t->tm_mday); replaceAll(outputString, "%DAYCRE", ti ); } else if (FORMATVARS[i] == "%DAYVIS"){ time_t li = visitTime; struct tm * t = localtime(&li); string ti = myItoa(t->tm_mday); replaceAll(outputString, "%DAYVIS", ti ); } else if (FORMATVARS[i] == "%DAYMOD"){ time_t li = modifiedTime; struct tm * t = localtime(&li); string ti = myItoa(t->tm_mday); replaceAll(outputString, "%DAYMOD", ti ); } else if (FORMATVARS[i] == "%YEARCRE"){ time_t li = creationTime; struct tm * t = localtime(&li); int year = t->tm_year; if (year >= 100) year -= 100; string ti = myItoa(year); if (ti.size() == 1) ti = "0" + ti; replaceAll(outputString, "%YEARCRE", ti ); } else if (FORMATVARS[i] == "%YEARFCRE"){ time_t li = creationTime; struct tm * t = localtime(&li); int year = t->tm_year; year += 1900; string ti = myItoa(year); replaceAll(outputString, "%YEARFCRE", ti ); } else if (FORMATVARS[i] == "%YEARMOD"){ time_t li = modifiedTime; struct tm * t = localtime(&li); int year = t->tm_year; if (year >= 100) year -= 100; string ti = myItoa(year); if (ti.size() == 1) ti = "0" + ti; replaceAll(outputString, "%YEARMOD", ti ); } else if (FORMATVARS[i] == "%YEARFMOD"){ time_t li = modifiedTime; struct tm * t = localtime(&li); int year = t->tm_year; year += 1900; string ti = myItoa(year); replaceAll(outputString, "%YEARFMOD", ti ); } else if (FORMATVARS[i] == "%YEARVIS"){ time_t li = visitTime; struct tm * t = localtime(&li); int year = t->tm_year; if (year >= 100) year -= 100; string ti = myItoa(year); if (ti.size() == 1) ti = "0" + ti; replaceAll(outputString, "%YEARVIS", ti ); } else if (FORMATVARS[i] == "%YEARFVIS"){ time_t li = visitTime; struct tm * t = localtime(&li); int year = t->tm_year; year += 1900; string ti = myItoa(year); replaceAll(outputString, "%YEARFVIS", ti ); } else if (FORMATVARS[i] == "%MONTHCRE1"){ time_t li = creationTime; struct tm * t = localtime(&li); int j = t->tm_mon; j++; string ti = myItoa(j); replaceAll(outputString, "%MONTHCRE1", ti ); } else if (FORMATVARS[i] == "%MONTHCRE2"){ time_t li = creationTime; struct tm * t = localtime(&li); int j = t->tm_mon; j++; string m = getMonth(j); replaceAll(outputString, "%MONTHCRE2", m ); } else if (FORMATVARS[i] == "%MONTHVIS1"){ time_t li = visitTime; struct tm * t = localtime(&li); int j = t->tm_mon; j++; string ti = myItoa(j); replaceAll(outputString, "%MONTHVIS1", ti ); } else if (FORMATVARS[i] == "%MONTHVIS2"){ time_t li = visitTime; struct tm * t = localtime(&li); int j = t->tm_mon; j++; string m = getMonth(j); replaceAll(outputString, "%MONTHVIS2", m ); } else if (FORMATVARS[i] == "%MONTHMOD1"){ time_t li = modifiedTime; struct tm * t = localtime(&li); int j = t->tm_mon; j++; string ti = myItoa(j); replaceAll(outputString, "%MONTHMOD1", ti ); } else if (FORMATVARS[i] == "%MONTHMOD2"){ time_t li = modifiedTime; struct tm * t = localtime(&li); int j = t->tm_mon; j++; string m = getMonth(j); replaceAll(outputString, "%MONTHMOD2", m ); } else if (FORMATVARS[i] == "%LEAFS") if (children){ string c = myItoa(children->getNumLeafs()); replaceAll(outputString, "%LEAFS", c); } else replaceAll(outputString, "%LEAFS", ""); else if (FORMATVARS[i] == "%NEW") if (creationTime + timeCutoff > currentTime){ // time_t li = creationTime; // struct tm * t = localtime(&li); // string dayCreated = myItoa(t->tm_mday); // int j = t->tm_mon; // j++; // string monthCreated = myItoa(j); // string yearCreated = myItoa(t->tm_year); string newgifTemplate = varValues[NEWGIF]; if (newgifTemplate.find("%NEW") != string::npos) replaceAll(newgifTemplate, "%NEW", ""); //nip those infinite loops in the bud. string ng = sendAsHTML(newgifTemplate, varValues); // string ng = "<IMG SRC=\"" + varValues[NEWGIF] + "\" align=middle alt=\"Added " // + monthCreated +"/" + dayCreated + "/" + yearCreated + "\"> "; replaceAll(outputString, "%NEW", ng); } else replaceAll(outputString, "%NEW", ""); else if (FORMATVARS[i] == "%TIMEFCRE"){ long int l = creationTime; string c (ctime(&l)); c = c.substr(0,c.size()-1); replaceAll(outputString, "%TIMEFCRE", c); } else if (FORMATVARS[i] == "%TIMEFMOD"){ long int l = modifiedTime; string c(ctime(&l)); c = c.substr(0,c.size()-1); replaceAll(outputString, "%TIMEFMOD", c); } else if (FORMATVARS[i] == "%TIMEFVIS"){ long int l = visitTime; string c(ctime(&l)); c = c.substr(0,c.size()-1); replaceAll(outputString, "%TIMEFVIS", c); } else if (FORMATVARS[i] == "%CONDDASH"){ if (comment != "") replaceAll(outputString, "%CONDDASH", "-"); else replaceAll(outputString, "%CONDDASH", ""); } else if (FORMATVARS[i] == "%IFCOMHAS("){ string::size_type ifstart; while ((ifstart = outputString.find("%IFCOMHAS(")) != string::npos){ string::size_type ifmid = outputString.find(")(",ifstart); string::size_type ifend = outputString.find(")",ifmid+1); string fullif = outputString.substr(ifstart, ifend-ifstart+1); string match = outputString.substr(ifstart+10, ifmid - (ifstart+10)); string htmltoadd = outputString.substr(ifmid+2 , ifend - (ifmid+2)); replaceAll(outputString, fullif, ""); if (comment.find(match) != string::npos){ replaceAll(localComment, match, ""); outputString.insert(ifstart,htmltoadd); } i = 0; //so html can contain %stuff } } } funstring finalanswer(outputString); return finalanswer.eval();}/** write as bookmark file */void reference::writeAsBookHelper(ostream& output, string & prepend) const{ if (!isPrivate()){ output << prepend << "<DT>"; if (children == 0){ //its a leaf output << "<A HREF=\"" << url << "\" "; if (aliasID != "") output << ALIASID << "=\"" << aliasID << "\" "; if (aliasOf != "") output << ALIASOF << "=\"" << aliasOf << "\" "; output << addDate << "=\"" << creationTime << "\" " << lastVisit << "=\"" << visitTime << "\" " << lastModified << "=\"" << modifiedTime << "\">" << title << "</A>" << endl; if (comment != ""){ string comt(comment); replaceAll(comt,"<","<"); output << "<DD>" << comt << endl; }; } else { //its a folder output << "<H3 FOLDED " << addDate << "=\"" << creationTime << "\">" << title << "</H3>" << endl; if ((comment != "") || isAliasof() || (commentCommands != "")){ string comt = comment + commentCommands; replaceAll(comt,"<","<"); if (isAliasof()) comt = ALIAS + comt; output << "<DD>" << comt << endl; //netscape does not indent folder comments, why? }; output << prepend << "<DL><p>" << endl; if (!isAliasof()){ string np = prepend + " "; children->writeAsBookHelper(output, np); } output << prepend << "</DL><p>" << endl; } }};/** write as xbel file */void reference::writeAsXBELHelper(ostream& output, string & prepend) const{ if (!isPrivate()){ if (children == 0){ //its a bookmark output << prepend << "<bookmark href=\"" << url << "\" "; //The times should be wrapped in a getISOTime() to fully conform to the standard, //but I prefer to deal with longs. output << "added=\"" << creationTime << "\" " << "visited=\"" << visitTime << "\" " << "modified=\"" << modifiedTime << "\" "; if (aliasID != "") output << "id=\"" << aliasID << "\" "; output << ">" << endl; if (aliasOf != "") output << prepend << "<alias ref=\"" << aliasOf << "\"/>" << endl; output << prepend << "<title>" << title << "</title>" << endl; if (comment != ""){ string comt(comment); // replaceAll(comt,"<","<"); replaceAll(comt,"<BR>",""); output << prepend << "<desc>" << comt << "</desc>" << endl; }; output << prepend << "</bookmark>" << endl; } else { //its a folder output << prepend << "<folder added=\"" << creationTime << "\">" << endl; output << prepend << "<title>" << title << "</title>" << endl; if ((comment != "") || isAliasof() || (commentCommands != "")){ string comt = comment + commentCommands; // replaceAll(comt,"<","<"); replaceAll(comt,"<BR>",""); if (isAliasof()) comt = ALIAS + comt; output << prepend << "<desc>" << comt << "</desc>" << endl; //netscape does not indent folder comments, why? }; if (!isAliasof()){ string np = prepend + " "; children->writeAsXBELHelper(output, np); } output << prepend << "</folder>" << endl; } }};// //write as bookmark file// ostream &operator<<(ostream& output, const reference & r) // {// if (!r.isPrivate()){// output << "<DT>";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -