forked from Cavemanon/cavepaintings
Hacky way of getting uploads working implemented
This works by abusing the fact that ratings are technically tags. Upload a file, add a rating, and then send it off. The tags_for_upload_slot func then takes the data sent over, explodes it out into individual instances. Notably, you can put your own data here (i.e. ratings) to then have them be considered tags. This hack forces ratings to be a dependency as no code was added to assume otherwise. Take this patch at your own risk.
This commit is contained in:
parent
40f4d76b12
commit
f038cd72fb
@ -267,9 +267,7 @@ class Upload extends Extension
|
|||||||
# merge then explode, not explode then merge - else
|
# merge then explode, not explode then merge - else
|
||||||
# one of the merges may create a surplus "tagme"
|
# one of the merges may create a surplus "tagme"
|
||||||
return Tag::explode(
|
return Tag::explode(
|
||||||
($_POST["tags"] ?? "") .
|
($_POST["tags"] ?? "") . " " . ($_POST["tags$id"] ?? "") . " " . ($_POST["rating"] ?? "") . " " . ($_POST["rating$id"] ?? "")
|
||||||
" " .
|
|
||||||
($_POST["tags$id"] ?? "")
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ use function MicroHTML\BR;
|
|||||||
use function MicroHTML\A;
|
use function MicroHTML\A;
|
||||||
|
|
||||||
use function MicroHTML\P;
|
use function MicroHTML\P;
|
||||||
|
use function MicroHTML\OPTION;
|
||||||
|
use function MicroHTML\SELECT;
|
||||||
|
|
||||||
class UploadTheme extends Themelet
|
class UploadTheme extends Themelet
|
||||||
{
|
{
|
||||||
@ -56,7 +58,7 @@ class UploadTheme extends Themelet
|
|||||||
),
|
),
|
||||||
$upload_list,
|
$upload_list,
|
||||||
TR(
|
TR(
|
||||||
TD(["colspan"=>"6"], INPUT(["id"=>"uploadbutton", "type"=>"submit", "value"=>"Post"]))
|
TD(["colspan"=>"8"], INPUT(["id"=>"uploadbutton", "type"=>"submit", "value"=>"Post"]))
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -86,18 +88,26 @@ class UploadTheme extends Themelet
|
|||||||
TR(
|
TR(
|
||||||
TD(["colspan"=>$tl_enabled ? 2 : 4], "Files"),
|
TD(["colspan"=>$tl_enabled ? 2 : 4], "Files"),
|
||||||
$tl_enabled ? TD(["colspan"=>"2"], "URLs") : emptyHTML(),
|
$tl_enabled ? TD(["colspan"=>"2"], "URLs") : emptyHTML(),
|
||||||
TD(["colspan"=>"2"], "Post-Specific Tags"),
|
TD(["colspan"=>"1"], "Rating"),
|
||||||
|
TD(["colspan"=>"3"], "Post-Specific Tags"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
for ($i=0; $i<$upload_count; $i++) {
|
for ($i=0; $i<$upload_count; $i++) {
|
||||||
$upload_list->appendChild(
|
$upload_list->appendChild(
|
||||||
TR(
|
TR(
|
||||||
TD(["colspan"=>$tl_enabled ? 2 : 4], INPUT(["type"=>"file", "name"=>"data${i}[]", "accept"=>$accept, "multiple"=>true])),
|
TD(["colspan"=>$tl_enabled ? 2 : 2], INPUT(["type"=>"file", "name"=>"data${i}[]", "accept"=>$accept, "multiple"=>true])),
|
||||||
$tl_enabled ? TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"url${i}"])) : emptyHTML(),
|
$tl_enabled ? TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"url${i}"])) : emptyHTML(),
|
||||||
#TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"tags${i}", "class"=>"autocomplete_tags", "autocomplete"=>"off"])),
|
TD(["colspan"=>"4"],
|
||||||
DIV(["class"=>'edit'],
|
SELECT(["name"=>"rating${i}"],
|
||||||
TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"tags${i}", "id"=>"tag_editor", "class"=>"autocomplete_tags", "autocomplete"=>"off"])),
|
OPTION(["value"=>"rating:safe"], "Safe"),
|
||||||
|
OPTION(["value"=>"rating:questionable"], "Questionable"),
|
||||||
|
OPTION(["value"=>"rating:explicit"], "Explicit"),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
DIV(["class"=>'edit'],
|
||||||
|
TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"tags${i}", "id"=>"tag_editor", "class"=>"autocomplete_tags", "autocomplete"=>"off"])),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -120,21 +130,21 @@ class UploadTheme extends Themelet
|
|||||||
function() {
|
function() {
|
||||||
if(typeof window=="undefined" || !window.location || window.location.href=="about:blank") {
|
if(typeof window=="undefined" || !window.location || window.location.href=="about:blank") {
|
||||||
window.location = "'. $main_page .'";
|
window.location = "'. $main_page .'";
|
||||||
}
|
}
|
||||||
else if(typeof document=="undefined" || !document.body) {
|
else if(typeof document=="undefined" || !document.body) {
|
||||||
window.location = "'. $main_page .'?url="+encodeURIComponent(window.location.href);
|
window.location = "'. $main_page .'?url="+encodeURIComponent(window.location.href);
|
||||||
}
|
}
|
||||||
else if(window.location.href.match("\/\/'. $_SERVER["HTTP_HOST"] .'.*")) {
|
else if(window.location.href.match("\/\/'. $_SERVER["HTTP_HOST"] .'.*")) {
|
||||||
alert("You are already at '. $title .'!");
|
alert("You are already at '. $title .'!");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var tags = prompt("Please enter tags", "tagme");
|
var tags = prompt("Please enter tags", "tagme");
|
||||||
if(tags != "" && tags != null) {
|
if(tags != "" && tags != null) {
|
||||||
var link = "'. $link . $delimiter .'url="+location.href+"&tags="+tags;
|
var link = "'. $link . $delimiter .'url="+location.href+"&tags="+tags;
|
||||||
var w = window.open(link, "_blank");
|
var w = window.open(link, "_blank");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)();';
|
)();';
|
||||||
$html1 = P(
|
$html1 = P(
|
||||||
A(["href"=>$js], "Upload to $title"),
|
A(["href"=>$js], "Upload to $title"),
|
||||||
@ -199,7 +209,7 @@ class UploadTheme extends Themelet
|
|||||||
["id"=>"large_upload_form", "class"=>"vert"],
|
["id"=>"large_upload_form", "class"=>"vert"],
|
||||||
$upload_list,
|
$upload_list,
|
||||||
TR(TD("Source"), TD(["colspan"=>3], INPUT(["name"=>"source", "type"=>"text"]))),
|
TR(TD("Source"), TD(["colspan"=>3], INPUT(["name"=>"source", "type"=>"text"]))),
|
||||||
TR(TD(["colspan"=>4], INPUT(["id"=>"uploadbutton", "type"=>"submit", "value"=>"Post"]))),
|
TR(TD(["colspan"=>6], INPUT(["id"=>"uploadbutton", "type"=>"submit", "value"=>"Post"]))),
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user