wiki.pl: Port some fixes from upstream
[Orgmuse.git] / modules / css-install.pl
blob500bb6b637f9dc35bfab8f00b2eb6d1610f5b3fd
1 =head1 NAME
3 css-install - an Oddmuse module that allows users to change the site CSS
5 =head1 SYNOPSIS
7 This module allows users to install their own CSS. This is useful for
8 new wikis, specially if using the I<Namespaces> extension.
10 =head1 INSTALLATION
12 Installing a module is easy: Create a modules subdirectory in your
13 data directory, and put the Perl file in there. It will be loaded
14 automatically.
16 =cut
18 $ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/css-install.pl">css-install.pl</a></p>';
20 =head1 CONFIGURATION
22 =head2 @CssList
24 C<@CssList> contains a list of all the recommended CSS URLs.
26 =cut
28 package OddMuse;
30 use vars qw(@CssList);
32 # List of Oddmuse CSS URLs
34 @CssList = qw(http://www.emacswiki.org/css/astrid.css
35 http://www.emacswiki.org/css/beige-red.css
36 http://www.emacswiki.org/css/blue.css
37 http://www.emacswiki.org/css/cali.css
38 http://www.emacswiki.org/css/green.css
39 http://www.emacswiki.org/css/hug.css
40 http://www.emacswiki.org/css/oddmuse.css
41 http://www.emacswiki.org/css/wikio.css);
43 push(@MyAdminCode, \&CssInstallMenu);
45 sub CssInstallMenu {
46 my ($id, $menuref, $restref) = @_;
47 push(@$menuref, ScriptLink('action=css', T('Install CSS'), 'css'))
48 unless $StyleSheet;
51 $Action{css} = \&DoCss;
53 sub DoCss {
54 my $css = GetParam('install', '');
55 if ($css) {
56 my $data = GetRaw($css);
57 ReportError(Ts('%s returned no data, or LWP::UserAgent is not available.', $css),
58 '500 INTERNAL SERVER ERROR') unless $data;
59 SetParam('text', $data);
60 DoPost($StyleSheetPage);
61 } else {
62 print GetHeader('', T('Install CSS')), $q->start_div({-class=>'content css'}),
63 $q->p(Ts('Copy one of the following stylesheets to %s:', GetPageLink($StyleSheetPage)));
64 # undo preview
65 print GetFormStart(undef, 'GET'), GetHiddenValue('action', 'css');
66 print GetHiddenValue('css', '');
67 print $q->submit(-name=>'Reset', -value=>T('Reset'));
68 print $q->end_form;
69 # save
70 print GetFormStart(undef, 'GET'), GetHiddenValue('action', 'css');
71 print GetHiddenValue('install', '');
72 print $q->submit(-name=>'Save', -accesskey=>T('s'), -value=>T('Save'));
73 print $q->end_form;
74 print $q->end_div();
75 foreach my $url (@CssList) {
76 print $q->start_div({-class=>'sheet'}), $q->p(GetUrl($url));
77 # preview
78 print GetFormStart(undef, 'GET'), GetHiddenValue('action', 'css');
79 print GetHiddenValue('css', $url);
80 print $q->submit(-name=>'Preview', -accesskey=>T('p'), -value=>T('Preview'));
81 print $q->end_form;
82 # save
83 print GetFormStart(undef, 'GET'), GetHiddenValue('action', 'css');
84 print GetHiddenValue('css', '');
85 print GetHiddenValue('install', $url);
86 print $q->submit(-name=>'Save', -accesskey=>T('s'), -value=>T('Save'));
87 print $q->end_form;
88 print $q->end_div();
90 print $q->end_div();
91 PrintFooter();
95 =head1 COPYRIGHT AND LICENSE
97 Copyright (C) 2011 Alex Schroeder <alex@gnu.org>
99 This program is free software: you can redistribute it and/or modify it under
100 the terms of the GNU General Public License as published by the Free Software
101 Foundation, either version 3 of the License, or (at your option) any later
102 version.
104 This program is distributed in the hope that it will be useful, but WITHOUT ANY
105 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
106 PARTICULAR PURPOSE. See the GNU General Public License for more details.
108 You should have received a copy of the GNU General Public License along with
109 this program. If not, see <http://www.gnu.org/licenses/>.
111 =cut