#! /usr/bin/perl # Copyright (C) 2017 Alex Schroeder # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along with # this program. If not, see . use strict; use v5.10; AddModuleDescription('paste-image.pl', 'Paste Files to Upload'); our (@MyInitVariables, $ScriptName, $HtmlHeaders, $MaxPost, $CommentsPattern, $QuestionaskerSecretKey); our ($PasteImageOnBrowse); $PasteImageOnBrowse = 0; push(@MyInitVariables, \&PasteImageScript); # Resampling based on the following: # https://stackoverflow.com/a/19223362/534893 # https://github.com/viliusle/Hermite-resize sub PasteImageScript { my $id = GetId(); return unless $id; OpenPage($id); my $username = GetParam('username', ''); my $templatePage = "Image_{n}_for_$id"; my $templateText = "Image {n}"; my $question = $QuestionaskerSecretKey || 'question'; if ((GetParam('action', 'browse') eq 'edit' or GetParam('action', 'browse') eq 'new' or $CommentsPattern and $id =~ /$CommentsPattern/ or $PasteImageOnBrowse and GetParam('action', 'browse') eq 'browse') and $HtmlHeaders !~ /PasteImage/) { $HtmlHeaders .= << "EOT"; EOT } }