From f73c8f66ce3d7246ee0dec0e78cf9bbdd7217fd6 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Wed, 25 Apr 2012 04:16:48 -0400 Subject: [PATCH 1/4] beige.css with changes from campaignwiki.org Mostly the introduction of more classes such as .aside and other classes to be used in divs. I also added a .gitignore file for the Emacs backup files and the current.pl that is created by the Makefile. --- .gitignore | 2 ++ css/beige.css | 70 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..bca14d4a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +/current.pl diff --git a/css/beige.css b/css/beige.css index 3be5d7c1..ea92d053 100644 --- a/css/beige.css +++ b/css/beige.css @@ -16,6 +16,23 @@ body { font-size:12pt; } } + +/* iPhone */ + +@media only screen and (max-device-width: 480px) { + body { font-size: 200%; } +} + +/* iPad */ + +@media only screen and (min-device-width: 481px) and (max-device-width: 900px) { + body { font-size: 150%; } + textarea,input { font-size: 100%; } + img { max-width: 550px !important; } +} + + + div.browse { min-height: 3em; } @@ -41,6 +58,14 @@ div.commentshown { } div.commenthidden { display:none; } div.commentshown { display:block; } +/* comment pages with username, homepage, and email subscription */ +.comment span { display: block; } +.comment span label { + display: inline-block; width: 10em; +} +input#mail, input#homepage, input#username { + display: inline-block; width: 20em; +} h1 { font-weight: bold; @@ -63,9 +88,10 @@ h2 { font-weight: bold; color: white; background-color: #000; - width: 98%; + /* width: 98%; */ font-size: 110%; padding: 0.2em; + clear: both; } a:link { font-weight: bold; @@ -89,21 +115,47 @@ div.image { display: inline; margin: 1em; font-size: 90%; text-align: center; } .right { float: right; margin-left: 1em; } div.right .right { float: none; } div.left .left { float: none; } +.caption { padding: 0 1em; } +.license { font-size: small; } +.aside { + font-size: small; + width: 30%; + float: right; + margin-left: 1em; + margin-bottom: 1em; + padding-left: 1em; +} +.aside img.smiley { height: 1em; } +.narrow { + width: 70%; +} a img { border: 1px solid #333; } .fit img { width: 80%; text-align: center; margin: 2em 8%; } .half img { width: 50%; height: 50%; text-align: center; margin: 2em 8%; } .noborder img { border: none; } +.twenty img { max-width: 20em; } em.underline { font-weight: bold; } .bar a { padding-right: 1em; } textarea { width:100%; } div.edit { padding-right: 1em; } -img.logo { float: right; clear: right; border-style:none; } +img.logo { + float: right; + clear: right; + border-style:none; + margin-left: 1em; + margin-bottom: 1ex; + border: 1px solid black; +} div.diff { padding-left:5%; padding-right:5%; } div.old { background-color:#FFFFAF; } div.new { background-color:#CFFFCF; } -div.message { background-color:#FEE; } +/* div.message { background-color:#FEE; } */ +div.message { + background-color: inherit; + font-size: smaller; +} table.history { border-style:none; } td.history { border-style:none; } span.result { font-size:larger; } @@ -132,6 +184,10 @@ table.user { border-top: 1px solid black; border-bottom: 1px solid black; } +div.aside table.user { + margin: 1em 0; + padding: 0; +} table.user td, table.user th { border-style: none; padding:5px 10px; @@ -153,6 +209,12 @@ table.user td.mark { background-color:yellow; } } } +/* Help */ + +.edit table { + font-size: small; +} + /* Calendar */ div.month { margin:0; padding:0; font-size:x-small; float:right; } div.content div.month { float:none; } @@ -164,7 +226,7 @@ div.month span.title a { font: inherit; } div.month a.local { font-weight: bold; } div.month a.local:link { color: #562; } div.month a.local:visited { color: #542; } -div.month a.today { font-weight: bold; color: #fff; } +div.month a.today { background-color: #faa; } div.month span.title a.local { font-weight: normal; color: #842; } @media print { div.month { display: none; } From 8ed24a11f85bb3e618bf2773e038186ab65812f2 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Fri, 27 Apr 2012 00:45:23 +0200 Subject: [PATCH 2/4] Remove unused local variables in GetPageFile, InitLinkPatterns --- wiki.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wiki.pl b/wiki.pl index 951be1be..f3ff3595 100755 --- a/wiki.pl +++ b/wiki.pl @@ -381,7 +381,7 @@ sub SetParam { } sub InitLinkPatterns { - my ($UpperLetter, $LowerLetter, $AnyLetter, $WikiWord, $QDelim); + my ($WikiWord, $QDelim); $QDelim = '(?:"")?'; # Optional quote delimiter (removed from the output) $WikiWord = '[A-Z]+[a-z\x80-\xff]+[A-Z][A-Za-z\x80-\xff]*'; $LinkPattern = "($WikiWord)$QDelim"; @@ -2717,7 +2717,7 @@ sub GetKeptRevision { # Call after OpenPage } sub GetPageFile { - my ($id, $revision) = @_; + my ($id) = @_; return $PageDir . '/' . GetPageDirectory($id) . "/$id.pg"; } From c11a196f8f826153c922a228efcab2944f5d85aa Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Fri, 27 Apr 2012 01:10:27 +0200 Subject: [PATCH 3/4] Ignore #bla# files created by Emacs and test-data directory --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index bca14d4a..bc97e4b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *~ /current.pl +\#*\# +/test-data From 41ef3cb3864ef96744be909d5accbfde3a9b6bec Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Thu, 17 May 2012 02:25:19 +0200 Subject: [PATCH 4/4] added imap2wiki script --- imap2wiki | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100755 imap2wiki diff --git a/imap2wiki b/imap2wiki new file mode 100755 index 00000000..774eb0e4 --- /dev/null +++ b/imap2wiki @@ -0,0 +1,152 @@ +#!/usr/bin/perl -w +# +# Copyright (C) 2012 Alex Schroeder +# +# 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 3 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, see . + +use strict; +use Getopt::Std; +use LWP::UserAgent; +use Net::IMAP::Simple; +use Email::Simple; +use Email::MIME; +use IO::Socket::SSL; # fail unless this is available + +my $usage = "Usage:\n" + . " imap2wiki TARGET SERVER PORT FROM TO MAIL_USER MAIL_PASSWORD \\\n" + . " MAIL_USER MAIL_PASSWORD WIKI_USER [WIKI_PASSWORD]\n\n" + . "TARGET is the base URL for the wiki.\n" + . "SERVER is the IMAP server you are checking.\n" + . "PORT is the port you are using.\n" + . " (We assume that you must use SSL.)\n" + . "FROM is sender you are looking for.\n" + . "TO is recipient you are looking for.\n" + . "MAIL_USER is the username to connect to the mail server.\n" + . "MAIL_PASSWORD is the password to use for the mail server.\n" + . "WIKI_USER is the username to use for the edit.\n" + . "WIKI_PASSWORD is the password to use if required.\n" + . "Example:\n" + . " imap2wiki http://www.emacswiki.org/cgi-bin/test imap.gmail.com 993 \\\n" + . " kensanata\@gmail.com kensanata+post\@gmail.com \\\n" + . " kensanata\@gmail.com '*secret*' \\\n" + . " Alex test\n\n"; + +sub UrlEncode { + my $str = shift; + return '' unless $str; + my @letters = split(//, $str); + my @safe = ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '-', '_', '.', '!', + '~', '*', "'", '(', ')', '#'); + foreach my $letter (@letters) { + my $pattern = quotemeta($letter); + if (not grep(/$pattern/, @safe)) { + $letter = sprintf("%%%02x", ord($letter)); + } + } + return join('', @letters); +} + +sub GetRaw { + my ($uri) = @_; + my $ua = LWP::UserAgent->new; + my $response = $ua->get($uri); + return $response->content if $response->is_success; +} + +sub PostRaw { + my ($uri, $id, $data, $user, $pwd) = @_; + my $ua = LWP::UserAgent->new; + my $summary; + if ($data =~ /^#FILE (\S+) ?(\S+)?\n/) { + $summary = 'file upload'; + } + my $response = $ua->post($uri, {title=>$id, text=>$data, raw=>1, + summary=>$summary, + username=>$user, pwd=>$pwd}); + warn "POST $id failed: " . $response->status_line . "\n" + unless $response->is_success; + return $response->is_success; +} + +sub post { + my ($target, $page, $data, $user, $pwd) = @_; + $page =~ s/ /_/g; + $page = UrlEncode ($page); + return PostRaw($target, $page, $data, $user, $pwd); +} + +sub main { + my ($target, $server, $port, $from, $to, + $mail_user, $mail_pwd, $wiki_user, $wiki_pwd) = @ARGV; + # all parameters except the wiki password are mandatory + for my $arg ($target, $server, $port, $from, $to, + $mail_user, $mail_pwd, $wiki_user) { + die $usage unless $arg; + } + + my $imap = Net::IMAP::Simple->new($server, port=>$port, use_ssl=>1 ) + or die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n"; + + if (not $imap->login($mail_user, $mail_pwd)) { + print STDERR "Login failed: " . $imap->errstr . "\n"; + exit(64); + } + + my %result; + my $rfrom = quotemeta($from); + my $rto = quotemeta($to); + + # go through the inbox and look for appropriate mails + my $num = $imap->select('INBOX'); + for (my $i = 1; $i <= $num; $i++) { + # looking at headers only + my $email = Email::Simple->new(join '', @{ $imap->top($i) } ); + if ($email->header("From") =~ /$rfrom/io + and $email->header("To") =~ /$rto/io) { + my $subject = $email->header('Subject'); + my $n = 1; + # fetch the body and parse the MIME stuff + $email = Email::MIME->new(join '', @{ $imap->get($i) } ); + + $email->walk_parts(sub { + my ($part) = @_; + return if $part->subparts; # multipart + + my ($pagename, $data); + + warn $part->content_type; + + if ($part->content_type =~ m[text/plain]i) { + ($pagename, $data) = ($subject, $part->body); + } elsif ($part->content_type =~ m!(image/[a-z]+)!i) { + ($pagename, $data) = ($subject . " " . $n++, + "#FILE " . $1 . "\n" . $part->body_raw); + } + + if ($pagename and $data) { + warn "Posting $pagename\n"; + post($target, $pagename, $data, $wiki_user, $wiki_pwd) + || die "Posting aborted, INBOX not expunged\n"; + } + } ); + + # mark as deleted + $imap->delete($i); + } + } + + # expunge messages that are marked for deletion + $imap->quit; +} + +main();