From: Quentin Smith Date: Sat, 20 Mar 2010 16:16:48 +0000 (-0400) Subject: Merge branch 'master' into sipb X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/commitdiff_plain/f01dd5d502ecb0e6ca4096ff039bc37998046889?hp=9fb3409613d32e447ababb99bc963867b80340e9 Merge branch 'master' into sipb --- diff --git a/.gitignore b/.gitignore index 8de36e2c8..a64612219 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ ikiwiki.out pm_to_blib *.man build-stamp +*~ po/po2wiki_stamp po/underlays/*/*.mdwn po/underlays/basewiki/*/*.mdwn diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 07369ac10..d7c85ecb8 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -110,10 +110,14 @@ sub cgi_signin ($$) { template => {type => 'div'}, stylesheet => baseurl()."style.css", ); - my $buttons=["Login"]; - + # MITLOGIN: These should be restored when logins are allowed again. + #my $buttons=["Login"]; + my $buttons=[]; + if ($q->param("do") ne "signin" && !$form->submitted) { - $form->text(gettext("You need to log in first.")); + #$form->text(gettext("You need to log in first.")); + $form->text( + "You must have an MIT personal certificate to edit"); } $form->field(name => "do", type => "hidden", value => "signin", force => 1); @@ -207,13 +211,16 @@ sub cgi_prefs ($$) { force => 1); $form->field(name => "sid", type => "hidden", value => $session->id, force => 1); - $form->field(name => "email", size => 50, fieldset => "preferences"); + #$form->field(name => "email", size => 50, fieldset => "preferences"); + $form->field(name => "realname", size => 50, fieldset => "preferences"); my $user_name=$session->param("name"); if (! $form->submitted) { - $form->field(name => "email", force => 1, - value => userinfo_get($user_name, "email")); + #$form->field(name => "email", force => 1, + #value => userinfo_get($user_name, "email")); + $form->field(name => "realname", force => 1, + value => userinfo_get($user_name, "realname")); } if ($form->submitted eq 'Logout') { @@ -230,7 +237,10 @@ sub cgi_prefs ($$) { userinfo_set($user_name, 'email', $form->field('email')) || error("failed to set email"); } - + if (defined $form->field('realname')) { + userinfo_set($user_name, 'realname', $form->field('realname')) || + error("failed to set realname"); + } $form->text(gettext("Preferences saved.")); } diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index b02f4a5ed..e3e1448d3 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -4,6 +4,7 @@ package IkiWiki::Plugin::git; use warnings; use strict; use IkiWiki; +use IkiWiki::UserInfo; use Encode; use open qw{:utf8 :std}; @@ -476,8 +477,9 @@ sub rcs_commit_staged ($$$) { my %env=%ENV; if (defined $user || defined $ipaddr) { my $u=encode_utf8(defined $user ? $user : $ipaddr); - $ENV{GIT_AUTHOR_NAME}=$u; - $ENV{GIT_AUTHOR_EMAIL}="$u\@web"; + # MITLOGIN This algorithm could be improved + $ENV{GIT_AUTHOR_NAME}=IkiWiki::userinfo_get($u, "realname"); + $ENV{GIT_AUTHOR_EMAIL}="$u\@mit.edu"; } $message = IkiWiki::possibly_foolish_untaint($message); diff --git a/IkiWiki/Plugin/httpauth.pm b/IkiWiki/Plugin/httpauth.pm index 478f67446..0bdc4a754 100644 --- a/IkiWiki/Plugin/httpauth.pm +++ b/IkiWiki/Plugin/httpauth.pm @@ -5,6 +5,7 @@ package IkiWiki::Plugin::httpauth; use warnings; use strict; use IkiWiki 3.00; +use Data::Dumper; sub import { hook(type => "getsetup", id => "httpauth", call => \&getsetup); @@ -53,7 +54,14 @@ sub auth ($$) { my $session=shift; if (defined $cgi->remote_user()) { - $session->param("name", $cgi->remote_user()); + my $user = $cgi->remote_user(); + $session->param("name", $user); + eval IkiWiki::possibly_foolish_untaint($ENV{SSL_CLIENT_S_DN_CN}); + my $realname = IkiWiki::userinfo_get($user, "realname"); + if ((!defined $realname || $realname eq "") && + defined $ENV{SSL_CLIENT_S_DN_CN}) { + IkiWiki::userinfo_set($user, "realname", $ENV{SSL_CLIENT_S_DN_CN}); + } } } diff --git a/IkiWiki/Plugin/mdwn.pm b/IkiWiki/Plugin/mdwn.pm index b892eabee..68765c6b8 100644 --- a/IkiWiki/Plugin/mdwn.pm +++ b/IkiWiki/Plugin/mdwn.pm @@ -52,7 +52,7 @@ sub htmlize (@) { } if (! defined $markdown_sub) { eval q{use Text::Markdown}; - if (! $@) { + if (1) {#! $@) { # Text::Markdown throws this but works. Shrug. if (Text::Markdown->can('markdown')) { $markdown_sub=\&Text::Markdown::markdown; } diff --git a/IkiWiki/Plugin/parentlinks.pm b/IkiWiki/Plugin/parentlinks.pm index 728bbc399..bdf678069 100644 --- a/IkiWiki/Plugin/parentlinks.pm +++ b/IkiWiki/Plugin/parentlinks.pm @@ -32,10 +32,17 @@ sub parentlinks ($) { my @pagepath=(split("/", $page)); my $pagedepth=@pagepath; + + # The last element in @pagepath is the page itself, so punt that + # (These are /parent/ links, after all.) + pop @pagepath; + foreach my $dir (@pagepath) { next if $dir eq 'index'; $depth=$i; $height=($pagedepth - $depth); + $path.="/".$dir; + $title=pagetitle($dir); push @ret, { url => urlto(bestlink($page, $path), $page), page => $title, @@ -44,8 +51,6 @@ sub parentlinks ($) { "depth_$depth" => 1, "height_$height" => 1, }; - $path.="/".$dir; - $title=pagetitle($dir); $i++; } return @ret; diff --git a/IkiWiki/Plugin/toc.pm b/IkiWiki/Plugin/toc.pm index ac07b9af6..1e888a82d 100644 --- a/IkiWiki/Plugin/toc.pm +++ b/IkiWiki/Plugin/toc.pm @@ -29,6 +29,7 @@ sub preprocess (@) { if ($params{page} eq $params{destpage}) { $params{levels}=1 unless exists $params{levels}; + $params{startlevel}=2 unless exists $params{startlevel}; # It's too early to generate the toc here, so just record the # info. diff --git a/IkiWiki/UserInfo.pm b/IkiWiki/UserInfo.pm index 0bf100a95..31f20c517 100644 --- a/IkiWiki/UserInfo.pm +++ b/IkiWiki/UserInfo.pm @@ -36,8 +36,17 @@ sub userinfo_get ($$) { if (! defined $userinfo || ! exists $userinfo->{$user} || ! ref $userinfo->{$user} || ! exists $userinfo->{$user}->{$field}) { + if ($field eq "realname" && defined $ENV{SSL_CLIENT_S_DN_CN}) { + userinfo_set($user, "realname", $ENV{SSL_CLIENT_S_DN_CN}); + return $ENV{SSL_CLIENT_S_DN_CN}; + } return ""; } + if ($field eq "realname" && $userinfo->{$user}->{$field} eq "" && + defined $ENV{SSL_CLIENT_S_DN_CN}) { + userinfo_set($user, "realname", $ENV{SSL_CLIENT_S_DN_CN}); + return $ENV{SSL_CLIENT_S_DN_CN}; + } return $userinfo->{$user}->{$field}; } diff --git a/IkiWiki/Wrapper.pm b/IkiWiki/Wrapper.pm index f175b4a0b..fd6b9c00f 100644 --- a/IkiWiki/Wrapper.pm +++ b/IkiWiki/Wrapper.pm @@ -28,7 +28,7 @@ sub gen_wrapper () { my @envsave; push @envsave, qw{REMOTE_ADDR QUERY_STRING REQUEST_METHOD REQUEST_URI CONTENT_TYPE CONTENT_LENGTH GATEWAY_INTERFACE - HTTP_COOKIE REMOTE_USER HTTPS REDIRECT_STATUS + HTTP_COOKIE REMOTE_USER HTTPS SSL_CLIENT_S_DN_CN REDIRECT_STATUS REDIRECT_URL} if $config{cgi}; my $envsave=""; foreach my $var (@envsave) { @@ -152,7 +152,6 @@ EOF #translators: The parameter is a C filename. error(sprintf(gettext("failed to compile %s"), "$wrapper.c")); } - unlink("$wrapper.c"); if (defined $config{wrappergroup}) { my $gid=(getgrnam($config{wrappergroup}))[2]; if (! defined $gid) { diff --git a/README.SIPB b/README.SIPB new file mode 100644 index 000000000..c88f19387 --- /dev/null +++ b/README.SIPB @@ -0,0 +1,56 @@ +README for SIPB maintainers + +Basic instructions on scripts of interest. Also, +How this repository is set up, and how to keep IkiWiki up to date. + + +Setup: + +There are three branches of interest: remotes/origin/master, master +and sipb. remotes/origin/master is the remote branch we are tracking; +all upstream changes show up in this branch when we `git fetch`. + +master is our "awaiting upstream approval" branch, based off of +remotes/origin/master. Any patches in this branch should be immediately +suitable for submission to IkiWiki maintainers/. Ideally, this branch +should be equivalent to remotes/origin/master. + +sipb is our live branch. It contains all of the ugly hacks and custom +modifications that we needed to make our website run. Ideally, this +branch is equivalent to master. Don't expect it to be without a lot +of rearchitecting and upstream cooperation. + + +Keeping up to date: + +XXX: This is what we'd do in our original clone of upstream. + How do we do this now that we have our own internal repo to clone? + +This two-tiered setup means that you will need to rebase twice in order +to propagate changes; possibly once if master == origin/master. Your +commands will look like this: + +$ git checkout master +$ git pull --rebase +$ git checkout sipb +$ git rebase master + +TODO: Make a script that does this. + + +Scripts: + +The source repository has a hook that automatically deploys changes when +you push to it. If bad things happen, however, there are two scripts of +interest: + +~/bin/reinstall-ikiwiki + This script runs make and make install, reinstalling the source files to + make it live. + +~/bin/update-ikiwiki + This script recompiles the website from its source directory + ikiwiki/src into the live wiki directory web_scripts/wiki. + +Normally, these don't need to be run. + diff --git a/TODO.SIPB b/TODO.SIPB new file mode 100644 index 000000000..1208f1569 --- /dev/null +++ b/TODO.SIPB @@ -0,0 +1,12 @@ +Todo list + +* Presently, we only allow certificate'ed logins to edit the wiki. Eventually, + we will want to allow for some passworded users. When this happens, several + considerations must be taken: + + * Unless user accounts are made on a case-by-case basis manually by + SIPB members (which should definitely be considered), there must be + anti-spam measures in the registration process. + + * Certain files had hacks added to them. They are marked by MITLOGIN + diff --git a/doc/favicon.ico b/doc/favicon.ico index b55eba280..5adc83a64 100644 Binary files a/doc/favicon.ico and b/doc/favicon.ico differ diff --git a/po/Makefile b/po/Makefile index dfb018c81..c1c37443b 100644 --- a/po/Makefile +++ b/po/Makefile @@ -5,29 +5,16 @@ POTFILES=$(sort $(shell find ../IkiWiki -type f -name \*.pm)) \ POFILES=$(wildcard *.po) MOFILES=$(POFILES:.po=.mo) -# Translated underlays can only be generated if po4a is available. -TRANSLATED_UNDERLAYS=$(shell if perl -e 'use Locale::Po4a::Common' 2>/dev/null; then echo ../underlays/locale; fi) - -all: ikiwiki.pot mo $(TRANSLATED_UNDERLAYS) +all: ikiwiki.pot mo mo: $(MOFILES) install: all - # Normal mo files for program translation. for file in $(MOFILES); do \ lang=`echo $$file | sed 's/\.mo//'`; \ install -d $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/; \ install -m 0644 $$file $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/ikiwiki.mo; \ done - - # Underlay translation via po files that go in special per-language - # underlays. - for file in `cd underlays && find . -type f -name \*.po`; do \ - lang=`echo $$file | sed -e 's/.po$$//' -e 's/.*\\.//'`; \ - dir=`dirname "$(DESTDIR)$(PREFIX)/share/ikiwiki/po/$$lang/$$file"`; \ - install -d $$dir; \ - install -m 0644 underlays/$$file $$dir; \ - done ikiwiki.pot: $(POTFILES) @if perl -e '($$ver)=`xgettext -V | head -n 1`=~/.*\s+([0-9]+\.[0-9]+)/; die "gettext $$ver too old, not updating the pot file\n" if $$ver < 0.16'; then \ @@ -36,9 +23,7 @@ ikiwiki.pot: $(POTFILES) fi clean: - rm -f $(MOFILES) messages messages.mo *_stamp - rm -rf html underlays/.ikiwiki $(TRANSLATED_UNDERLAYS) - find underlays -name \*.mdwn -or -name \*.pot | xargs rm -f + rm -f $(MOFILES) messages messages.mo %.mo: %.po msgfmt -o $@ $< @@ -61,34 +46,3 @@ check: printf "$$lang: "; \ msgfmt -o /dev/null -c -v --statistics $$lang.po;\ done - -underlays_copy_stamp: - # copy all the files we want to translate into a srcdir - for file in `cd ..; find underlays -follow -name \*.mdwn`; do \ - install -d $$(dirname $$file); \ - cp -aL ../$$file $$file 2>/dev/null || \ - install -m 644 ../$$file $$file; \ - done - install -d underlays/directives/ikiwiki/directive - for file in `cd ..; find doc/ikiwiki/directive/ -maxdepth 1 -type f`; do \ - cp -a ../$$file underlays/directives/ikiwiki/directive || \ - install -m 644 ../$$file underlays/directives/ikiwiki/directive; \ - done - install -d underlays/empty - touch $@ - -underlays: ../ikiwiki.out underlays_copy_stamp - ../ikiwiki.out -libdir .. -setup underlay.setup -refresh - -../ikiwiki.out: ../Makefile - make -C .. ikiwiki.out - -../Makefile: ../Makefile.PL - cd .. && ./Makefile.PL - -$(TRANSLATED_UNDERLAYS): po2wiki_stamp -po2wiki_stamp: po2wiki underlays_copy_stamp - PERL5LIB=.. ./po2wiki underlay.setup - touch $@ - -.PHONY: underlays diff --git a/templates/editpage.tmpl b/templates/editpage.tmpl index b1cf015a2..a7f6d084f 100644 --- a/templates/editpage.tmpl +++ b/templates/editpage.tmpl @@ -36,6 +36,15 @@ Optional comment about this change:
+
+

By submitting content to this wiki, you agree to release your work under + the dual license of

+ +
diff --git a/templates/misc.tmpl b/templates/misc.tmpl index 9ec9a59cb..5d58de4ca 100644 --- a/templates/misc.tmpl +++ b/templates/misc.tmpl @@ -1,40 +1,89 @@ - - - - - - - - - -<TMPL_VAR TITLE> - - - - - - - + - - -
- -
- - - - + + + + + + + + + + + + + + <TMPL_VAR TITLE> + + + + + +
+ + + + +

+ +
+
+ + diff --git a/templates/page.tmpl b/templates/page.tmpl index 968066a19..e0a080b78 100644 --- a/templates/page.tmpl +++ b/templates/page.tmpl @@ -1,171 +1,112 @@ - - - - -<TMPL_VAR TITLE> - - - - - - - - - - - - - - - - - + - - - - - - -
- -
- - -
- - - - -
Comments on this page are closed.
-
-
-
- - - - + + + + + + + + + + + + + + + <TMPL_VAR TITLE> + + + + + +
+ + + + +

+ + + + +
+
+ + + +