mirror of
https://github.com/adamdruppe/arsd.git
synced 2025-04-26 13:20:05 +03:00
more stuff
This commit is contained in:
parent
b0bd5cd1fe
commit
4b5a1a916e
5 changed files with 370 additions and 53 deletions
55
html.d
55
html.d
|
@ -233,61 +233,10 @@ Html linkify(string text) {
|
|||
/// Returns true of the string appears to be html/xml - if it matches the pattern
|
||||
/// for tags or entities.
|
||||
bool appearsToBeHtml(string src) {
|
||||
return false;
|
||||
import std.regex;
|
||||
return cast(bool) match(src, `.*\<[A-Za-z]+>.*`);
|
||||
}
|
||||
|
||||
/+
|
||||
void qsaFilter(string logicalScriptName) {
|
||||
string logicalScriptName = siteBase[0 .. $-1];
|
||||
|
||||
foreach(a; document.querySelectorAll("a[qsa]")) {
|
||||
string href = logicalScriptName ~ _cgi.pathInfo ~ "?";
|
||||
|
||||
int matches, possibilities;
|
||||
|
||||
string[][string] vars;
|
||||
foreach(k, v; _cgi.getArray)
|
||||
vars[k] = cast(string[]) v;
|
||||
foreach(k, v; decodeVariablesSingle(a.qsa)) {
|
||||
if(k in _cgi.get && _cgi.get[k] == v)
|
||||
matches++;
|
||||
possibilities++;
|
||||
|
||||
if(k !in vars || vars[k].length <= 1)
|
||||
vars[k] = [v];
|
||||
else
|
||||
assert(0, "qsa doesn't work here");
|
||||
}
|
||||
|
||||
string[] clear = a.getAttribute("qsa-clear").split("&");
|
||||
clear ~= "ajaxLoading";
|
||||
if(a.parentNode !is null)
|
||||
clear ~= a.parentNode.getAttribute("qsa-clear").split("&");
|
||||
|
||||
bool outputted = false;
|
||||
varskip: foreach(k, varr; vars) {
|
||||
foreach(item; clear)
|
||||
if(k == item)
|
||||
continue varskip;
|
||||
foreach(v; varr) {
|
||||
if(outputted)
|
||||
href ~= "&";
|
||||
else
|
||||
outputted = true;
|
||||
|
||||
href ~= std.uri.encodeComponent(k) ~ "=" ~ std.uri.encodeComponent(v);
|
||||
}
|
||||
}
|
||||
|
||||
a.href = href;
|
||||
|
||||
a.removeAttribute("qsa");
|
||||
|
||||
if(matches == possibilities)
|
||||
a.addClass("current");
|
||||
}
|
||||
}
|
||||
+/
|
||||
string favicon(Document document) {
|
||||
auto item = document.querySelector("link[rel~=icon]");
|
||||
if(item !is null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue