internal linking

hash-command-arbitrary
Avril 6 years ago
parent 88e302226e
commit 8a374940e5
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -1,3 +1,5 @@
var internal_url_re = /(?:>>>)?(?:https?:\/\/)?flanchan\.moe\/s\/((?:\d|\w)(?:\d|\w|\/)*)/;
/* YOUTUBE */ /* YOUTUBE */
// fairly liberal regexp that will accept things like // fairly liberal regexp that will accept things like

@ -474,6 +474,23 @@ on_input: function (val) {
end -= diff; end -= diff;
} }
} }
/* and internal links */
while (true) {
var m = val.match(internal_url_re);
if (!m)
break;
var sc = '>>>/s/' + m[1];
var old = m[0].length;
val = val.substr(0, m.index) + sc + val.substr(m.index + old);
changed = true;
ward = m.index;
ward_len = sc.length;
if (m.index < start) {
var diff = old - sc.length;
start -= diff;
end -= diff;
}
}
/* and Twitter links */ /* and Twitter links */
while (true) { while (true) {
var m = val.match(twitter_url_re); var m = val.match(twitter_url_re);

@ -201,7 +201,7 @@ var OS = OneeSama.prototype;
var break_re = new RegExp("(\\S{" + DEFINES.WORD_LENGTH_LIMIT + "})"); var break_re = new RegExp("(\\S{" + DEFINES.WORD_LENGTH_LIMIT + "})");
/* internal refs, embeds */ /* internal refs, embeds */
var ref_re = />>(\d+|>\/watch\?v=[\w-]{11}(?:#t=[\dhms]{1,9})?|>\/soundcloud\/[\w-]{1,40}\/[\w-]{1,80}|>\/@\w{1,15}\/\d{4,20}(?:\?s=\d+)?|>\/(?:a|sysint|nap)\/\d{0,10})/; var ref_re = />>(\d+|>\/s\/(?:\w|\d)(?:\w|\d|\/)*|>\/watch\?v=[\w-]{11}(?:#t=[\dhms]{1,9})?|>\/soundcloud\/[\w-]{1,40}\/[\w-]{1,80}|>\/@\w{1,15}\/\d{4,20}(?:\?s=\d+)?|>\/(?:a|sysint|nap)\/\d{0,10})/;
OS.hook = function (name, func) { OS.hook = function (name, func) {
var hs = this.hooks[name]; var hs = this.hooks[name];
@ -241,10 +241,14 @@ OS.red_string = function (ref) {
dest = 'https://www.youtube.com/' + ref.slice(2); dest = 'https://www.youtube.com/' + ref.slice(2);
linkClass = 'embed watch'; linkClass = 'embed watch';
} }
else if (prefix == '>/s') { else if (prefix2 == '>/sou') {
dest = 'https://soundcloud.com/' + ref.slice(13); dest = 'https://soundcloud.com/' + ref.slice(13);
linkClass = 'embed soundcloud'; linkClass = 'embed soundcloud';
} }
else if (prefix == '>/s') {
dest ="/"+ ref.slice(2);
linkClass = 'embed'
}
else if (prefix == '>/@') { else if (prefix == '>/@') {
var bits = ref.slice(3).split('/'); var bits = ref.slice(3).split('/');
dest = 'https://twitter.com/' + bits[0] + '/status/' + bits[1]; dest = 'https://twitter.com/' + bits[0] + '/status/' + bits[1];

@ -20,10 +20,12 @@
"dependencies": { "dependencies": {
"async": "2.1.4", "async": "2.1.4",
"chart.js": "^2.7.2", "chart.js": "^2.7.2",
"diskspace": "^2.0.0",
"formidable": "1.0.17", "formidable": "1.0.17",
"hashloli": "file:../hashloli",
"jsoncompress": "^0.1.3", "jsoncompress": "^0.1.3",
"minimist": "1.2.0", "minimist": "1.2.0",
"nan": "2.5.0", "nan": "^2.14.0",
"recaptcha2": "^1.3.2", "recaptcha2": "^1.3.2",
"redis": "2.6.3", "redis": "2.6.3",
"request": "2.79", "request": "2.79",

Loading…
Cancel
Save