chiark / gitweb /
automatic agpl compliance: generate links on login forms etc.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Feb 2013 11:59:58 +0000 (11:59 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Feb 2013 11:59:58 +0000 (11:59 +0000)
cgi-auth-flexible.pm

index de603bc..dd44e22 100644 (file)
@@ -173,6 +173,30 @@ sub gen_plain_login_link ($$) {
            '</a>');
 }
 
+sub gen_special_link_html ($$$$) {
+    my ($c,$r,$anchor,$specval) = @_;
+    my %params = ($r->{S}{special_param_name} => [ $specval ]);
+    return '<a href="'.escapeHTML($r->url_with_query_params(\%params)).'">'.
+       $anchor."</a>";
+}
+sub gen_plain_agpl_link_html ($$) {
+    my ($c,$r) = @_;
+    gen_special_link_html($c,$r, 'GNU Affero GPL', 'licence');
+}
+sub gen_plain_source_link_html ($$) {
+    my ($c,$r) = @_;
+    gen_special_link_html($c,$r, 'Source available', 'source');
+}
+
+sub gen_plain_footer_html ($$) {
+    my ($c,$r) = @_;
+    return ('<hr><address>',
+           ("Powered by Free / Libre / Open Source Software".
+            " according to the ".$r->_ch('gen_agpl_link_html')."."),
+           $r->_ch('gen_source_link_html').".",
+           '</address>');
+}
+
 #---------- verifier object methods ----------
 
 sub new_verifier {
@@ -197,6 +221,7 @@ sub new_verifier {
            dummy_param_name_prefix => 'caf__',
            cookie_name => "caf_assocsecret",
            password_param_name => 'password',
+           special_param_name => 'caf_special',
            username_param_names => [qw(username)],
            form_entry_size => 60,
            logout_param_names => [qw(caf_logout)],
@@ -221,6 +246,9 @@ sub new_verifier {
            get_cookie_domain => \&get_cookie_domain,
            encrypted_only => 1,
            gen_start_html => sub { $_[0]->start_html($_[2]); },
+           gen_footer_html => \&gen_plain_footer_html,
+           gen_agpl_link_html => \&gen_plain_agpl_link_html,
+           gen_source_link_html => \&gen_plain_source_link_html,
            gen_end_html => sub { $_[0]->end_html(); },
            gen_login_form => \&gen_plain_login_form,
            gen_login_link => \&gen_plain_login_link,
@@ -828,8 +856,9 @@ sub check_ok ($) {
 
     $r->_print($r->{Cgi}->header($r->_cgi_header_args($cookie)),
               $r->_ch('gen_start_html',$title),
-              (join "\n", @body),
-              $r->_ch('gen_end_html'));
+              (join "\n", (@body,
+                           $r->_ch('gen_footer_html'),
+                           $r->_ch('gen_end_html'))));
     return 0;
 }