Skip to content
Browse files

fix #6: final commit to enable 'send mobi via mail'

  • Loading branch information...
1 parent e3eeba7 commit f5bc6df78ce2318e91aec878886ed68b07197293 @reneeb committed Jan 6, 2013
Showing with 22 additions and 12 deletions.
  1. +1 −0 .gitignore
  2. +10 −6 pod_book/lib/PodBook/CpanSearch.pm
  3. +11 −6 pod_book/templates/cpan_search/form.html.ep
View
1 .gitignore
@@ -0,0 +1 @@
+reb.yml
View
16 pod_book/lib/PodBook/CpanSearch.pm
@@ -42,14 +42,15 @@ sub form {
}
$self->stash( listsize => $listsize );
+ $self->stash( message => '' );
+
my $via_mail = $self->cookie( 'via_mail' ) || 0;
$self->stash( via_mail => $via_mail );
- my $mobi_mail = $self->cookie( 'mobi_mail' ) || '';
+ my $mobi_mail = $self->cookie( 'mail' ) || '';
$self->stash( mobi_mail => $mobi_mail );
- my $mobi_sent = $self->cookie( 'mobi_sent' ) || 0;
- $self->stash( mobi_sent => $mobi_sent );
+ $self->stash( mobi_sent => 0 );
# set the optional message no matter what happens!
$self->stash( optional_message => $opt_msg );
@@ -92,7 +93,8 @@ sub form {
mobi => 1,
);
- my $type = lc $self->param('target');
+ my @types = $self->param('target');
+ my $type = lc $types[0];
if ( !$targets{$type} ) {
# EXIT if unknown
@@ -324,20 +326,22 @@ sub send_download_to_client {
# send mobi file to mail address
my $type = lc $self->param('target');
my $mobi_send = $self->param( 'mobi_send' ) || $self->cookie( 'mail' );
-
+
if ( $type eq 'mobi' && $mobi_send ) {
my ($mail,$save) = split /\|\|/, $mobi_send;
# save mail address in cookie if requested
if ( $save && $save eq 'yes' && $mail ) {
$self->cookie( mail => $mail );
+ $self->stash( mobi_mail => $mail );
if ( $self->param( 'always_mail' ) ) {
$self->cookie( via_mail => 1 );
+ $self->stash( via_mail => 1 );
}
}
- if ( $mail ) {
+ if ( $mail && $mail ne '-1' ) {
$self->app->log->info( "Send $name via mail" );
$self->mail(
mail => {
View
17 pod_book/templates/cpan_search/form.html.ep
@@ -16,6 +16,7 @@
<input type="hidden" name="mobi_send" id="mobi_send" />
<input type="hidden" name="target" id="mobi_target" />
+ <input type="hidden" name="always_mail" id="always_mail_form" />
<br />
</form>
<div id="msg">
@@ -40,7 +41,7 @@
<br />
<label for="always_mail">Send .mobi always per mail:</label>
- <input type="checkbox" name="always_mail" id="always_mail" />
+ <input type="checkbox" id="always_mail_dialog" value="1" />
</div>
<script type="text/javascript">
@@ -54,6 +55,7 @@
}
$('#mobi_btn').click( function() {
+ $('#mobi_target').val('mobi');
if ( !via_mail ) {
$('#dialog').dialog( 'open' );
return false;
@@ -66,18 +68,21 @@
width: 400,
modal: true,
buttons: {
- Ok: function() {
+ "Send via mail": function() {
$('#mobi_send').val(
$('#mail').val() + '||' + $('#save').val()
);
$(this).dialog( 'close' );
- $('#mobi_target').val('mobi');
- $('#perlybook').submit();
},
- Cancel: function() {
+ "Download" : function() {
+ $('#mobi_send').val(-1);
$(this).dialog( 'close' );
- $('#perlybook').submit();
},
+ },
+ close : function () {
+ $('#mobi_target').val('mobi');
+ $('#always_mail_form').val( $('#always_mail_dialog').is(':checked') ? 1 : 0 );
+ $('#perlybook').submit();
}
});
});

0 comments on commit f5bc6df

Please sign in to comment.
Something went wrong with that request. Please try again.