summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/tpl/vnedit3
-rw-r--r--data/tpl/vnpage2
-rw-r--r--data/tpl/vnpage_scr16
-rw-r--r--lib/ChangeLog2
-rw-r--r--lib/VNDB/Util/DB.pm8
-rw-r--r--lib/VNDB/VN.pm7
-rw-r--r--static/files/def.js4
-rw-r--r--static/files/dyna.js43
-rw-r--r--static/files/style.css14
-rw-r--r--util/dump.sql2
-rw-r--r--util/updates/update_1.22.sql5
11 files changed, 82 insertions, 24 deletions
diff --git a/data/tpl/vnedit b/data/tpl/vnedit
index 70bf09a5..eaddf8ed 100644
--- a/data/tpl/vnedit
+++ b/data/tpl/vnedit
@@ -105,6 +105,9 @@
<b style="float: none; display: inline; font-weight: bold">Make sure to submit the form after the upload has finished!</b>
</span><br />
<div id="scrfrm" class="$p{st}">...make sure to enable Javascript...</div>
+ <script type="text/javascript">
+ var scrRel = [|.join(', ', map { ($$_{title} = _hchar($$_{title})) =~ s/\\/\\\\/g; $$_{title}=~s/'/\\'/g; "[ $$_{id}, '$$_{language}', '$$_{title}' ]" } @{$d{rel}}).q|];
+ </script>
|},
{ type => 'sub', title => 'Edit summary', short => 'com' },
diff --git a/data/tpl/vnpage b/data/tpl/vnpage
index a773a3a1..2e9fc6aa 100644
--- a/data/tpl/vnpage
+++ b/data/tpl/vnpage
@@ -35,7 +35,7 @@
[ categories => 'Categories', sub { join(' ', map { my $l=$VNDB::CAT->{substr($_->[0],0,1)}[1]{substr($_->[0],1,2)}; $l?$l.'('.$_->[1].')':() } sort { $a->[0] cmp $b->[0] } @{$_[0]}) || 'No categories selected' }, 1 ],
[ relations => 'Relations', sub { join("<br />\n", map { $VNDB::VREL->[$_->{relation}].': '._hchar($_->{title}) } sort { $a->{id} <=> $b->{id} } @{$_[0]}) } ],
[ image => 'Image', sub { $_[0] > 0 ? sprintf '<img src="%s/cv/%02d/%d.jpg" />', $p{st}, $_[0]%100, $_[0] : $_[0] < 0 ? '[processing]' : 'No image'; } ],
- [ screenshots => 'Screenshots', sub { join "<br />\n", map sprintf('<a href="%s/sf/%02d/%d.jpg">%3$d</a> (%s)',$p{st},$$_{id}%100,$$_{id},$$_{nsfw}?'NSFW':'Safe'), @{$_[0]} } ],
+ [ screenshots => 'Screenshots', sub { join "<br />\n", map sprintf('[%s] <a href="%s/sf/%02d/%d.jpg">%4$d</a> (%s)',$$_{rid}?qq|<a href="/r$$_{rid}">r$$_{rid}</a>|:'no release',$p{st},$$_{id}%100,$$_{id},$$_{nsfw}?'NSFW':'Safe'), @{$_[0]} } ],
[ img_nsfw => 'NSFW', sub { $_[0] ? 'Not safe' : 'Safe' } ]
) ]]
[[ } ]]-
diff --git a/data/tpl/vnpage_scr b/data/tpl/vnpage_scr
index 0675d093..f0c4ae9f 100644
--- a/data/tpl/vnpage_scr
+++ b/data/tpl/vnpage_scr
@@ -7,15 +7,25 @@
]]-
<div id="screenshots">
-[[ for(@{$d{vn}{screenshots}}) { ]]
+[[ for my $r (undef, @{$d{rel}}) {
+ my @s = grep { !$r && !$_->{rid} || $r && $_->{rid} && $_->{rid} == $r->{id} } @{$d{vn}{screenshots}};
+ next if !@s;
+]]-
+[[ if($r) { ]]
+<b><acronym class="icons lang -[[= $r->{language} ]]" title="[[: $VNDB::LANG->{$r->{language}} ]]">&nbsp;</acronym>
+[[: $r->{title} ]]</b>
+[[ } ]]
+[[ for(@s) { ]]
<a href="[[= sprintf '%s/sf/%02d/%d.jpg', $p{st}, $$_{id}%100, $$_{id} ]]"
- [[= $$_{nsfw} ? ' class="scr_nsfw"'.(!$p{AuthNsfw}?' style="display: none"':'') : '' ]]-
+ class="shot [[= $$_{nsfw} ? ' scr_nsfw':'' ]]" [[= !$p{AuthNsfw}&&$$_{nsfw}?' style="display: none"':'' ]]-
rel="[[= $$_{width}.'x'.$$_{height} ]]"><img src="[[= sprintf '%s/st/%02d/%d.jpg', $p{st}, $$_{id}%100, $$_{id} ]]"
/><b>[[= $$_{nsfw} ? 'x' : '&nbsp;' ]]</b></a>
[[ } ]]-
+<br style="clear: left" /><br />
+[[ } ]]
+
</div>
[[ if($nsfw) { ]]-
-<br style="clear: left" /><br />
<p id="scrNsfwHid">&nbsp;</p>
<i style="font-size: 10px;">Items marked with a red X are flagged as NSFW.</i>
[[ } ]]-
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 756f6a9a..652e0afd 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -5,6 +5,7 @@ TODO:
+ Remove all references to an item when it's hidden
(preferably with the option to re-add them when unhiding)
+ Add a link for the hidden 'h' option at /hist
+ + Rewrite the revision diff code, it's horrible...
1.22 - ?
- Inverted vote graph
@@ -18,6 +19,7 @@ TODO:
changes (causedby) -> changes (id)
threads (id, count) -> threads_posts (tid, num)
- Converted relation graphs to PNG
+ - Added link between screenshots and releases
1.21 - 2008-08-16 (r90)
- Added !vn and !uptime commands to Multi::IRC
diff --git a/lib/VNDB/Util/DB.pm b/lib/VNDB/Util/DB.pm
index 2f9ae9f2..8641f6b0 100644
--- a/lib/VNDB/Util/DB.pm
+++ b/lib/VNDB/Util/DB.pm
@@ -824,7 +824,7 @@ sub DBGetVN { # %options->{ id rev char search order results page what cati cate
if($o{what} =~ /screenshots/) {
push(@{$r->[$r{$_->{vid}}]{screenshots}}, $_) && delete $_->{vid} for (@{$s->DBAll(q|
- SELECT vs.vid, s.id, vs.nsfw, s.width, s.height
+ SELECT vs.vid, s.id, vs.nsfw, vs.rid, s.width, s.height
FROM vn_screenshots vs
JOIN screenshots s ON vs.scr = s.id
WHERE vs.vid IN(!l)
@@ -917,9 +917,9 @@ sub _insert_vn_rev { # columns in vn_rev + categories + screenshots + relations
) for (@{$o->{categories}});
$s->DBExec(q|
- INSERT INTO vn_screenshots (vid, scr, nsfw)
- VALUES (?, ?, ?)|,
- $cid, $_->[0], $_->[1]?1:0
+ INSERT INTO vn_screenshots (vid, scr, nsfw, rid)
+ VALUES (?, ?, ?, ?)|,
+ $cid, $_->[0], $_->[1]?1:0, $_->[2]
) for (@{$o->{screenshots}});
$s->DBExec(q|
diff --git a/lib/VNDB/VN.pm b/lib/VNDB/VN.pm
index 9c872619..544bc351 100644
--- a/lib/VNDB/VN.pm
+++ b/lib/VNDB/VN.pm
@@ -83,7 +83,7 @@ sub VNEdit {
relations => join('|||', map { $_->{relation}.','.$_->{id}.','.$_->{title} } @{$v->{relations}}),
categories => join(',', map { $_->[0].$_->[1] } sort { $a->[0] cmp $b->[0] } @{$v->{categories}}),
anime => join(' ', sort { $a <=> $b } map $_->{id}, @{$v->{anime}}),
- screenshots => join(' ', map "$$_{id},$$_{nsfw}", @{$v->{screenshots}}),
+ screenshots => join(' ', map sprintf('%d,%d,%d', $$_{id}, $$_{nsfw}?1:0, $$_{rid}||0), @{$v->{screenshots}}),
) : ();
my $frm = {};
@@ -107,11 +107,11 @@ sub VNEdit {
my $relations = [ map { /^([0-9]+),([0-9]+)/ && $2 != $id ? ( [ $1, $2 ] ) : () } split /\|\|\|/, $frm->{relations} ];
my $cat = [ map { [ substr($_,0,3), substr($_,3,1) ] } split /,/, $frm->{categories} ];
my $anime = [ grep /^[0-9]+$/, split / +/, $frm->{anime} ];
- my $screenshots = [ map [split /,/], grep /^[0-9]+,[01]$/, split / +/, $frm->{screenshots} ];
+ my $screenshots = [ map { local $_=[split /,/];$$_[2]||=undef; $_ } grep /^[0-9]+,[01],[0-9]+$/, split / +/, $frm->{screenshots} ];
$frm->{img_nsfw} = $frm->{img_nsfw} ? 1 : 0;
$frm->{anime} = join ' ', sort { $a <=> $b } @$anime; # re-sort
- $frm->{screenshots} = join ' ', map "$$_[0],$$_[1]", sort { $$a[0] <=> $$b[0] } @$screenshots;
+ $frm->{screenshots} = join ' ', map sprintf('%d,%d,%d', $$_[0], $$_[1]?1:0, $$_[2]||0), sort { $$a[0] <=> $$b[0] } @$screenshots;
return $self->ResRedirect('/v'.$id, 'post')
if $id && !$self->ReqParam('img') && 13 == scalar grep { $b4{$_} eq $frm->{$_} } keys %b4;
@@ -191,6 +191,7 @@ sub VNEdit {
form => $frm,
id => $id,
vn => $v,
+ rel => scalar $self->DBGetRelease(vid => $id),
});
}
diff --git a/static/files/def.js b/static/files/def.js
index b9efaebb..4928cb84 100644
--- a/static/files/def.js
+++ b/static/files/def.js
@@ -230,6 +230,8 @@ function scrNsfwHid() {
var t=0;var n=0;
for(i=0;i<l.length;i++) {
+ if(l[i].className.indexOf('shot')<0)
+ continue;
t++;
if(l[i].className.indexOf('scr_nsfw')>=0)
n++;
@@ -251,7 +253,7 @@ function scrView(what) {
if(ol.length > 0) {
var l=[];
for(i=0;i<ol.length;i++)
- if(!scrNsfwEnabled || ol[i].className.indexOf('scr_nsfw')<0)
+ if(ol[i].className.indexOf('shot')>=0 && (!scrNsfwEnabled || ol[i].className.indexOf('scr_nsfw')<0))
l[l.length] = ol[i];
ol=0;
diff --git a/static/files/dyna.js b/static/files/dyna.js
index b711fec2..f698cd9d 100644
--- a/static/files/dyna.js
+++ b/static/files/dyna.js
@@ -593,13 +593,13 @@ function catSet(id, rnk) {
\***************************/
-var scrL = []; // id, load, nsfw, obj
+var scrL = []; // id, load, nsfw, obj, rid
function scrLoad() {
// 'screenshots' format: id,nsfw id,nsfw ..
var l=x('screenshots').value.split(' ');
for(var i=0;i<l.length;i++)
if(l[i].length > 2)
- scrL[i] = { load: 2, id: l[i].split(',')[0], nsfw: l[i].split(',')[1]>0?1:0 };
+ scrL[i] = { load: 2, id: l[i].split(',')[0], nsfw: l[i].split(',')[1]>0?1:0, rid: l[i].split(',')[2] };
// <tbody> because IE can't operate on <table>
x('scrfrm').innerHTML = '<table><tbody id="scrTbl"></tbody></table>';
@@ -615,14 +615,21 @@ function scrLoad() {
function scrSetSubmit() {
var o=document.forms[1].onsubmit;
document.forms[1].onsubmit = function() {
- var c=0;
- for(var i=0;i<scrL.length;i++)
+ var c=0;var r=0;
+ for(var i=0;i<scrL.length;i++) {
if(scrL[i] && scrL[i].load)
c=1;
- if(!c)
+ if(scrL[i] && scrL[i].rid == 0)
+ r=1;
+ }
+ if(c) {
+ alert('Please wait for the screenshots to be uploaded before submitting the form.');
+ return false;
+ } else if(r) {
+ alert('Please select the appropriate release for every screenshot');
+ return false;
+ } else
return o();
- alert('Please wait for the screenshots to be uploaded before submitting the form.');
- return false;
};
}
@@ -660,7 +667,9 @@ function scrGenerateTR(i) {
+'<input type="checkbox" name="scrNSFW'+i+'" id="scrNSFW'+i+'"'+(scrL[i].nsfw?' checked="checked"':'')+' style="float: left" onclick="scrSer()" /> '
+'<label for="scrNSFW'+i+'" class="checkbox">&nbsp;This screenshot is NSFW.</label>'
+'<input type="button" value="remove" onclick="scrDel('+i+')" style="float: right; width: auto; height: auto" />'
- +'<br /><br />Full size: '+scrL[i].width+'x'+scrL[i].height+'px';
+ +'<br /><b style="float: left; width: auto; margin-right: 5px">Release:</b>'
+ +'<select style="width: 350px; float: none; height: auto;" onchange="scrSer()" id="scrRel'+i+'">'+scrRelList(scrL[i].rid)+'</select>'
+ +'<br />Full size: '+scrL[i].width+'x'+scrL[i].height+'px';
if(scrL[i].obj) {
x('scrTr'+i).getElementsByTagName('td')[1].innerHTML = r;
@@ -708,6 +717,21 @@ function scrStripe() {
l[j].style.backgroundColor = j%2==0 ? '#fff' : '#f5f5f5';
}
+function scrRelLine(rid, sel) {
+ var r;
+ for(var i=0;i<scrRel.length;i++)
+ if(scrRel[i][0] == rid)
+ r = scrRel[i];
+ return '<option value="'+r[0]+'"'+(sel?' selected="selected"':'')+'>['+r[1]+'] '+r[2]+'</option>';
+}
+
+function scrRelList(rid) {
+ var r='<option value="0">-- select release --</option>';
+ for(var i=0;i<scrRel.length;i++)
+ r += scrRelLine(scrRel[i][0], rid == scrRel[i][0] ? 1 : 0);
+ return r;
+}
+
function scrUploadComplete(i) {
if(window.frames['scrIframe'+i].location.href.indexOf('screenshots') > 0) {
try {
@@ -779,7 +803,8 @@ function scrSer() {
for(var i=0;i<scrL.length;i++) {
if(scrL[i] && scrL[i].id && !scrL[i].load) {
scrL[i].nsfw = x('scrNSFW'+i).checked ? '1' : '0';
- r += ' '+scrL[i].id+','+scrL[i].nsfw;
+ scrL[i].rid = x('scrRel'+i).options[x('scrRel'+i).selectedIndex].value;
+ r += ' '+scrL[i].id+','+scrL[i].nsfw+','+scrL[i].rid;
}
}
x('screenshots').value = r;
diff --git a/static/files/style.css b/static/files/style.css
index eca1ee82..85f72612 100644
--- a/static/files/style.css
+++ b/static/files/style.css
@@ -613,7 +613,15 @@ div#screenshots {
margin: 0;
padding: 0;
}
-div#screenshots a {
+div#screenshots b {
+ display: block;
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ background-color: #f5f5f5;
+ font-weight: normal;
+}
+div#screenshots a.shot {
display: block;
float: left;
width: 136px;
@@ -623,10 +631,10 @@ div#screenshots a {
text-decoration: none;
text-align: center;
}
-div#screenshots a:hover {
+div#screenshots a.shot:hover {
background-color: #ccc;
}
-div#screenshots a b {
+div#screenshots a.shot b {
display: block;
margin: -16px 0 0 0;
padding: 0;
diff --git a/util/dump.sql b/util/dump.sql
index cedd2518..39e74bad 100644
--- a/util/dump.sql
+++ b/util/dump.sql
@@ -233,6 +233,7 @@ CREATE TABLE vn_screenshots (
vid integer NOT NULL DEFAULT 0,
scr integer NOT NULL DEFAULT 0,
nsfw boolean NOT NULL DEFAULT FALSE,
+ rid integer DEFAULT NULL,
PRIMARY KEY(vid, scr)
);
@@ -305,6 +306,7 @@ ALTER TABLE vn_rev ADD FOREIGN KEY (id) REFERENCES changes
ALTER TABLE vn_rev ADD FOREIGN KEY (vid) REFERENCES vn (id) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE vn_screenshots ADD FOREIGN KEY (vid) REFERENCES vn_rev (id) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE vn_screenshots ADD FOREIGN KEY (scr) REFERENCES screenshots (id) DEFERRABLE INITIALLY DEFERRED;
+ALTER TABLE vn_screenshots ADD FOREIGN KEY (rid) REFERENCES releases (id) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE vnlists ADD FOREIGN KEY (uid) REFERENCES users (id) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE vnlists ADD FOREIGN KEY (vid) REFERENCES vn (id) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE votes ADD FOREIGN KEY (uid) REFERENCES users (id) DEFERRABLE INITIALLY DEFERRED;
diff --git a/util/updates/update_1.22.sql b/util/updates/update_1.22.sql
index 9a81b2c6..897b0a2b 100644
--- a/util/updates/update_1.22.sql
+++ b/util/updates/update_1.22.sql
@@ -27,3 +27,8 @@ ALTER TABLE changes ADD FOREIGN KEY (causedby) REFERENCES changes (id) DEFERRABL
ALTER TABLE threads_posts ALTER COLUMN num TYPE smallint;
ALTER TABLE threads ADD FOREIGN KEY (id, count) REFERENCES threads_posts (tid, num) DEFERRABLE INITIALLY DEFERRED;
+
+-- screenshots now have a relation with releases
+ALTER TABLE vn_screenshots ADD COLUMN rid integer DEFAULT NULL REFERENCES releases (id) DEFERRABLE INITIALLY DEFERRED;
+
+