]> 91.132.146.200 Git - insipid.git/commitdiff
screenshot overview
authorBanana <banana@starscream.de>
Fri, 30 Nov 2012 13:45:57 +0000 (14:45 +0100)
committerBanana <banana@starscream.de>
Fri, 30 Nov 2012 13:45:57 +0000 (14:45 +0100)
insipid.cgi
lib/Insipid/Main.pm
lib/Insipid/Screenshots.pm [new file with mode: 0644]
lib/Insipid/Stats.pm
lib/Insipid/Tags.pm

index 6713da78533e3f3a1bde54c0d723b7b9856b1ffe..4bb6de35e8d7662bf5aa8658b59afd714f539803 100755 (executable)
@@ -18,7 +18,6 @@
 # USA
 #
 
-use Data::Dumper;
 use warnings;
 use strict;
 
@@ -38,7 +37,7 @@ eval {
 };
 
 if($@) {
-       my $errstr = $@;        
+       my $errstr = $@;
        if($errstr =~ /Can\'t locate (.*) in/) {
                show_error("Couldn't find the module \"$1\".", "You may want to " .
                        "<a href=\"http://search.cpan.org/\">search CPAN</a> " .
@@ -64,7 +63,7 @@ if($@) {
 
                if($@) {
                        $errstr = $@;
-                       show_error("Database error", "There was a problem " . 
+                       show_error("Database error", "There was a problem " .
                        "creating the database tables required by Insipid:",
                        $errstr);
                }
index 66fb6e741f499944166afe1aa0566be2c5614772..97c0739193f6b223ebc7bf791624d40287173bb9 100755 (executable)
@@ -40,6 +40,7 @@ use Insipid::Snapshots;
 use Insipid::Tags;
 use Insipid::Util;
 use Insipid::Stats;
+use Insipid::Screenshots;
 
 use CGI qw/:standard/;
 use CGI::Carp qw(fatalsToBrowser);
@@ -545,7 +546,7 @@ BLET
             }
 
             # screenshot overview
-            if (param('op') eq 'screenshots') {
+            if (param('op') eq 'screenshots' && $usePhantomjs) {
                 show_screenshots();
                 print "</td></tr></table><br /></body></html>";
                 exit;
@@ -886,6 +887,7 @@ sub show_toolbar {
         print "<a class=\"tools\" href=\"$site_url/insipid.cgi?op=import\">import</a> | ";
         print "<a class=\"tools\" href=\"$site_url/insipid.cgi?op=export\">export</a> | ";
         print "<a class=\"tools\" href=\"$site_url/insipid.cgi?op=snapshots\">snapshots</a> | ";
+        print "<a class=\"tools\" href=\"$site_url/insipid.cgi?op=screenshots\">screenshots</a> | ";
         print "<a class=\"tools\" href=\"$site_url/insipid.cgi?op=logout\">logout</a><br />";
         print "<a class=\"tools\" href=\"$site_url/insipid.cgi?op=add_bookmark\">add</a> | ";
         print "<a class=\"tools\" href=\"$site_url/insipid.cgi?op=bookmarklets\">bookmarklets</a> | ";
diff --git a/lib/Insipid/Screenshots.pm b/lib/Insipid/Screenshots.pm
new file mode 100644 (file)
index 0000000..872ac03
--- /dev/null
@@ -0,0 +1,89 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 2012 jumpin.banana
+#
+# 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+# USA
+#
+
+package Insipid::Screenshots;
+
+use strict;
+use warnings;
+
+use vars qw(@ISA @EXPORT @EXPORT_OK);
+use CGI qw/:standard/;
+use CGI::Carp qw(fatalsToBrowser);
+use Insipid::Config;
+use Insipid::Database;
+use Insipid::Sessions;
+use Insipid::Util;
+require Exporter;
+
+use URI;
+use URI::Escape;
+use POSIX qw/strftime/;
+use File::Basename;
+
+@ISA = qw(Exporter);
+
+@EXPORT = qw(
+show_screenshots
+);
+
+sub show_screenshots {
+
+       if(defined(param('delete')) && defined(param('hash'))) {
+               my $_md5 = param('hash');
+               if($_md5 ne '') {
+                       unlink("./screenshots/$_md5.png");
+                       print "<p style='color: green'>Screenshot deleted.</p>";
+               }
+       }
+
+       my @files = <./screenshots/*.png>;
+       if(@files) {
+               print '<table>';
+               print '<tr><th>Screenshot</th><th>Date</th><th>Bookmark</th><th>Options</th></tr>';
+               foreach my $file (@files) {
+                       # some file informations
+                       my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime,
+                       $mtime, $ctime, $blksize, $blocks) = stat($file);
+
+                       my $md5Hash = basename($file,  ".png");
+
+                       # get the bookmark
+                       my $sql = "select $tbl_bookmarks.url, $tbl_bookmarks.id from $tbl_bookmarks
+                                               where ($tbl_bookmarks.md5 = ?)";
+                       my $sth = $dbh->prepare($sql);
+                       $sth->execute($md5Hash);
+                       my @r = $sth->fetchrow_array;
+
+                       my $bookmark = $r[0];
+                       my $bookmarkID = $r[1];
+
+                       print '<tr>';
+                       print "<td><a href='".$file ."'>Screenshotfile</a></td>";
+                       print "<td>".scalar localtime($mtime)."</td>";
+                       print "<td><a href='$bookmark'>$bookmark</a></td>\n";
+                       print "<td><a href='$site_url/insipid.cgi?op=screenshots&delete=1&hash=$md5Hash'>delete</a>, <a href='$site_url/insipid.cgi?op=screenshot&id=$bookmarkID'>refresh</a></td>\n";
+                       print '</tr>';
+               }
+               print '</table>';
+       }
+       else {
+               print "<p>No screenshots available yet.</p>";
+       }
+}
index 088e692b81357d098732d7104c9e7883af20f6ad..505193d07b17ec9e8a9be2e2a56de0fc3b45c837 100644 (file)
@@ -35,8 +35,6 @@ require Exporter;
 use URI;
 use URI::Escape;
 
-use Data::Dumper;
-
 @ISA = qw(Exporter);
 
 @EXPORT = qw(
index 6d6c25d79318213e2ba06c54619354e02ea3a8cb..46e681b3609ccac895e1b61ab432a8c83b607f81 100755 (executable)
@@ -32,8 +32,6 @@ use Insipid::Sessions;
 use Insipid::Util;
 require Exporter;
 
-use Data::Dumper;
-
 @ISA = qw(Exporter);
 
 @EXPORT = qw(