Compare commits

...

253 Commits
2.2.6 ... 2.3.2

Author SHA1 Message Date
Alex Schroeder
4b0d411564 Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse
Conflicts:
	wiki.pl
2014-11-01 01:03:16 +01:00
Alex Schroeder
6790de2d6a Yet another attempt at fixing encoding issues.
To facilitate future debugging, STDERR now also gets the UTF-8 layer.

Apparently CGI does not decode UTF-8 encoded URL parameters. Handle this
case in GetParam.

PageHtml can be called when STDOUT already has the UTF-8 layer. It needs
to be able to handle both cases. That's why we call binmode without any
layers and then we call binmode with the UTF-8 layer again. Now it will
work for RSS files as well.

Unrelated fix: In order to force a decent Etag header even if no index
file exists (and thus $LastUpdate is undef), we use $Now as an
alternative.
2014-11-01 00:52:55 +01:00
Alex Schroeder
2784628544 PageHtml no longer uses utf8 layer
binmode adding utf8 layer to STDOUT resulted in double encoded pages
included via PageHtml. On my homepage I was appending the comments to
every page using the following code:

    my $target = $CommentsPrefix . $id;
    my $page = '';
    $page = PageHtml($target) if $IndexHash{$target};
    print $q->div({-class=>'comment'},
                  $q->h2(T('Comments')),
                  $page);
2014-10-31 23:50:28 +01:00
Alex Schroeder
dd8c687b2b Caching: Fixed tests.
There is no problem generating an Etag header even if a Last Modified
header is provided.
2014-10-31 23:49:41 +01:00
Alex Jakimenko
9f4ceb2d72 module-updater.pl: No need to return when calling OrError subs 2014-10-31 18:48:48 +02:00
Alex Jakimenko
0f8a4fa1df module-updater.pl: Fixed cache problems 2014-10-31 18:48:06 +02:00
Alex Jakimenko
3b16b58880 module-bisect.pl: Solved cache problems, added 'Back' button from 'Stop' page, all strings are now translatable, some refactoring. 2014-10-31 18:41:08 +02:00
Alex Jakimenko
192a902932 Typos and language 2014-10-31 15:41:00 +02:00
Alex Schroeder
aedf77cff8 wiki.pl: Fix caching.
Previously, if calling GetHeader with 'nocache', this would get passed
on to GetHttpHeader as $ts. The code would then produce an etag header
with a value of 'nocache'. This is now fixed. A long comment now
explains how it is supposed to work to reduce confusion in the future.
2014-10-31 09:27:27 +01:00
Alex Schroeder
728547f309 Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-10-31 09:10:08 +01:00
Alex Schroeder
33f5484441 oddmuse-curl.el: oddmuse-search, oddmuse-match
Both may use a prefix argument to search a different wiki.
2014-10-31 09:09:52 +01:00
Alex Schroeder
a225486709 vc-oddmuse.el: vc-oddmuse-diff, vc-oddmuse-checkin
These simply did not work.
2014-10-31 09:08:16 +01:00
Alex Jakimenko
3f7f9ec1eb module-bisect.pl: Indicate progress by using > signs 2014-10-31 04:45:45 +02:00
Alex Jakimenko
174aac5570 module-bisect.pl: Do binary search on your modules by disabling/enabling them 2014-10-31 04:09:33 +02:00
Alex Jakimenko
954232f7c8 module-updater.pl: Do not update modules immediately, just show diffs and ask the user whether he wants to apply those changes. 2014-10-29 23:40:09 +02:00
Alex Jakimenko
067658fd10 comment-div-wrapper.pl: Now using $q-> functions instead of printing html manually 2014-10-26 00:54:45 +03:00
Alex Jakimenko
b2b2b0f6cc comment-div-wrapper.pl: Use 'class' instead of 'id' (otherwise it creates multiple elements with the same id in journals) 2014-10-26 00:29:35 +03:00
Alex Jakimenko
408d169729 comment-div-wrapper.pl: indentation 2014-10-26 00:28:32 +03:00
Alex Schroeder
0eddbd5806 oddmuse-2013.css: white-space and word-wrap 2014-10-24 15:50:42 +02:00
Alex Schroeder
210a28afd4 oddmuse-2013.css: small changes 2014-10-24 15:50:31 +02:00
Alex Schroeder
94a16bd463 Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-10-24 09:47:29 +02:00
Alex Schroeder
4005e246f7 oddmuse-curl.el: Emacs 24.4 compatibility
shell-command-on-region apparently no longer returns an error number.

Also, use quotes for oddmuse-get-command.
2014-10-24 09:46:51 +02:00
Alex Jakimenko
6b3cd0437f module-updater.pl: GetRaw() instead of wget, cgi functions instead of printing tags 2014-10-22 03:00:32 +03:00
Alex Jakimenko
c961748b49 image.pl: Commentable images (create divs with text above images) 2014-10-21 17:26:31 +03:00
Alex Jakimenko
7327eb8e0c div-foo.pl: Support for spans, paragraph problem solved 2014-10-21 16:27:14 +03:00
Alex Schroeder
1b0d595945 Oddmuse mode for Emacs: Fix diff support
C-x v = calls diff and it didn't work at all; now it works again but
something about the revisions still isn't right.
2014-10-16 23:29:37 +02:00
Alex Schroeder
b7e2a04bb4 search.t: test fix for encoding error
On my website, I noticed that searching for matching pages with a
string containing a non-ascii character worked, where as doing a
normal search resulted in an encoding error. The difference was this:

  # fix match parameter
  my $match = GetParam('match', '');
  SetParam('match', FreeToNormal($match)) if $match;

This may be necessary to remove underscores, but it should not be
necessary to fix encoding errors.
2014-10-10 18:15:54 +02:00
Alex Schroeder
848eb65ad0 use CGI qw/-utf8/
This option should allow automatic encoding and decoding of
parameters. This saves a few lines and solves an encoding error:
previously, searching for a text containing non-ASCII characters would
result in double-encoded text fields.
2014-10-10 17:15:28 +02:00
Alex Schroeder
7ae98f4ed9 $q->endform to $q->end_form
When updating to CGI 4.06, it turns out that $q->endform
is no longer defined.
2014-10-10 16:43:01 +02:00
Alex Jakimenko
dc792691d4 Fail less dramatically if h1 appears. 2014-10-02 16:29:45 +03:00
Alex Jakimenko
0a57a8e89b toc.pl: Treat h2 as the first header when Creole Extension is active. 2014-10-02 16:23:00 +03:00
Alex Jakimenko
f75d415322 Div Foo Extension 2014-09-29 03:46:02 +03:00
Gauthier Vandemoortele
1654562236 clustermap.pl: fixed regression (subrotine name was changed)
This module used a function called ‘DoRc’ that disappeared from the main oddmuse script since the 1.837 version. It was apparently replaced by ‘PrintRcHtml’.
2014-09-26 23:12:23 +03:00
Alex Schroeder
ba0535f39d Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-09-24 16:51:30 +02:00
Alex Schroeder
e5b069f70b upgrade.t: ensure modules directory exists
When calling clean_pages on OSX, the mac.pl module is installed via
add_module, which in turn calls mkdir. On other systems, however,
installing the old namespace module will not work since the module
directory will not exist. This change ensures that mkdir is called
before symlinking.
2014-09-24 16:49:29 +02:00
Alex Schroeder
d34b9f669b upgrade.t: ensure modules directory exists
When creating a symlink on HFS+, the directory doesn't need to exist,
apparently. On ext4, it needs to exist. Make the test more robust by
calling mkdir.
2014-09-24 16:42:46 +02:00
Alex Schroeder
ae2061fcaf referrer-tracking.t: skip if questionasker is installed 2014-09-24 16:27:21 +02:00
Alex Schroeder
65475cf2e8 git.t: make test more robust
Different git versions use different strings to report issues and the
tests don't use --porcelain. Made them a little more robust.
2014-09-24 16:17:25 +02:00
Alex Schroeder
ce2e63be6b Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-09-23 22:19:51 +02:00
Alex Schroeder
007ce8db86 cookie.t: no longer hardcode the wiki name
Changed the tests to no longer assume the default value for
$CookieName. This is important when running the tests on a system
where Apache starts a number of wikis for various virtual hosts and
one of them will end up as the host to use for http://localhost/. That
wiki might very well have a cookie name set.
2014-09-23 22:17:47 +02:00
IngoBelka
5997c3ea02 creole.pl: title-tag for images
This enables tooltips for images in FireFox and possibly in other browsers too
2014-09-13 14:55:38 +03:00
Alex Schroeder
6895428844 UserCanEditOrDie text preferred
It turns out that one of the tests in lock.t relied on the exact wording
of the error message. I decided to use the same wording for all
instances: "Editing not allowed: %s is read-only" and no longer using
"Editing not allowed for %s".
2014-09-12 15:30:20 +02:00
Alex Schroeder
2bc2d1f927 New convenience function UserCanEditOrDie
Closes bug #41625 "ban-quick-editors.pl can hide the error message".
DoPost now uses the same code as DoEdit and thus it will display the
error message, which solves the issue for ban-quick-editors.pl. Added a
test to demonstrate it.
2014-09-12 15:20:06 +02:00
Alex Schroeder
873ce10ced permanent-anchors.pl: report page deletion status
Make sure the status is returned if page deletion fails.
2014-09-12 11:50:51 +02:00
Alex Schroeder
3855c83a7e maintain.t: Verify that maintenance deletes pages 2014-09-12 11:45:24 +02:00
Alex Schroeder
281736a082 Merge: use [[foo bar]] and [[foo_bar]]
I find that removing " space" and "_underscore" made it easier for me to
visually compare the XPath expressions. I also wanted to keep the
[[foo bar|text]] test (and keep the XPath expression as similar as possible).
2014-09-11 22:08:50 +02:00
Alex Schroeder
63d8e24c2f creole.t: test for new free link rule
Make sure that [[foo bar]] turns to [[foo_bar?]] if foo_bar does not
exist, and [[foo bar|text]] turns to [[foo_bar?|text]].
2014-09-11 21:57:27 +02:00
Alex Jakimenko
c66f1a6f8e We have chosen a wrong way to compare $text with $id. It should be better now.
This also fixes recent test added to creole.t
2014-09-11 16:47:18 +03:00
Alex Jakimenko
6418cab98c creole.t: creole extension has its own link rules, so we have to test spaces in [[links]] 2014-09-11 16:43:52 +03:00
Alex Jakimenko
040d51bc93 default-links.t: test both underscores and spaces in [[links]] 2014-09-11 16:41:22 +03:00
Alex Schroeder
41c3245a51 default-links.t: test for new free link rule
Make sure that [[foo_bar]] turns to [[foo_bar?]] if foo_bar does not
exist.
2014-09-10 23:13:45 +02:00
Alex Schroeder
ffc2a0b12f Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-09-10 22:59:36 +02:00
Alex Schroeder
90c632f4ab Avoid Save button for comments after rollback
If you clicked on the Save button after rolling pack a comment page, the
content of the comment page would be deleted.
2014-09-10 22:56:54 +02:00
Alex Jakimenko
9e8def306a Fixed free links to nonexisting pages (now [[foo bar]] results in [[foo_bar?]] instead of [[foo_bar?|foo bar]]) 2014-09-03 15:25:13 +03:00
Alex Jakimenko
f4e551111a Executable flag is only useful when shebang is specified 2014-09-03 14:23:20 +03:00
Alex Jakimenko
1ead545561 Fix gravatar tests (https links from f7b99d4 commit) 2014-09-03 14:06:38 +03:00
Alex Schroeder
f5fc46821f emoji.pl: use \s+:3 2014-08-27 08:22:04 +02:00
Alex Schroeder
ce9f8d9b74 emoji.pl: require whitespace before :3 2014-08-27 08:19:03 +02:00
Alex Jakimenko
1104ecf72f emoji.pl: :3 smiley fixed
Previously it was matching dates like 12:31
2014-08-27 06:32:55 +03:00
Alex Schroeder
13fc4cc0a4 emoji.pl: fixed rule order 2014-08-26 22:39:39 +02:00
Alex Schroeder
31f7b330c5 emoji.pl: added more 2014-08-26 22:34:30 +02:00
Alex Schroeder
ad3909888b emoji.pl: added more 2014-08-26 22:24:08 +02:00
Alex Schroeder
f7b99d44fd gravatar.pl: use https 2014-08-25 20:29:25 +02:00
Alex Schroeder
2cf943d178 Makefile: more fixing for prepare target
The prepare target didn't handle wiki.pl itself correctly. This has been
fixed. The command to add the git tag was changed from sed to perl, like
for the other targets. As emoji.pl and smiles.pl refer to permanent
anchors, the addition of the anchor parameter to AddModuleDescription
was obviously misguided and I reverted it.
2014-08-24 22:20:50 +02:00
Alex Schroeder
b2b1c16247 markup.pl: link English documentation 2014-08-24 21:31:00 +02:00
Alex Schroeder
f91041b677 Handle AddModuleDescription for translations
The Makefile didn't add tag information for translation files when
running 'make prepare'. This has been fixed. As we cannot have a slash
in the file name, as slashes get escaped in UrlEncode, a new parameter
was added to AddModuleDescription and the Makefile will now set this
parameter for translation files such that the source link will point to
the correct directory ("translations/").
2014-08-24 21:25:38 +02:00
Alex Schroeder
30b0faa70e ban-contributors.t: fixed test
The test no longer refers to hostname but to IP number.
2014-08-24 13:05:03 +02:00
Alex Schroeder
174c4f6642 oddtrans: add fake AddModuleDescription
Add a fake AddModuleDescription such that the new translation files with
the new module description call don't fail on "do".

Also use :encoding(utf8) on opening the file as suggested by Ingo Belka
on the wiki instead of calling utf8::decode on every line.
2014-08-24 12:37:48 +02:00
Alex Schroeder
9ba5b119f8 Fix module description to handle version tag.
This makes sure that "make prepare" works once again by allowing an
optional argument to AddModuleDescription with the tag.
AddModuleDescription now also takes an optional anchor which is used by
emoji.pl and smiles.pl.

This commit also updates all the translation files and makes sure that
they all use AddModuleDescription.
2014-08-24 12:31:15 +02:00
Alex Schroeder
b8ce7f07df diff3 output decoded as UTF-8
Without this decoding, calling diff3 leads to UTF-8 corruption.
2014-08-24 09:01:58 +02:00
Alex Schroeder
c9a9db28a6 german-utf8.pl: updated 2014-08-24 08:46:48 +02:00
Alex Schroeder
b21dc2db01 Get rid of "Updates in the last 1 day"
If it's one day, write "Updates in the last day" instead.
2014-08-24 08:46:03 +02:00
Alex Schroeder
0f61a795ee Modules no longer refer to hostname banning
Hostnames are no longer tracked and therefore log messages such as
"hostname or IP number matched" no longer make sense.
2014-08-24 08:45:14 +02:00
Ingo Belka
ed30eeffb0 oddtrans: Keep translation headers 2014-08-24 08:44:31 +02:00
Alex Jakimenko
9473e08a14 smarttitles.pl allow intermap links in suburl
maybe this feature should have been called "sublink"...
2014-08-24 06:33:50 +03:00
Alex Jakimenko
16796b7fe5 smarttitles.pl: added #SUBURL
SUBURL is another optional feature that allows you to specify some arbitrary link to be displayed in the subtitle.
This might be handy to wikis where some pages are associated with particular URLs
2014-08-23 09:04:12 +03:00
Alex Jakimenko
1e704ece07 smarttitles.pl: do not match in the middle of the string 2014-08-23 06:27:15 +03:00
Alex Jakimenko
1f824d5838 diff.pl: fix corrupted html 2014-08-23 05:28:16 +03:00
Alex Jakimenko
d8bc7bd82f Module Updater Extension 2014-08-23 05:13:27 +03:00
Alex Jakimenko
a2e1a73d10 smarttitles.pl: fixed XSS, fixed wrong behaviour when #TITLE was not specified but #SUBTITLE was, fixed wrong behaviour when title or subtitle was specified in the end of the page, some refactoring 2014-08-22 22:01:50 +03:00
Alex Schroeder
68e71cc535 upgrade.t: fixed old namespaces problem
The problem was that the new namespaces.pl wants to call
AddModuleDescription which doesn't exist in oddmuse-2.2.6.pl -- but
that's the Oddmuse version that is used for the upgrade test.
2014-08-22 16:43:09 +02:00
Alex Schroeder
548bdf7d1c upgrade.pl: add module description 2014-08-22 16:17:18 +02:00
Alex Schroeder
a6314a2c44 Merge branch 'ad/module-description' 2014-08-22 09:09:03 +02:00
Alex Schroeder
85e8800435 offline.pl and webapp.pl: link wiki page 2014-08-22 08:49:40 +02:00
Alex Schroeder
41b5c65e22 national-days: moved to translations folder 2014-08-22 08:33:08 +02:00
Alex Schroeder
3ad0438a78 Revert changes made to translation files.
This reverts part of commit 5aba2ae56f.

Conflicts:
	modules/locked.pl
2014-08-22 00:10:04 +02:00
Alex Schroeder
3ab80d0e3f Merge branch 'ad/module-description' of git.sv.gnu.org:/srv/git/oddmuse into ad/module-description 2014-08-21 23:39:20 +02:00
Alex Schroeder
2312787ec1 simple-rules test moved to Test::More
Moved modules/simple-rules-test.pl to t/simple-rules.t and started using
the standard testing infrastructure.
2014-08-21 23:38:52 +02:00
Alex Schroeder
b8b2035151 simple-rules test moved to Test::More
Moved modules/simple-rules-test.pl to t/simple-rules.t and started using
the standard testing infrastructure.
2014-08-21 23:37:31 +02:00
Alex Schroeder
4aefc9a648 emoji.pl and smiles.pl: Fixed module description
These two modules used to link to a named anchor instead of a simple
page. This was dropped.
2014-08-21 22:32:37 +02:00
Alex Schroeder
c1cb7516a8 locked.pl is effectively a duplicate
listlocked.pl provides the same functionality and is actually installed
on emacswiki.org, so that's the one we'll keep.
2014-08-21 22:24:21 +02:00
Alex Schroeder
5aba2ae56f Fixed typo in AddModuleDescription sub name 2014-08-21 22:23:23 +02:00
Alex Schroeder
f958de8165 AddModuleDescription uses FreeToNormal
This makes sure that links to pages with spaces in their names have
spaces translated to underscores.
2014-08-21 22:22:10 +02:00
Alex Schroeder
f79b188e82 finnish-utf8.pl and swedish-utf8.pl: fix mode
The files specified fundamental-mode for Emacs users. I removed that
line because the defaults seem to work just fine.
2014-08-21 22:01:44 +02:00
Alex Schroeder
dc182fde16 brazilian-portuguese-utf8.pl: Added header back.
This header had somehow gotten lost.
2014-08-21 22:01:11 +02:00
Alex Jakimenko
5fbc444a53 Removed scripts for processing module descriptions 2014-08-21 16:48:49 +03:00
Alex Jakimenko
a7f83b2ba7 Added file descriptions without wiki links 2014-08-21 16:41:32 +03:00
Alex Jakimenko
5bfe0073d9 Fixed some module descriptions 2014-08-21 16:20:43 +03:00
Alex Schroeder
3b3e707d3b Fix Recent Changes pagination
The commit "RcHtml: fix generating More... links" introduced a bug. The
first page after clicking a More... link was the default page again. The
computation of the new FROM parameter wasn't working when neither UPTO
nor DAYS was set (as is the case when you look at the default Recent
Changes). A simple defaulting to $RcDefault did the trick.
2014-08-21 07:53:55 +02:00
Alex Jakimenko
ee932dee37 Automatically reformatted modules 2014-08-21 07:29:46 +03:00
Alex Jakimenko
772bf2745a Scripts to automatically clean module descriptions.
These files do not belong here, but they are commited intentionally (Just in case we need them again)
2014-08-21 07:17:26 +03:00
Alex Jakimenko
8cbd7dabec AddModuleDescription: allow modules without wiki pages 2014-08-21 05:44:00 +03:00
Alex Jakimenko
860d2f0bce AddModuleDescripton() 2014-08-21 04:35:53 +03:00
Alex Jakimenko
ef4aac31b4 Get rid of CRLF line endings 2014-08-21 02:46:47 +03:00
Alex Jakimenko
be1789f996 diff.pl: Fix removal of newline warning 2014-08-21 02:42:14 +03:00
Alex Schroeder
b7c1045783 Help users unlock a wiki.
When a lock is blocking the user, offer them a way to unlock the wiki.

Also, update the German translations.
2014-08-21 01:08:25 +02:00
Alex Schroeder
54913a0131 Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-08-20 17:09:46 +02:00
Alex-Daniel Jakimenko
a6036d2455 Fix removal of newline warning 2014-08-20 17:08:12 +02:00
Alex-Daniel Jakimenko
12d362106e Use -- to delimit args from filenames.
This applies to the calls of diff and diff3. -- is required to
indicate the end of command line arguments, so that filenames that
start with dashes will not cause any trouble. Of course, since no one
will ever set his $TempDir to something like that, it is not critical.
2014-08-20 17:07:58 +02:00
Alex Schroeder
b292ab5983 Fix modules using PrintAllPages. 2014-08-20 17:07:54 +02:00
Alex-Daniel Jakimenko
090c708ce9 diff.pl: Diff Action Extension. 2014-08-20 17:07:36 +02:00
Alex-Daniel Jakimenko
67dc63c433 Fix removal of newline warning 2014-08-20 17:02:50 +02:00
Alex Schroeder
2606b846f0 Use -- to delimit args from filenames.
This applies to the calls of diff and diff3. -- is required to
indicate the end of command line arguments, so that filenames that
start with dashes will not cause any trouble. Of course, since no one
will ever set his $TempDir to something like that, it is not critical.
2014-08-20 08:31:32 +02:00
Alex Schroeder
ff66da7c65 Fix modules using PrintAllPages. 2014-08-20 08:28:36 +02:00
Alex Schroeder
76a6b4bfad diff.pl: Diff Action Extension. 2014-08-20 08:22:18 +02:00
Alex Schroeder
ddadb21517 Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-08-20 08:21:37 +02:00
Alex Schroeder
e62423ec84 Fix edit link for the homepage.
The universal edit button link in the HTML header did not work when
looking at the home page if the home page did not appear in the URL.
2014-08-15 09:38:32 +02:00
Alex Jakimenko
083fdb3371 Refactor: Some code extracted from GetHeader
The code was moved into the new subroutine GetHeaderTitle.
2014-08-13 15:55:23 +02:00
Alex-Daniel Jakimenko
6cfe1ab29a Links With AccessKeys Extension
Oddmuse provides several shortcuts, like ‘e’ to edit page or ‘c’ to open
comments page and several others. In most browsers it means that
pressing Alt+Shift+e should automatically click (or at least focus) edit
link. However, by default there is no way to provide accesskey for links
on your wiki pages. This module is trying to solve this.
2014-08-13 12:17:24 +02:00
Alex-Daniel Jakimenko
4e43357daa Another Git Extension
Unlike Git Extension, this extension initializes git repository right
inside your Page Directory. This approach simplifies the code because
there is no need to copy files from one location to another.
2014-08-13 12:13:21 +02:00
Alex-Daniel Jakimenko
7a82dd40ff New Window Links Extension
This is a simple extension that provides syntax for creating links that
open in new windows or tabs.
2014-08-13 12:11:54 +02:00
Alex-Daniel Jakimenko
584f23b08a Comment Div Wrapper Extensions
This module will place all comments into <div> tags.
2014-08-13 12:10:08 +02:00
Alex-Daniel Jakimenko
b21f33951f Advanced Uploading
This module adds file upload buttons to comment and edit forms.
2014-08-13 12:06:55 +02:00
Alex Schroeder
acacd5ff01 GetFooterLinks avoids useless link. 2014-08-06 12:25:54 +02:00
Alex Schroeder
a333fbf3b1 creole.pl: Fixed list item issues.
creole.t now runs again.
2014-08-06 11:01:15 +02:00
Alex Jakimenko
eb7de3c722 Allow mixed mode lists.
OpenHtmlEnvironment now accepts fourth parameter that defines similar
tags.

creole.pl now passes 'ol|ul' as fourth parameter to OpenHtmlEnvironment.

In addition to that, the creole.pl code was refactored a little bit to
remove copy-pasted part.
2014-08-05 22:59:17 +02:00
Alex Schroeder
ac7ca05707 oddmuse-curl: make nicer RC buffer
Use shadow face for author.
2014-08-03 01:02:50 +02:00
Alex Schroeder
32ce6cde2d Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-08-03 01:02:22 +02:00
Alex Schroeder
d922b7413c RcHtml: fix generating More... links
When using days for RecentChanges, the More... links after the first
one reverted to $RcDefault instead of keeping the same time period.
This is now fixed.
2014-08-03 01:01:42 +02:00
Alex Schroeder
54b0fbcfaf RcHtml: fix generating More... links
When using days for RecentChanges, the More... links after the first
one reverted to $RcDefault instead of keeping the same time period.
This is now fixed.
2014-08-03 00:59:41 +02:00
Alex Schroeder
d919dd5d94 rc.t: Add test for More... links 2014-08-03 00:50:42 +02:00
Alex Schroeder
48ec41b566 git: added git.t, rewrote git.pl
Tests were added. As I wrote the tests, I realized that GitRun was
printing to STDOUT even though we had created a local *STDOUT and opened
it to write to a memory file (like PageHtml does). Apparently this is
not inherited to the child process. I now use the solution provided for
in the perldoc for open. Unfortunately it requires a temp file. Trying
to use a memory file results in an error. Temporary files are a mess if
I want to access the output: I need to close it and reopen it for
reading. That's why GitRun only does that if $GitDebug is set. This is
what most of the tests will use: set $GitDebug and examine $GitResult.
At the same time I realized that the error message was never being
triggered. The previous code was tricky because it only considered
showing an error message in a non-void context, ie. when called from
maintenance. I wasn't sure this was an actual benefit and decided to
remove it altogether. I we really want to, we can set $GitDebug and
examine $GitResult in GitCleanup.
2014-07-31 13:18:32 +02:00
Alex Schroeder
0d592e12f2 test.pl: extract config file writing
Move the writing of the config file (and the resetting of the important
variables) into a separate file so that tests can reset the config file
without clearing all the pages.
2014-07-31 13:17:02 +02:00
Alex Schroeder
ee8b8db17f oddmuse-curl.el: pwd parameter handling
Two commands used 'password' instead of 'pwd' as parameter for the
password. In addition to that, oddmuse-run will now report errors, if it
thinks there are any.
2014-07-30 14:12:19 +02:00
Alex Jakimenko
252033bff8 git.pl: Some significant changes.
Added: $GitPageFile variable. Set it to true if you want to keep
complete page files in git and not just text.

Fixed: previously git extension was chdir-ing into $GitRepo directory
without ever going back, this could have lead to problems if some other
code needed access to file system.

Fixed: now this extension will work smoothly if $DataDir is set to a
relative path.

Fixed: this extension was probably broken for wiki pages starting with
two dashes (e.g. --SomePage), this is now fixed by using -- to indicate
the end of command-line options.

Changed: GitCleanup is now using GitRun instead of backticks (like
everywhere else). It will also print the exit status of 'git commit'
command.

Changed: some tiny style improvements.
2014-07-30 14:06:07 +02:00
Alex Schroeder
e21333faca Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-07-28 11:36:38 +02:00
Alex Schroeder
ff3d7a9ea2 Search & Replace: use → instead of -> 2014-07-28 11:35:36 +02:00
Alex Schroeder
dd34aff9ef oddmuse-curl.el: Fixed message for new pages.
oddmuse-get-latest-revision doesn't return anything when the page is
new. In this case the previous message was confusing. Now it just says
that the page must be new.
2014-07-28 10:37:21 +02:00
Alex Schroeder
9eee99514b add-link.pl: more improvements 2014-07-27 22:36:38 +02:00
Alex Schroeder
5ead2bdcf2 add-link.pl: added support for /top and /match 2014-07-27 15:48:36 +02:00
Alex Schroeder
8b5267a013 oddmuse-curl.el: Markup for interlinks. 2014-07-26 23:18:22 +02:00
Alex Schroeder
423dad59b1 oddmuse-curl.el: fixing prefix arg handling for previews. 2014-07-26 23:08:47 +02:00
Alex Schroeder
f79aa04c68 oddmuse-curl.el: Support matching page names 2014-07-26 22:46:50 +02:00
Alex Schroeder
7535c859b9 oddmuse-curl.el: Fix Preview. 2014-07-26 16:43:04 +02:00
Alex Schroeder
ac34706853 oddmuse-curl.el, vc-oddmuse.el: Refactor. 2014-07-26 11:38:55 +02:00
Alex Schroeder
b705fcb3f1 oddmuse-curl.el: Reorganize code. 2014-07-25 15:20:59 +02:00
Alex Schroeder
ae13fe5235 oddmuse-curl.el: refactor
Use with-oddmuse-wiki-and-pagename.
2014-07-25 11:12:57 +02:00
Alex Schroeder
5830fbcd71 oddmuse-curl.el, vc-oddmuse.el: Revert support.
Also, a lot of refactoring and preparing to refactor some more.
2014-07-24 23:37:53 +02:00
Alex Schroeder
a2123aeb76 copy.pl: Moved to the campaignwiki subdir 2014-07-23 16:28:08 +02:00
Alex Schroeder
f07bdddb5d oddmuse-curl.el: oddmuse-reload
Added oddmuse-reload as an alias for
oddmuse-compute-pagename-completion-table.
2014-07-23 16:27:59 +02:00
Alex Schroeder
5da39c28a8 copy.pl: major rewrite 2014-07-23 16:24:53 +02:00
Alex Schroeder
28f08d9583 oddmuse-curl.el: Change key-bindings.
Use C-c C-e for editing and C-c C-f for following, freeing C-c C-o.
2014-07-23 09:52:12 +02:00
Alex Jakimenko
0ba55b13d6 Code style and refactoring. 2014-07-21 20:48:47 +02:00
Alex Schroeder
270e1aad9e oddmuse-curl.el: Add wiki searching.
Use C-c C-s to search the wiki. Introduces oddmuse-search-command,
oddmuse-search, etc.

Also: Get rid of %?. Improve documentation for percent format strings.
2014-07-21 09:56:00 +02:00
Alex Schroeder
ec1b7d1a46 Code style.
Simplify A ? A : B to A || B.
2014-07-18 14:11:08 +02:00
Alex Schroeder
718e17f07f recaptcha.t: skip if dependency is not installed
The CPAN module Captcha::reCAPTCHA is required for this test to run.
2014-07-18 14:07:11 +02:00
Alex Jakimenko
48ff67a27c Code style and refactoring 2014-07-18 13:15:29 +02:00
Alex Schroeder
39eabb6cbb Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-07-16 12:45:13 +02:00
Alex Schroeder
28d7d0a897 oddmuse-curl.el: handle ampersand in pagenames 2014-07-16 12:43:21 +02:00
Alex Schroeder
3f295e7a88 RSS 3.0 doesn't need HTML quoted. 2014-07-16 10:44:13 +02:00
Alex Schroeder
d6ef6bb56c alex-2012.css: fix CSS for numbered links 2014-07-12 20:20:00 +02:00
Alex Schroeder
f276ae6469 Don't store host names.
Get rid of the option $UseLookup. Remove GetRemoteHost and rename
GetRemoteAddress to GetRemoteHost. Thus, it now returns IP number only.
2014-07-11 19:09:33 +02:00
Alex Schroeder
f6d4d5f517 gotobar.pl: Use PageMarkedForDeletion 2014-07-11 10:23:46 +02:00
Alex Schroeder
0ee7a23018 all.pl: Add variation parameter to PrintAllPages call. 2014-07-10 17:02:35 +02:00
Alex Schroeder
61dec7317b journal3.t: Add variation=journal to the tests. 2014-07-10 16:56:49 +02:00
Alex Schroeder
7a1b4c38b1 bbcode.t: Fix smiley and frowning face character 2014-07-10 16:53:52 +02:00
Alex Jakimenko
0e97e7bee5 Refactoring 2014-07-10 15:04:47 +02:00
Alex Schroeder
769bc55821 oddmuse-curl.el: Improved pagename handling.
1. Use completion-ignore-case when reading a pagename.
2. Replace _ with spaces when inserting a pagename into the buffer.
3. URL-encode pagename when concatenating with the wiki URL.
2014-07-09 10:42:27 +02:00
Alex Schroeder
bd9cdf56bf oddmuse-curl.el: Only highlight bullet with space.
This avoids conflict with bold words at the beginning of a line.
2014-07-09 10:41:24 +02:00
Alex Schroeder
be97b89b87 journal.t: whitespace 2014-07-09 10:40:34 +02:00
Alex Jakimenko
a9f5fe4374 journal.t: Tests for the new journal syntax 2014-07-05 12:39:47 +02:00
Alex Schroeder
a88878dc08 bbcode.pl: Different Unicode smilies.
The smilies now match emoji.p: use 😊 instead of ☺ and 😟 instead of😊☹.
2014-07-04 16:38:32 +02:00
Alex Schroeder
dcaabca09f emoji.pl: Added module description. 2014-07-04 10:33:33 +02:00
Alex Schroeder
d680d0173b emoji.pl: fix one entity 2014-07-03 15:11:12 +02:00
Alex Schroeder
3e8cb56f37 smiles.pl: Using the data URI schema.
The smilies are from the Emacs 24 distribution.
2014-07-03 15:02:35 +02:00
Alex Schroeder
33ec1b1743 emoji.pl: More.
Also, use 😊 instead of ☺ and 😟 instead of😊☹.
2014-07-03 14:37:16 +02:00
Alex Schroeder
6f4b5451fc emoji.pl: Using Unicode characters.
Instead of using %Smilies (as seen in smiles.pl), this translates
sequences like :) to Unicode characters such as ☺.
2014-07-03 13:44:32 +02:00
Alex Jakimenko
2770defdc4 Additional features for journal syntax.
If you set 0 as the number of entries for More... pages, the More...
button will be disabled completely (e.g. <journal 3,0> to show only 3
entries without giving a link to other pages).

You can specify initial offset by using journal:OFFSET (e.g. <journal:3
5 "News_\d+"> will skip first three news pages).

The :OFFSET syntax might be confusing, but it is quite easy to remember:
in bash ${arr:3:5} will get five elements of array arr starting with the
third index (fourth element, thus the offset is 3). Therefore, to make
it even more confusing, it is now possible to write previous example as
<journal:3:5 "News_\d+">.

Now you can use <titles> to get links without displaying the contents.
It accepts exactly the same arguments as <journal>. For example
<titles:3 5 "News_\d+">.
2014-07-03 12:58:48 +02:00
Alex Jakimenko
1d6f435ca8 askpage.pl: Fixed variable name.
Fixed variable name (this module was not working previously), comments
and minor fixes.
2014-07-03 09:17:49 +02:00
Alex Schroeder
00856c0436 oddmuse-curl.pl: Editable *Preview* buffer.
Switch to fundamental mode (undoing view-mode) before loading a new
preview.
2014-07-03 09:10:22 +02:00
Alex Schroeder
e0ee3bb24d oddmuse-curl.el: Fix line-breaking.
Allow line-breaking when we're right at the start of a link.
2014-07-02 09:46:50 +02:00
Alex Schroeder
8bbbed026d add-link.pl: Handle & in names.
Handle HTML quoting correctly when it comes to site names such that
sites containing an ampersand show up as & and not as &amp;.

Inline the star.png in order to be stand-alone.
2014-07-01 16:07:19 +02:00
Alex Schroeder
c9767ce84b alex-2012.css: Button icon shadow. 2014-07-01 13:36:50 +02:00
Alex Schroeder
b984f3ecad alex-2012.css: Button size. 2014-07-01 13:16:54 +02:00
Alex Schroeder
f58f784009 oddmuse-curl.el: Fix parameters for oddmuse-follow 2014-07-01 10:09:54 +02:00
Alex Schroeder
b6ee8da7c6 Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-07-01 10:08:51 +02:00
Alex Schroeder
ae59ab3746 GetParam: only call utf8::decode on defined values
In some recent versions of Perl such as v5.18.0, when $foo is undef,
utf8::decode($foo) modifies $foo to '' (defined null string). This
causes problems. When the Preview button is clicked, for example, a
nomal page is shown instead of the preview, because of this. Thus, we
need to avoid calling utf8::decode on undefined value.
2014-07-01 09:33:17 +02:00
Alex Schroeder
28ab5885a0 contrib: README with an explanation of the files 2014-06-30 14:43:48 +02:00
Alex Schroeder
881dbc7094 copy.pl: add use utf-8. 2014-06-30 14:40:51 +02:00
Alex Schroeder
2537a97900 description: added for gitweb. 2014-06-30 14:29:45 +02:00
Alex Schroeder
20de100781 contrib: Add +x to all .pl files 2014-06-30 14:25:10 +02:00
Alex Schroeder
e1c3445136 add-link.pl: Undid commit to the wrong location. 2014-06-30 14:24:23 +02:00
Alex Schroeder
e8be707079 add-link.pl: Script used to maintain a bookmark wiki. 2014-06-30 14:22:35 +02:00
Alex Schroeder
680c3b96ce oddmuse-curl.el: Remove extra closing parenthesis. 2014-06-30 10:00:41 +02:00
Alex Schroeder
ba4ce729e6 alex-2012.css: Add a download link class 2014-06-30 09:37:14 +02:00
Alex Schroeder
d74da11382 raw.pl: Use new page directory structure.
And added a test for raw.pl.
2014-06-27 11:30:33 +02:00
Alex Schroeder
9d0e6cb3cb upgrade.pl: Fix handling of dot files 2014-06-26 18:52:21 +02:00
Alex Schroeder
027557999d Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-06-26 18:47:15 +02:00
Alex Schroeder
41fb4d0c4b Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-06-26 18:44:45 +02:00
Alex Schroeder
7cf0904b2b oddmuse-curl.el: Infer wiki and pagename
Replace oddmuse-read-wiki-and-pagename by oddmuse-pagename such that
the user will not be asked for a wiki and a pagename if it can be
inferred from the context.
2014-06-26 18:35:20 +02:00
Alex Schroeder
7330f1961b oddmuse-curl.el: C-u shows preview in browser 2014-06-26 18:33:55 +02:00
Alex Schroeder
6e9d50204f oddmuse-curl.el: C-c C-b to browse this page 2014-06-26 18:31:06 +02:00
Alex Schroeder
629157d367 oddmuse-curl.el: more fiddling with markup order 2014-06-25 12:17:32 +02:00
Alex Schroeder
23af89d21e oddmuse-2013.css: smaller font-size for code 2014-06-25 12:16:36 +02:00
Alex Schroeder
a3cf3dbb99 oddmuse-2013.css: black line before comment 2014-06-24 16:18:57 +02:00
Alex Schroeder
a28f380125 journal-rss.pl: monthly parameter
As suggested by Ingo Belka on the wiki: The parameter monthly=1 will
set the match parameter to the current year and the current month.
2014-06-24 16:13:59 +02:00
Alex Schroeder
eb8fd17e01 oddmuse-curl.el: Reorganized, mostly for font-lock
Changed all the oddmuse-*-markup functions to variables. Reorganized
oddmuse-mode.
2014-06-24 11:46:18 +02:00
Alex Schroeder
4784e3bc88 oddmuse-curl.el: oddmuse-revert confirmation
oddmuse-revert will now ask for confirmation before reverting the
current buffer.
2014-06-24 11:44:23 +02:00
Alex Schroeder
cff287ee24 oddmuse-curl.el: Remove Oddmuse Wiki from oddmuse-wikis
There don't seem to be a big overlap between Emacs users and Oddmuse
Wiki editors.
2014-06-24 11:42:32 +02:00
Alex Schroeder
07eeffa3e3 oddmuse-curl.el: add nobreak property
oddmuse-nobreak-p now takes into account the nobreak property. This
property is added to font-lock-extra-managed-props and used by *bold*,
_underline_ and /italic/.
2014-06-23 13:50:07 +02:00
Alex Schroeder
fe7a5e564a admin.pl: Get rid of CreatePageDir. 2014-06-23 12:54:39 +02:00
Alex Schroeder
00aa0761d7 referrer-tracking.t: Clean up after the last test. 2014-06-23 12:24:51 +02:00
Alex Schroeder
f09a81b3b9 referrer-tracking: Get rid of CreatePageDir.
Fix the unit tests, too.
2014-06-23 12:19:07 +02:00
Alex Schroeder
c43b0695c2 oddmuse-curl.t: fix handing of ' in summary
Shell quoting issues, the bane of every programmer.
2014-06-23 11:32:08 +02:00
Alex Schroeder
e9e436c0b8 Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2014-06-23 09:53:17 +02:00
Alex Schroeder
c0194c1178 pageidx file now no longer contains all those ones
Previously, the pageidx file contained the serialized hash. If we had
two pages A and B, it contained A 1 B 1. When you install this version,
your wiki will report extra pages of "1" until you delete your pageidx
file, or until you create a new page (which will delete your pageidx
file).
2014-06-22 23:28:56 +02:00
Alex Schroeder
c6a0cb33ac Raw RSS adds "minor: 1" for minor changes
If you looked at an URL like the following, you wouldn't know which
items referred to minor changes and which didn't. They all looked the
same.
http://localhost/cgi-bin/wiki.pl?action=rc;showedit=1;raw=1

This change adds "minor: 1" to items caused by minor changes, and
oddmuse-curl.el (the Oddmuse Mode for Emacs), handles this.
2014-06-22 23:14:55 +02:00
Alex Schroeder
e9375974cb rollback.t: Get rid of stat
Using stat to get the last edit timestamp can lead to a failing test.
To be absolutely certain, use the timestamp stored in the page file.
As it stands, $Now is used for the timestamp in the page file but if
this is a new file (revision 1), then the index file gets rewritten
and its timestamp changes.
2014-06-22 23:11:35 +02:00
Alex Schroeder
a226902617 oddmuse-curl.el: RecentChanges with Summary
Recent Changes will now show the summary.
2014-06-22 22:20:25 +02:00
Aki Goto
213774d6ff joiner.pl: Support Questionasker and reCaptcha.
These are used in the Register and Login forms.

And, the deprecated CreatePageDir is replaced by CreateDir (fixes a bug
introduced by Oddmuse version 2.3.0).
2014-06-22 12:10:53 +02:00
Aki Goto
98d96fd1d8 gd_security_image.pl: New CAPTCHA module.
This one uses GD::SecurityImage.
2014-06-22 12:06:14 +02:00
Alex Schroeder
ddb8fb06e6 gotobar.pl: Add support for external links 2014-06-22 00:21:46 +02:00
Alex Schroeder
25989f78a5 Merge branch 'as/no-more-page-subdirectories' 2014-06-21 21:30:27 +02:00
Aki Goto
afdb7a9dcb form_timeout.pl: an anti-spam module for Oddmuse
This is an anti-spam module for Oddmuse using form timeout. Edit
permission times out after a specified duration (the default is 30
minutes). When edit content is posted directly by a spam bot without
viewing the edit form, edit will be denied.
2014-06-21 12:18:26 +02:00
Alex Schroeder
2e79a843c8 oddmuse-curl.el: Fix URL 2014-06-21 12:01:08 +02:00
Alex Schroeder
54370da235 oddmuse-curl.el: whitespace 2014-06-21 12:00:26 +02:00
Alex Schroeder
43839ac1aa upgrade.t: Testing for the changes to upgrade.pl 2014-06-21 10:45:21 +02:00
Alex Schroeder
3c2f96250b upgrade.pl: Use variables; print utf8.
Instead of fiddling with @MyInitVariables, set the options naming
pages to the empty string.
2014-06-21 04:44:33 -04:00
Alex Schroeder
9def2d2eb2 upgrade.pl: Disable some module initialisations
Some modules read a page file when initializing. As these cannot be
found before the upgrade, we need to disable them.
2014-06-21 04:18:16 -04:00
Alex Schroeder
3ad40b84fb .gitignore: .DS_Store 2014-06-20 22:39:37 +02:00
Alex Schroeder
ecda4c3d98 oddmuse-curl.el: Preview shows just the preview
Don't show the header, footer and textarea; show just the preview div.
2014-06-20 22:36:09 +02:00
Alex Schroeder
74a0576c5d oddmuse-curl.el: Font lock restructuring
All the font-locking functions are now modifying font-lock-defaults
instead of calling font-lock-add-keywords because that's what it says
in the elisp manual.
2014-06-20 21:23:30 +02:00
Alex Schroeder
a6e07a9886 oddmuse-curl.el: Preview command
The preview command uses shr, a built in HTML renderer.
2014-06-20 18:31:33 +02:00
Alex Schroeder
b76b61dc86 .gitignore: .DS_Store 2014-06-19 23:11:04 +02:00
Alex Schroeder
c3cb434973 upgrade.pl: handle name spaces 2014-06-19 23:00:18 +02:00
Alex Schroeder
62f82c2af2 upgrade.pl: New interface.
Don't rely on a separate upgrade action. Any request except for login
and unlock will trigger an upgrade, if you're an admin. Once the upgrade
is complete, the module will rename itself such that it will no longer
load.
2014-06-17 13:14:13 +02:00
Alex Schroeder
d454973294 oddmuse-curl.el: fix order of font-locking
oddmuse-basic-markup must come last (which prepends its rules to the
front) such that links get precedence over other markup.
2014-06-17 12:26:50 +02:00
Alex Schroeder
cba29c8981 oddmuse-curl.el: added oddmuse-new
A function to make it easy to blog by offering the current ISO date as
page name.
2014-06-17 10:39:05 +02:00
Alex Schroeder
4a812931c8 oddmuse-curl.el: do not break links
Added a fill-nobreak-predicate to prevent links from breaking. This uses
the face property and checks for the link face.
2014-06-17 10:37:57 +02:00
Alex-Daniel Jakimenko
093a6da63d askpage.pl: Don't keep old value of $NewComment
Resetting the value was dead code. Instead of fixing this, the old value
is now discarded. There is no point in keeping it around.
2014-06-16 15:40:13 +02:00
Aki Goto
0ab5261bc6 load-lang.pl: add $LoadLanguageDir
The new option $LoadLanguageDir specifies a directory for the language
files.
2014-06-16 15:33:53 +02:00
Alex Schroeder
1d4f3e4a28 Ask Page extension
This is a simple extension to create a page for asking questions. The
process of writing a question is similar to writing a comment, for the
only exception that after pressing the ‘Save’ button the user will be
redirected to the newly created page containing his question.
2014-06-16 11:25:13 +02:00
Alex Jakimenko
6babcffd00 Consistency in file permissions.
Some modules are executable where as others are not. This patch fixes
this.
2014-06-16 11:19:24 +02:00
Alex Jakimenko
977cbba251 Fix two issues with $NewComment.
Display $NewComment above comment textarea.

'c' is now an access key to focus comment textarea.
2014-06-16 11:06:20 +02:00
Alex Schroeder
2fc4f4b054 Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse into as/no-more-page-subdirectories 2014-06-16 10:32:31 +02:00
Alex Schroeder
53566c8434 Use a function instead of $ENV{REMOTE_ADDR}
When the webserver is behind a reverse proxy, $ENV{REMOTE_ADDR} is not
the actual remote client's address but the reverse proxy's address. The
actual remote client's address is available from an environment
variable. The name of this variable depends on the proxy, e.g. pound
uses $ENV{HTTP_X_FORWARDED_FOR}.

As suggested by tyatsumi on the wiki, all access $ENV{REMOTE_ADDR} now
happens via a new function which allows users to override it in their
config file.
2014-06-16 09:50:05 +02:00
Alex Schroeder
563e5cd9c6 upgrade.pl: delete empty directories after upgrade 2014-06-07 17:08:18 +02:00
Alex Schroeder
365d33b602 Get rid of one letter sub-directories.
Recent GNU/Linux systems use ext3 or ext4 file systems. These use HTree
to index files. Wikipedia says: "HTree indexing improved the scalability
of Linux ext2 based filesystems from a practical limit of a few thousand
files, into the range of tens of millions of files per directory. [...]
HTree indexes are available in ext3 when the dir_index feature is
enabled. [...] HTree indexes are turned on by default in ext4."

Thus, instead of working on balanced-page-directories.pl, we decided to
get rid of these sub-directories altogether.

Unfortunately, this is backwards incompatible. Users wanting to upgrade
will need to install the upgrade.pl extension in order to upgrade the
file database.
2014-06-06 17:32:44 +02:00
Alex Schroeder
eef56e435d questionasker.t: fixed number of tests 2014-06-05 17:07:15 +02:00
Alex Schroeder
2044564981 Merge branch 'master' of ssh://git.sv.gnu.org/srv/git/oddmuse 2014-06-05 05:34:08 -04:00
Alex Schroeder
26a5db86b0 Fix module description. 2014-05-27 14:48:02 +02:00
Alex Schroeder
7f74d3c211 Use smaller headers 2014-04-09 08:34:14 -04:00
Alex Schroeder
ab3a7752ba New highlighting to look like Emacs buffers. 2014-03-21 19:18:15 +01:00
320 changed files with 16381 additions and 2778 deletions

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@
/Mac/pkg/
*.dmg
*.pkg
.DS_Store

View File

@@ -17,24 +17,22 @@ build:
mkdir -p build
build/wiki.pl: wiki.pl
sed "s/\\\$$q->a({-href=>'http:\/\/www.oddmuse.org\/'}, 'Oddmuse')/\\\$$q->a({-href=>'http:\/\/git.savannah.gnu.org\/cgit\/oddmuse.git\/tag\/?id=$(VERSION_NO)'}, 'wiki.pl') . ' ($(VERSION_NO)), see ' . &/" < $< > $@
perl -lne "s/(\\\$$q->a\({-href=>'http:\/\/www.oddmuse.org\/'}, 'Oddmuse'\))/\\\$$q->a({-href=>'http:\/\/git.savannah.gnu.org\/cgit\/oddmuse.git\/tag\/?id=$(VERSION_NO)'}, 'wiki.pl') . ' ($(VERSION_NO)), see ' . \$$1/; print" < $< > $@
build/%-utf8.pl: modules/translations/%-utf8.pl
sed "s/<a href=\"http:\/\/git.savannah.gnu.org\/cgit\/oddmuse.git\/tree\/modules\/translations\/\\(.*\\).pl\">\\(.*\\).pl<\/a>/<a href=\"http:\/\/git.savannah.gnu.org\/cgit\/oddmuse.git\/tree\/modules\/translations\/\\1.pl?id=$(VERSION_NO)\">\\1.pl<\/a> (for $(VERSION_NO))/" < $< > $@
# Currently oddtrans introduces encoding errors!
# %-utf8.pl: wiki.pl $(MODULES)
# perl oddtrans -l $@ $^ > $@-new && mv $@-new $@
perl -lne "s/(AddModuleDescription\('[^']+', '[^']+')\)/\$$1, 'translations\/', '$(VERSION_NO)')/; print" < $< > $@
# from: http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/namespaces.pl
# to: http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/namespaces.pl?id=2.1-11-gd4f1e27
build/%.pl: modules/%.pl
sed "s/<a href=\"http:\/\/git.savannah.gnu.org\/cgit\/oddmuse.git\/tree\/modules\/\\(.*\\).pl\">\\(.*\\).pl<\/a>/<a href=\"http:\/\/git.savannah.gnu.org\/cgit\/oddmuse.git\/tree\/modules\/\\1.pl?id=$(VERSION_NO)\">\\1.pl<\/a> (for $(VERSION_NO))/" < $< > $@
perl -lne "s/(AddModuleDescription\('[^']+', '[^']+')\)/\$$1, undef, '$(VERSION_NO)')/; print" < $< > $@
translations: $(TRANSLATIONS)
for f in $^; do \
echo updating $$f...; \
perl oddtrans -l $$f wiki.pl $(MODULES) > $$f-new && mv $$f-new $$f; \
done
# UNTESTED/OBSOLETE: these targets have not been tested in a long time
# and are potentially obsolete.

View File

@@ -0,0 +1,37 @@
The files in this directory are used to run http://campaignwiki.org/
add-link.pl
===========
This is used to add links to the Links To Wisdom wiki. This wiki is a
bookmark site: A few pages make up a big unordered list of links in
wiki format. add-link is a tool to help users contribute new links to
the list.
http://campaignwiki.org/wiki/LinksToWisdom/HomePage
copy.pl
=======
This is used to copy the text from a web page to a wiki page. The idea
was to keep archive copies of cool pages somewhere. The Blog Archive
never got used, though.
http://campaignwiki.org/wiki/BlogArchive/HomePage
monster-tag.pl
==============
This is used to quickly tag many pages in the Monsters wiki. The
Monsters wiki hasn't been used in a long time, though.
http://campaignwiki.org/wiki/Monsters/HomePage
submit.pl
=========
This used to be used to add sites to the Old School RPG Planet. The
aggregator was configured via a wiki page on the Planet wiki. It's now
abandoned.
http://campaignwiki.org/wiki/Planet/HomePage

262
contrib/campaignwiki/add-link.pl Normal file → Executable file
View File

@@ -1,6 +1,6 @@
#! /usr/bin/perl
# Copyright (C) 2011 Alex Schroeder <alex@gnu.org>
# Copyright (C) 20112014 Alex Schroeder <alex@gnu.org>
# 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
@@ -15,8 +15,10 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
package OddMuse;
use LWP::UserAgent;
use HTML::TreeBuilder;
use JSON::PP;
use utf8;
# load Oddmuse core
@@ -24,11 +26,14 @@ $RunCGI = 0;
do "wiki.pl";
# globals
my $self = "http://campaignwiki.org/add-link";
my $name = "OSR Links to Wisdom";
my $wiki = 'LinksToWisdom';
my $site = "http://campaignwiki.org/wiki/$wiki";
# my $site = "http://localhost/wiki.pl";
my $home = "$site/$HomePage";
# http://www.emacswiki.org/pics/star.png
my $stardata = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAFVBMVEUAAHkAAACzdRTapx3twwD/9qb////1YCa0AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfXAQYCJAu+WhwbAAAAKnRFWHRDb21tZW50AGJ5IFJhZG9taXIgJ1RoZSBTaGVlcCcgRG9waWVybGFza2kVfTXbAAAAYElEQVQI12NgQAKMMIaYAFTAzRDKCHOEMETCnEFyjIJhYS6OggwMoqGhaS7GRgIMjC6uYc5GikA5YRcXIyWwotBgJUWw7lAXsAyDaIihMlhK1FFA0AjEEAESQgJQu4EYAPAPC2XcokgQAAAAAElFTkSuQmCC';
main();
@@ -47,9 +52,62 @@ sub toc {
$labels{$value} = $label;
}
}
return \@values, \%labels;
}
sub top {
# start with the homepage
my %blog;
my $n;
for my $id (GetPageContent($HomePage) =~ /\* \[\[(.*?)\]\]/g) {
for my $item (GetPageContent(FreeToNormal($id)) =~ /^\*+\s+\[(https?:\/\/[^\/\n\t ]+)/mg) {
$n++;
# handle blogspot domain munging
$item =~ s/blogspot(\.[a-z]+)+/blogspot.com/;
$blog{$item}++;
}
}
print $q->p("Total links counted: $n.");
my @list = sort { $blog{$b} <=> $blog{$a} } keys %blog;
# my $max = scalar @list;
# $max = 20 if $max > 20;
# @list = @list[0 .. $max -1];
@list = map {
my $domain = substr($_, index($_, '://') + 3);
my $term = quotemeta($domain);
# handle blogspot domain munging
$term =~ s/blogspot\\\.com/blogspot(\\.[a-z]+)+/;
$term = QuoteHtml($term);
$q->a({-href => $_}, $domain)
. " (" . $q->a({-href => "$self/match/$term"}, $blog{$_}) . ")";
} @list;
return \@list;
}
sub match {
my $term = shift;
# start with the homepage
my @list;
my $title;
for my $id (GetPageContent($HomePage) =~ /\* \[\[(.*?)\]\]/g) {
for my $line (split /\n/, GetPageContent(FreeToNormal($id))) {
if ($line =~ /^\*+\s+([^][\n]*)$/) {
$title = $1;
} elsif ($line =~ /$term/o) {
if ($line =~ /^\*+\s+\[(https?:\S+)\s+([^]]+)\]/) {
push (@list, $q->a({-href => $1}, $2) . " (" . $title . ")");
}
}
}
}
return \@list;
}
sub html_toc {
my ($values, $labels) = toc();
return $q->radio_group(-name =>'toc',
-values => \@values,
-labels => \%labels,
-values => $values,
-labels => $labels,
-linebreak=>'true');
}
@@ -57,102 +115,108 @@ sub default {
print $q->p("Add a link to the " . $q->a({-href=>$home}, $name) . ".");
print $q->start_multipart_form(-method=>'get', -class=>'submit');
print $q->p($q->label({-for=>'url'}, T('URL:')) . ' '
. $q->textfield(-name=>'url', -id=>'url', -size=>50));
print toc();
print $q->submit('go', 'Add!');
print $q->end_form();
print $q->p("Drag this bookmarklet to your bookmarks bar for easy access:",
. $q->textfield(-name=>'url', -id=>'url', -size=>80));
print $q->p({-style=>'font-size: 10pt'},
"(Drag this bookmarklet to your bookmarks bar for easy access:",
$q->a({-href=>q{javascript:location='}
. $q->url()
. qq{?url='+encodeURIComponent(window.location.href)}},
"Submit $name") . ".");
"Submit $name") . ".)");
print html_toc();
print $q->submit('go', 'Add!');
print $q->end_form();
}
sub check_url {
my $toc = GetParam('toc');
return default() unless $toc;
my $url = shift;
if (not GetParam('confirm', 0)) {
my $name = get_name($url);
print $q->p("Please confirm that you want to add "
. GetUrl($url, $name)
. " to the section “$toc”.");
print $q->start_form(-method=>'get');
print $q->p($q->label({-for=>'name', -style=>'display: inline-block; width:30ex'},
T('Use a different link name:')) . ' '
. $q->textfield(-style=>'display: inline-block; width:60ex',
-name=>'name', -id=>'name', -size=>50, -default=>$name)
. $q->br()
. $q->label({-for=>'username', -style=>'display: inline-block; width:30ex'},
T('Your name for the log file:')) . ' '
. $q->textfield(-style=>'display: inline-block; width:60ex',
-name=>'username', -id=>'username', -size=>50));
my $star = $q->img({-src=>'http://www.emacswiki.org/pics/star.png', -class=>'smiley',
-alt=>'star'});
print '<p>Optionally: Do you want to rate it?<br />';
my $i = 0;
foreach my $label ($q->span({-style=>'display: inline-block; width:15ex'}, $star)
. 'I might use this for my next campaign',
$q->span({-style=>'display: inline-block; width:15ex'}, $star x 2)
. 'I have used this in a campaign and it worked as intended',
$q->span({-style=>'display: inline-block; width:15ex'}, $star x 3)
. 'I have used it in many of my campaigns',
$q->span({-style=>'display: inline-block; width:15ex'}, $star x 4)
. 'Everybody should give it a try',
$q->span({-style=>'display: inline-block; width:15ex'}, $star x 5)
. 'Everybody should use it, that is how awesome it is!') {
$i++;
print qq{<label><input type="radio" name="stars" value="$i" $checked/>$label</label><br />};
}
print '</p>';
print $q->hidden('url', $url);
print $q->hidden('toc', $toc);
print $q->hidden('confirm', 1);
print $q->submit('go', 'Continue');
print $q->end_form();
} else {
post_addition($q->param('name'), $url, $toc);
sub confirm {
my ($url, $name, $toc) = @_;
print $q->p("Please confirm that you want to add "
. GetUrl($url, $name)
. " to the section “$toc”.");
print $q->start_form(-method=>'get');
print $q->p($q->label({-for=>'name', -style=>'display: inline-block; width: 15em'},
T('Use a different link name:')) . ' '
. $q->textfield(-style=>'display: inline-block; width:50ex',
-name=>'name', -id=>'name', -size=>50, -default=>$name)
. $q->br()
. $q->label({-for=>'summary', -style=>'display: inline-block; width:15em'},
T('An optional short summary:')) . ' '
. $q->textfield(-style=>'display: inline-block; width:50ex',
-name=>'summary', -id=>'summary', -size=>50)
. $q->br()
. $q->label({-for=>'username', -style=>'display: inline-block; width:15em'},
T('Your name for the log file:')) . ' '
. $q->textfield(-style=>'display: inline-block; width:50ex',
-name=>'username', -id=>'username', -size=>50));
my $star = $q->img({-src=>$stardata, -class=>'smiley', -alt=>'☆'});
print '<p>Optionally: Do you want to rate it?<br />';
my $i = 0;
foreach my $label ($q->span({-style=>'display: inline-block; width:3em'}, $star)
. 'I might use this for my campaign',
$q->span({-style=>'display: inline-block; width:3em'}, $star x 2)
. 'I have used this in a campaign and it worked as intended',
$q->span({-style=>'display: inline-block; width:3em'}, $star x 3)
. 'I have used this in a campaign and it was ' . $q->em('great')) {
$i++;
print qq{<label><input type="radio" name="stars" value="$i" $checked/>$label</label><br />};
}
print '</p>';
print $q->hidden('url', $url);
print $q->hidden('toc', $toc);
print $q->hidden('confirm', 1);
print $q->submit('go', 'Continue');
print $q->end_form();
}
# returns unquoted html
sub get_name {
my $url = shift;
my $tree = HTML::TreeBuilder->new_from_content(GetRaw($url));
my $h = $tree->look_down('_tag', 'h1');
$h = $tree->look_down('_tag', 'title') unless $h;
my $h = $tree->look_down('_tag', 'title');
$h = $tree->look_down('_tag', 'h1') unless $h;
$h = $h->as_text if $h;
return $h;
}
sub post_addition {
my ($name, $url, $toc) = @_;
my ($url, $name, $toc, $summary) = @_;
my $id = FreeToNormal($name);
my $display = $name;
utf8::decode($display); # we're dealing with user input
utf8::decode($summary); # we're dealing with user input
print $q->p("Adding ", GetUrl($url, $display), " to “$toc”.");
# start with the homepage
my @pages = GetPageContent($HomePage) =~ /\* \[\[(.*?)\]\]/g;
for my $id (@pages) {
return post($id, undef, $name, $url, GetParam('stars', '')) if $id eq $toc;
return post($id, undef, $name, $summary, $url, GetParam('stars', '')) if $id eq $toc;
my $data = GetPageContent(FreeToNormal($id));
while ($data =~ /(\*+ ([^][\n]*))$/mg) {
return post($id, $1, $name, $url, GetParam('stars', '')) if $2 eq $toc;
return post($id, $1, $name, $summary, $url, GetParam('stars', '')) if $2 eq $toc;
}
}
print $q->p("Whoops. I was unable to find “$toc” in the wiki. Sorry!");
}
sub post {
my ($id, $toc, $name, $url, $stars) = @_;
my ($id, $toc, $name, $summary, $url, $stars) = @_;
my $data = GetPageContent(FreeToNormal($id));
my $re = quotemeta($url);
if ($data =~ /$re\s+(.*?)\]/) {
my $display = $1;
print $q->p($q->strong("Oops, we seem to have a problem!"));
print $q->p(GetPageLink(NormalToFree($id)),
" already links to the URL you submitted:",
GetUrl($url, $display));
return;
}
$stars = ' ' . (':star:' x $stars) if $stars;
$summary = ': ' . $summary if $summary;
if ($toc) {
$toc =~ /^(\*+)/;
my $depth = "*$1"; # one more!
my $regexp = quotemeta($toc);
$data =~ s/$regexp/$toc\n$depth \[$url $name\]$stars/;
$data =~ s/$regexp/$toc\n$depth \[$url $name\]$summary$stars/;
} else {
$data = "* [$url $name]$stars\n" . $data;
$data = "* [$url $name]$summary$stars\n" . $data;
}
my $ua = LWP::UserAgent->new;
my %params = (text => $data,
@@ -173,30 +237,68 @@ sub post {
}
}
sub main {
$ConfigFile = "$DataDir/config"; # read the global config file
$DataDir = "$DataDir/$wiki"; # but link to the local pages
Init(); # read config file (no modules!)
$ScriptName = $site; # undo setting in the config file
binmode(STDOUT,':utf8');
$q->charset('utf8');
if ($q->path_info eq '/source') {
seek DATA, 0, 0;
print "Content-type: text/plain; charset=UTF-8\r\n\r\n", <DATA>;
} else {
$UserGotoBar = $q->a({-href=>$q->url . '/source'}, 'Source');
print GetHeader('', 'Submit a new link');
print $q->start_div({-class=>'content index'});
if (not GetParam('url')) {
default();
} else {
check_url(GetParam('url'));
}
sub print_end_of_page {
print $q->p('Questions? Send mail to Alex Schroeder <'
. $q->a({-href=>'mailto:kensanata@gmail.com'},
'kensanata@gmail.com') . '>');
print $q->end_div();
PrintFooter();
}
sub main {
$ConfigFile = "$DataDir/config"; # read the global config file
$DataDir = "$DataDir/$wiki"; # but link to the local pages
Init(); # read config file (no modules!)
$ScriptName = $site; # undo setting in the config file
$FullUrl = $site; #
binmode(STDOUT,':utf8');
$q->charset('utf8');
if ($q->path_info eq '/source') {
seek DATA, 0, 0;
print "Content-type: text/plain; charset=UTF-8\r\n\r\n", <DATA>;
} elsif ($q->path_info eq '/structure') {
my ($values, $labels) = toc();
my @indented = map {
($labels->{$_} || $_) =~ /^(*)/;
[$_, length($1)]
} @$values;
print "Content-type: application/json; charset=UTF-8\r\n\r\n";
binmode(STDOUT,':raw'); # because of encode_json
print JSON::PP::encode_json(\@indented);
} elsif ($q->path_info eq '/toc') {
my ($values, $labels) = toc();
print "Content-type: application/json; charset=UTF-8\r\n\r\n";
binmode(STDOUT,':raw'); # because of encode_json
print JSON::PP::encode_json($values);
} elsif ($q->path_info eq '/top') {
print GetHeader('', 'Top Blogs');
print $q->start_div({-class=>'content top'});
print $q->ol($q->li(top()));
print_end_of_page();
} elsif ($q->path_info =~ '^/match/(.*)') {
my $term = $1;
print GetHeader('', "Entries Matching '$term'");
print $q->start_div({-class=>'content match'});
print $q->ol($q->li(match($term)));
print_end_of_page();
} else {
push(@UserGotoBarPages, 'Help');
$UserGotoBar = $q->a({-href=>$q->url . '/source'}, 'Source');
print GetHeader('', 'Submit a new link');
print $q->start_div({-class=>'content index'});
my $url = GetParam('url');
my $name = UnquoteHtml(GetParam('name', get_name($url)));
my $toc = GetParam('toc');
my $confirm = GetParam('confirm');
my $summary = GetParam('summary');
if (not $url or not $toc) {
default();
} elsif (not $confirm) {
confirm($url, $name, $toc);
} else {
post_addition($url, $name, $toc, $summary);
}
print_end_of_page();
}
}

View File

@@ -1,6 +1,6 @@
#! /usr/bin/perl
# Copyright (C) 2011 Alex Schroeder <alex@gnu.org>
# Copyright (C) 20112014 Alex Schroeder <alex@gnu.org>
# 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
@@ -17,63 +17,62 @@
package OddMuse;
use LWP::UserAgent;
use HTML::TreeBuilder;
use utf8;
# load Oddmuse core
$RunCGI = 0;
do "wiki.pl";
# globals
my $wiki = 'BlogArchive';
my $site = "http://campaignwiki.org/wiki/$wiki";
# my $site = "http://localhost/wiki.pl";
my $home = "$site/HomePage";
$default_namespace = 'NameOfYourWiki';
main();
sub default {
print $q->p("Copy a blog article to the "
. $q->a({-href=>$home}, $wiki) . ".");
print $q->start_multipart_form(-method=>'get', -class=>'submit');
print $q->p($q->label({-for=>'url'}, T('URL:')) . ' '
. $q->textfield(-name=>'url', -id=>'url', -size=>50));
my ($url, $ns) = @_;
print $q->start_multipart_form(-method=>'get', -class=>'copy');
print $q->p("This script helps you copy of a blog post to your Campaign Wiki.");
print $q->p($q->label({-for=>'url', -style=>'display: inline-block; width: 20ex'}, 'Blog post URL:'),
$q->textfield(-name=>'url', -id=>'url', -size=>50),
$q->br(),
$q->label({-for=>'ns', -style=>'display: inline-block; width: 20ex'}, 'Name of your wiki:'),
$q->textfield(-name=>'ns', -id=>'ns', -size=>50, -default=>$default_namespace));
if ($url and not $ns) {
print $q->p($q->em('Please provide the name of your wiki. It is mandatory. Use “NameOfYourWiki” if you just want to test something.'));
}
print $q->submit('go', 'Go!');
print $q->end_form();
print $q->p("Please make sure youre only submitting your own articles",
"or articles with an appropriate license.");
print $q->p("Drag this bookmarklet to your bookmarks bar for easy access:",
$q->a({-href=>q{javascript:location='http://campaignwiki.org/copy?url='+encodeURIComponent(window.location.href)}}, $wiki) . ".");
$q->a({-href=>q{javascript:location='http://campaignwiki.org/copy?url='+encodeURIComponent(window.location.href)}}, 'Copy Blog Post') . ".");
}
sub check_url {
my $url = shift;
print $q->p("Looking at ", $q->a({-href=>$url}, $url));
my ($name, $data) = get_data($url);
$name = GetParam('name', $name);
if (name_exists($name) and not GetParam('confirm', 0)) {
print $q->p("We already have a page with that name: ",
$q->a({-href=>$duplicate}, $duplicate));
print $q->start_multipart_form(-method=>'get', -class=>'submit');
print $q->p($q->label({-for=>'name'}, T('New name:')) . ' '
. $q->textfield(-name=>'name', -id=>'name', -size=>50,
-default=>$name));
print $q->hidden('url', $url);
print $q->hidden('confirm', 1);
print $q->submit('go', 'Continue');
print $q->end_form();
} elsif (not GetParam('confirm', 0)) {
print $q->p("Please confirm that you want to copy this article to the wiki.");
print $q->start_multipart_form(-method=>'get', -class=>'submit');
print $q->p($q->label({-for=>'name'}, T('Name:')) . ' '
. $q->textfield(-name=>'name', -id=>'name', -size=>50,
-default=>$name));
print $q->hidden('url', $url);
print $q->hidden('confirm', 1);
print $q->submit('go', 'Continue');
print $q->end_form();
} else {
post_addition($name, $data, $url);
}
sub confirm_overwrite {
my ($url, $ns, $name) = @_;
print $q->p("We already have a page with that name: ", GetPageLink($name));
print $q->start_multipart_form(-method=>'get', -class=>'submit');
print $q->p($q->label({-for=>'name'}, T('New name:')) . ' '
. $q->textfield(-name=>'name', -id=>'name', -size=>50, -default=>$name));
print $q->hidden('url', $url);
print $q->hidden('ns', $ns);
print $q->hidden('confirm', 1);
print $q->submit('go', 'Continue');
print $q->end_form();
}
sub confirm_save {
my ($url, $ns, $name) = @_;
my $ns = GetParam('ns', $default_namespace);
print $q->p("Please confirm that you want to copy",
$q->a({-href=>$url}, "this article"), "to", GetPageLink($HomePage, $ns) . ".");
print $q->start_multipart_form(-method=>'get', -class=>'submit');
print $q->p($q->label({-for=>'name'}, T('Name:')) . ' '
. $q->textfield(-name=>'name', -id=>'name', -size=>50, -default=>$name));
print $q->hidden('url', $url);
print $q->hidden('ns', $ns);
print $q->hidden('confirm', 1);
print $q->submit('go', 'Continue');
print $q->end_form();
}
sub get_data {
@@ -82,24 +81,32 @@ sub get_data {
my $h = $tree->look_down('_tag', 'h1');
$h = $tree->look_down('_tag', 'title') unless $h;
$h = $h->as_text if $h;
my $b = $tree->look_down('_tag', 'body');
if ($b = $tree->look_down('_tag', 'div',
'class', qr/post-body/)) {
# blogspot
my $b;
if ($b = $tree->look_down('_tag', 'div', 'class', qr/post-body/)) {
# Blogspot
$b = html($b);
} elsif ($b = $tree->look_down('_tag', 'div', 'class', qr/content/)) {
# Oddmuse
$b = html($b);
} else {
# no idea, just get the text
$b = $b->as_text if $b;
# default: get it all
$b = html($tree->look_down('_tag', 'body'));
}
# common illegal character for page names
$h =~ s/:/,/g;
return ($h, $b);
}
sub html {
my $tree = shift;
my ($tree, $p) = @_;
# $p indicates whether we need an empty line or not
my $str;
for my $element ($tree->content_list()) {
if (not ref $element) {
$str .= $element;
} elsif ($element->tag() eq 'p') {
$str .= ($p == 1 ? "\n\n" : "") . html($element);
$p = 1;
} elsif ($element->tag() eq 'br') {
$str .= "\n\n";
} elsif ($element->tag() eq 'span'
@@ -107,6 +114,20 @@ sub html {
$str .= "[b]" . html($element) . "[/b]";
} elsif ($element->tag() =~ m/^(b|i|h[1-6])$/) {
$str .= "[$1]" . html($element) . "[/$1]";
} elsif ($element->tag() eq 'a'
and $element->attr('href')) {
$str .= "[url=" . $element->attr('href') . "]" . html($element) . "[/url]";
} elsif ($element->tag() eq 'img'
and $element->attr('src')) {
$str .= "[img]" . $element->attr('src') . "[/img]";
} elsif ($element->tag() eq 'pre') {
$str .= "\n\n[code]\n" . $element->as_text() . "\n[/code]";
$p = 1;
} elsif ($element->tag() eq 'div'
and ($element->attr('style') =~ /float: *(left|right)/
or $element->attr('style') =~ /text-align: *(center)/)) {
$str .= "\n[$1]" . html($element) . "[/$1]";
$p = 1;
} else {
$str .= html($element);
}
@@ -123,25 +144,25 @@ sub name_exists {
}
sub post_addition {
my ($name, $data, $url) = @_;
my ($url, $ns, $name, $data) = @_;
my $id = FreeToNormal($name);
print $q->p("Adding ", $q->a({-href=>$url}, $name));
print $q->p("Copying ", $q->a({-href=>$url}, "the blog post") . "…");
my $text = "Based on [$url $name].\n----\n" . $data;
my $ua = LWP::UserAgent->new;
my %params = (text => $text,
title => $id,
summary => $name,
username => GetParam('username'),
ns => $ns,
pwd => GetParam('pwd'));
$params{$QuestionaskerSecretKey} = 1 if $QuestionaskerSecretKey;
my $response = $ua->post($site, \%params);
my $response = $ua->post($FullUrl, \%params);
if ($response->is_error) {
print $q->p("The submission failed!");
print $q->pre($response->status_line . "\n"
. $response->content);
print $q->p("Copying failed!");
print $q->p($q->strong($response->status_line));
print $response->content;
} else {
print $q->p("See for yourself: ",
$q->a({-href=>"$site/$id"}, $name));
print $q->p("Your copy: ", GetPageLink($name) . ".");
}
}
@@ -152,12 +173,22 @@ sub main {
print "Content-type: text/plain; charset=UTF-8\r\n\r\n", <DATA>;
} else {
$UserGotoBar .= $q->a({-href=>$q->url . '/source'}, 'Source');
print GetHeader('', 'Submit a new blog article');
print GetHeader('', 'Copy a blog article');
print $q->start_div({-class=>'content index'});
if (not GetParam('url')) {
default();
my $url = GetParam('url');
my $ns = GetParam('ns');
if (not $url or not $ns) {
default($url, $ns);
} else {
check_url(GetParam('url'));
my ($name, $data) = get_data($url);
$name = GetParam('name', $name);
if (name_exists($name) and not GetParam('confirm', 0)) {
confirm_overwrite($url, $ns, $name);
} elsif (not GetParam('confirm', 0)) {
confirm_save($url, $ns, $name);
} else {
post_addition($url, $ns, $name, $data);
}
}
print $q->p('Questions? Send mail to Alex Schröder <'
. $q->a({-href=>'mailto:kensanata@gmail.com'},

0
contrib/campaignwiki/monster-tag.pl Normal file → Executable file
View File

0
contrib/campaignwiki/submit.pl Normal file → Executable file
View File

File diff suppressed because it is too large Load Diff

View File

@@ -39,11 +39,15 @@
(file-name-directory file)))
(defun vc-oddmuse-state (file)
"No idea."
'up-to-date)
"Return the current version control state of FILE.
For a list of possible values, see `vc-state'."
;; Avoid downloading the current version from the wiki and comparing
;; the text: Too much traffic!
'edited)
(defun vc-oddmuse-working-revision (file)
"No idea")
"The current revision based on `oddmuse-revisions'."
(oddmuse-revision-get oddmuse-wiki oddmuse-page-name))
(defun vc-oddmuse-checkout-model (files)
"No locking."
@@ -60,52 +64,28 @@
nil)
(defvar vc-oddmuse-log-command
"curl --silent %w\"?action=rc;showedit=1;all=1;from=1;raw=1;match=%r\""
(concat "curl --silent %w"
" --form action=rc"
" --form showedit=1"
" --form all=1"
" --form from=1"
" --form raw=1"
" --form match='%r'")
"Command to use for publishing index pages.
It must print the page to stdout.
%? '?' character
%w URL of the wiki as provided by `oddmuse-wikis'
%r Regular expression, URL encoded, of the pages to limit ourselves to.
This uses the free variable `regexp'.")
See `oddmuse-format-command' for the formatting options.")
(defun vc-oddmuse-print-log (files buffer &optional shortlog
start-revision limit)
(defun vc-oddmuse-print-log (files buffer &optional shortlog start-revision limit)
"Load complete recent changes for the files."
(let* ((wiki (or oddmuse-wiki
(completing-read "Wiki: " oddmuse-wikis nil t)))
(wiki-data (assoc wiki oddmuse-wikis))
(url (nth 1 wiki-data))
(regexp (concat
"^(" ;; Perl regular expression!
(mapconcat 'file-name-nondirectory files "|")
")$"))
(command (oddmuse-format-command vc-oddmuse-log-command))
(coding (nth 2 wiki-data))
(coding-system-for-read coding)
(coding-system-for-write coding)
(max-mini-window-height 1))
(oddmuse-run "Getting recent changes" command buffer nil))
;; Parse current buffer as RSS 3.0 and display it correctly.
(save-excursion
(with-current-buffer buffer
(let (result)
(dolist (item (cdr (split-string (buffer-string) "\n\n")));; skip first item
(let ((data (mapcar (lambda (line)
(when (string-match "^\\(.*?\\): \\(.*\\)" line)
(cons (match-string 1 line)
(match-string 2 line))))
(split-string item "\n"))))
(setq result (cons data result))))
(dolist (item (nreverse result))
(insert "title: " (cdr (assoc "title" item)) "\n"
"version: " (cdr (assoc "revision" item)) "\n"
"generator: " (cdr (assoc "generator" item)) "\n"
"timestamp: " (cdr (assoc "last-modified" item)) "\n\n"
" " (or (cdr (assoc "description" item)) ""))
(fill-paragraph)
(insert "\n\n"))
(goto-char (point-min))))))
;; Derive `oddmuse-wiki' from the first file
(with-oddmuse-file (car files)
;; The wiki expects a Perl regular expression!
(let ((regexp (concat "^(" (mapconcat 'file-name-nondirectory files "|") ")$")))
(oddmuse-run "Getting recent changes" vc-oddmuse-log-command nil nil buffer)))
(with-current-buffer buffer
(oddmuse-render-rss3))
'limit-unsupported)
(defun vc-oddmuse-log-outgoing ()
(error "This is not supported."))
@@ -114,74 +94,76 @@ It must print the page to stdout.
(error "This is not supported."))
(defvar vc-oddmuse-get-revision-command
"curl --silent %w\"?action=browse;id=%t;revision=%o;raw=1\""
(concat "curl --silent"
" --form action=browse"
" --form id=%t"
" --form revision=%v"
" --form raw=1"
" '%w'")
"Command to use to get older revisions of a page.
It must print the page to stdout.
%? '?' character
%w URL of the wiki as provided by `oddmuse-wikis'
%t Page title as provided by `oddmuse-page-name'
%o Revision to retrieve as provided by `oddmuse-revision'")
%v Revision to retrieve as provided by `oddmuse-revision'")
(defvar vc-oddmuse-get-history-command
"curl --silent %w\"?action=history;id=%t;raw=1\""
"Command to use to get the history of a page.
It must print the page to stdout.
%? '?' character
%w URL of the wiki as provided by `oddmuse-wikis'
%t Page title as provided by `oddmuse-page-name'")
(defun oddmuse-revision-filename (rev)
"Return filename for revision REV.
This uses `oddmuse-directory', `oddmuse-wiki' and
`oddmuse-page-name'."
(concat oddmuse-directory
"/" oddmuse-wiki
"/" oddmuse-page-name
".~" rev "~"))
(defun vc-oddmuse-diff (files &optional rev1 rev2 buffer)
"Report the differences for FILES."
(setq buffer (or buffer (get-buffer-create "*vc-diff*")))
(dolist (file files)
(setq oddmuse-page-name (file-name-nondirectory file)
oddmuse-wiki (or oddmuse-wiki
(file-name-nondirectory
(directory-file-name
(file-name-directory file)))))
(let* ((wiki-data (or (assoc oddmuse-wiki oddmuse-wikis)
(error "Cannot find data for wiki %s" oddmuse-wiki)))
(url (nth 1 wiki-data)))
(unless rev1
;; Since we don't know the most recent revision we have to fetch
;; it from the server every time.
(with-temp-buffer
(let ((max-mini-window-height 1))
(oddmuse-run "Determining latest revision"
(oddmuse-format-command vc-oddmuse-get-history-command)
(current-buffer) nil))
(if (re-search-forward "^revision: \\([0-9]+\\)$" nil t)
(setq rev1 (match-string 1))
(error "Cannot determine the latest revision from the page history"))))
(with-oddmuse-file file
(setq rev1 (or rev1 (oddmuse-get-latest-revision wiki pagename)))
(dolist (rev (list rev1 rev2))
(when (and rev
(not (file-readable-p (concat oddmuse-directory
"/" oddmuse-wiki "/"
oddmuse-page-name
".~" rev "~"))))
(when (and rev (not (file-readable-p (oddmuse-revision-filename rev))))
(let* ((oddmuse-revision rev)
(command (oddmuse-format-command vc-oddmuse-get-revision-command))
(coding (nth 2 wiki-data))
(filename (concat oddmuse-directory "/" oddmuse-wiki "/"
oddmuse-page-name ".~" rev "~"))
(coding-system-for-read coding)
(coding-system-for-write coding))
(command (oddmuse-format-command
vc-oddmuse-get-revision-command))
(filename (oddmuse-revision-filename rev)))
(with-temp-buffer
(let ((max-mini-window-height 1))
(oddmuse-run (concat "Downloading revision " rev)
command (current-buffer) nil))
(oddmuse-run
(concat "Downloading revision " rev)
command wiki)
(write-file filename)))))
(diff-no-select
(if rev1
(concat oddmuse-directory "/" oddmuse-wiki "/" oddmuse-page-name ".~" rev1 "~")
file)
(if rev2
(concat oddmuse-directory "/" oddmuse-wiki "/" oddmuse-page-name ".~" rev2 "~")
file)
(if rev1 (oddmuse-revision-filename rev1) file)
(if rev2 (oddmuse-revision-filename rev2) file)
nil
(vc-switches 'oddmuse 'diff)
buffer))))
(defun vc-oddmuse-revert (file &optional contents-done)
"Revert FILE back to the wiki revision.
If optional arg CONTENTS-DONE is non-nil, then nothing needs to
be done, as the contents of FILE have already been reverted from
a version backup."
(unless contents-done
(with-oddmuse-file file
(let ((command (oddmuse-format-command vc-oddmuse-get-revision-command)))
(with-temp-buffer
(oddmuse-run "Loading" command)
(write-file file))))))
(defun vc-oddmuse-checkin (files rev comment)
"Commit changes in FILES to this backend.
REV is a historical artifact and should be ignored. COMMENT is
used as a check-in comment."
(dolist (file files)
(with-oddmuse-file file
(let* ((summary comment)
(command (oddmuse-format-command oddmuse-post-command))
(buf (get-buffer-create " *oddmuse-response*")))
(with-temp-buffer
(insert-file-contents file)
(oddmuse-run "Posting" command wiki pagename buf t 302))))))
(provide 'vc-oddmuse)

View File

@@ -74,6 +74,36 @@ h1 a:visited, h2 a:visited, h3 a:visited {
color: inherit;
}
/* for download buttons and the like */
.button {
display: inline-block;
font-size: 120%;
cursor: pointer;
padding: 0.4em 0.6em;
text-shadow: 0px -1px 0px #ccc;
background-color: #cfa;
border: 1px solid #9d8;
border-radius: 5px;
box-shadow: 0px 1px 3px white inset, 0px 1px 3px black;
}
.button .icon {
color: #363;
text-shadow: 0px -1px 1px white, 0px 1px 3px #666;
}
.button a {
text-decoration: none;
font-weight: normal;
}
/* links */
a.number {
text-decoration: none;
}
/* stop floating content from flowing over the footer */
hr {
@@ -235,8 +265,8 @@ div.comment h2 {
margin-top: 5em;
}
/* comment pages with username, homepage, and email subscription */
.comment span { display: block; }
.comment span label { display: inline-block; width: 10em; }
.comment form span { display: block; }
.comment form span label { display: inline-block; width: 10em; }
/* IE sucks */
.comment input#username,
.comment input#homepage,

View File

@@ -335,7 +335,22 @@ div.month a.local {
/* highlighting */
/* Equivalent to Output::HTML */
/* highlighting source code */
span.builtin { color: #483d8b; } /* DarkSlateBlue */
span.comment { color: #b22222; } /* Firebrick */
span.constant { color: #008b8b; } /* DarkCyan */
span.function { color: #0000ff; } /* Blue1 */
span.keyword { color: #7f007f; } /* Purple */
span.string { color: #8b475d; } /* VioletRed4 */
span.type { color: #228b22; } /* ForestGreen */
span.warning { color: #ff0000; font-weight: bold; } /* Red1 */
span.comment span,
span.string span { color: inherit; }
span.comment span.important.constant,
span.string span.important.constant { color: #008b8b; }
/* old: Equivalent to Output::HTML */
span.linecomment { color: green; }
span.blockcomment { color: green; }

View File

@@ -28,7 +28,7 @@ body {
padding:2% 5%;
margin:0;
font-family: "Gentium Basic", "Bookman Old Style", "Times New Roman", serif;
font-size: 18pt;
font-size: 16pt;
}
div.header h1 {
@@ -129,9 +129,15 @@ dd {
margin-bottom:1ex;
}
textarea { width:100%; height:80%; }
textarea {
width:100%;
height:80%;
font-size: 12pt;
}
textarea#summary { height: 3em; }
input {
font-size: 12pt;
}
div.image span.caption {
margin: 0 1em;
}
@@ -191,6 +197,19 @@ hr {
div.footer hr {
height:4px;
margin: 2em 0 1ex 0;
clear:both;
}
div.content > div.comment {
border-top: none;
padding-top: none;
border-left: 1ex solid #bbb;
padding-left: 1ex;
}
div.wrapper > div.comment {
border-top: 2px solid #000;
padding-top: 2em;
}
pre {
@@ -199,9 +218,13 @@ pre {
margin-right: 2em;
white-space: pre;
overflow:hidden;
font-size: smaller;
white-space: pre-wrap; /* CSS 3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
div.footer hr {
clear:both;
}
tt, pre, code {
font-size: 80%;
};

1
description Normal file
View File

@@ -0,0 +1 @@
Oddmuse

2
modules/aawrapperdiv.pl Executable file → Normal file
View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/aawrapperdiv.pl">aawrapperdiv.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/WrapperDiv_Module">WrapperDiv Module</a></p>';
AddModuleDescription('aawrapperdiv.pl', 'WrapperDiv Module');
*OldGetHeader = *GetHeader;

36
modules/accesskeys.pl Normal file
View File

@@ -0,0 +1,36 @@
# Copyright (C) 2014 Alex-Daniel Jakimenko <alex.jakimenko@gmail.com>
# Copyright (C) 2014 Alex Schroeder <alex@gnu.org>
# 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 <http://www.gnu.org/licenses/>.
package OddMuse;
AddModuleDescription('accesskeys.pl', 'Links With AccessKeys Extension');
push(@MyRules, \&LinksWithAccessKeys);
sub LinksWithAccessKeys {
if (m/\G(\[\[$FreeLinkPattern\{(.)\}\]\])/cog) {
my ($id, $key) = ($2, $3);
Dirty($1);
$id = FreeToNormal($id);
my ($class, $resolved, $title, $exists) = ResolveId($id);
my $text = NormalToFree($id);
if ($resolved) { # anchors don't exist as pages, therefore do not use $exists
print ScriptLink(UrlEncode($resolved), $text, $class, undef, $title, $key);
} else {
print "[[" . QuoteHtml($text) . GetEditLink($id, '?') . "]]";
}
return ''; # this is a dirty rule that depends the definition of other pages
}
return undef; # the rule didn't match
}

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/admin.pl">admin.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Admin_Power_Extension">Admin Power Extension</a></p>';
AddModuleDescription('admin.pl', 'Admin Power Extension');
$Action{delete} = \&AdminPowerDelete;
$Action{rename} = \&AdminPowerRename;
@@ -62,13 +62,13 @@ sub AdminPowerRename {
# Regenerate index on next request -- remove this before errors can occur!
unlink($IndexFile);
# page file
CreatePageDir($PageDir, $new); # It might not exist yet
CreateDir($PageDir); # It might not exist yet
rename($fname, $newfname)
or ReportError(Tss('Cannot rename %1 to %2', $fname, $newfname) . ": $!", '500 INTERNAL SERVER ERROR');
# keep directory
my $kdir = GetKeepDir($id);
my $newkdir = GetKeepDir($new);
CreatePageDir($KeepDir, $new); # It might not exist yet (only the parent directory!)
CreateDir($KeepDir); # It might not exist yet (only the parent directory!)
rename($kdir, $newkdir)
or ReportError(Tss('Cannot rename %1 to %2', $kdir, $newkdir) . ": $!", '500 INTERNAL SERVER ERROR')
if -d $kdir;
@@ -76,7 +76,7 @@ sub AdminPowerRename {
if (defined(&GetRefererFile)) {
my $rdir = GetRefererFile($id);
my $newrdir = GetRefererFile($new);
CreatePageDir($RefererDir, $new); # It might not exist yet
CreateDir($RefererDir); # It might not exist yet
rename($rdir, $newrdir)
or ReportError(Tss('Cannot rename %1 to %2', $rdir, $newrdir) . ": $!", '500 INTERNAL SERVER ERROR')
if -d $rdir;

View File

@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/adsense.pl">adsense.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/AdSense_Module">AdSense Module</a></p>';
AddModuleDescription('adsense.pl', 'AdSense Module');
use vars qw($AdSensePageName $AdSensePlace);

View File

@@ -0,0 +1,35 @@
# Copyright (C) 2014 Alex-Daniel Jakimenko <alex.jakimenko@gmail.com>
# 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 <http://www.gnu.org/licenses/>.
package OddMuse;
AddModuleDescription('advanced-uploads.pl', 'Advanced File Upload Extension');
$HtmlHeaders .= '<script type="text/javascript" src="/js/uploader.js"></script>';
*AdvancedUploadsOldGetTextArea = *GetTextArea;
*GetTextArea = *AdvancedUploadsNewGetTextArea;
sub AdvancedUploadsNewGetTextArea {
my ($name, $text, $rows) = @_;
return AdvancedUploadsOldGetTextArea(@_) . $q->br() . ($name =~ 'text|aftertext' ? GetUploadForm() : '');
}
sub GetUploadForm {
return $q->span({-class=>'upload'}, $q->label({-for=>'fileToUpload'}, T('Attach file:')),
$q->filefield(-name=>'fileToUpload', -id=>'fileToUpload', -multiple=>'multiple', -onChange=>'fileSelected()', -size=>20),
$q->span({-id=>'fileSize'}, ''),
$q->button(-name=>'uploadButton', -value=>T('Upload'), -onClick=>'uploadFile()'),
$q->span({-id=>'progressNumber'}));
}

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/age.pl">age.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Age_Indication_Extension">Age Indication Extension</a></p>';
AddModuleDescription('age.pl', 'Age Indication Extension');
use vars qw(%AgeEffect $AgeParameter);

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/aggregate.pl">aggregate.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Front_Page_Extension">Front Page Extension</a></p>';
AddModuleDescription('aggregate.pl', 'Front Page Extension');
push(@MyRules, \&AggregateRule);

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/all.pl">all.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/All_Action">All Action</a></p>';
AddModuleDescription('all.pl', 'All Action');
$Action{all} = \&DoPrintAllPages;
@@ -28,7 +28,7 @@ sub DoPrintAllPages {
print GetHeader('', T('Complete Content'))
. $q->p(Ts('The main page is %s.', $q->a({-href=>'#' . $HomePage}, $HomePage)));
print $q->p($q->b(Ts('(for %s)', GetParam('lang', 0)))) if GetParam('lang', 0);
PrintAllPages(0, 0, undef, AllPagesList());
PrintAllPages(0, 0, undef, undef, AllPagesList());
PrintFooter();
}

View File

@@ -12,7 +12,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/anchors.pl">anchors.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Local_Anchor_Extension">Local Anchor Extension</a></p>';
AddModuleDescription('anchors.pl', 'Local Anchor Extension');
push(@MyRules, \&AnchorsRule);

2
modules/antispam.pl Executable file → Normal file
View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/antispam.pl">antispam.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Antispam_Module">Antispam Module</a></p>';
AddModuleDescription('antispam.pl', 'Antispam Module');
use vars qw($DoMaskEmail $CreateMailtoLinks);

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/archive.pl">archive.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Archive_Extension">Archive Extension</a></p>';
AddModuleDescription('archive.pl', 'Archive Extension');
*OldArchiveGetHeader = *GetHeader;
*GetHeader = *NewArchiveGetHeader;

63
modules/askpage.pl Normal file
View File

@@ -0,0 +1,63 @@
# Copyright (C) 2014 Alex-Daniel Jakimenko <alex.jakimenko@gmail.com>
#
# 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 <http://www.gnu.org/licenses/>.
AddModuleDescription('askpage.pl', 'Ask Page Extension');
use Fcntl qw(:DEFAULT :flock);
use vars qw($AskPage $QuestionPage $NewQuestion);
# Don't forget to set your $CommentsPattern to include both $AskPage and $QuestionPage
$AskPage = 'Ask';
$QuestionPage = 'Question_';
$NewQuestion = 'Write your question here:';
sub IncrementInFile {
my $filename = shift;
sysopen my $fh, $filename, O_RDWR|O_CREAT or die "can't open $filename: $!";
flock $fh, LOCK_EX or die "can't flock $filename: $!";
my $num = <$fh> || 1;
seek $fh, 0, 0 or die "can't rewind $filename: $!";
truncate $fh, 0 or die "can't truncate $filename: $!";
(print $fh $num+1, "\n") or die "can't write $filename: $!";
close $fh or die "can't close $filename: $!";
return $num;
}
*OldAskPageDoPost=*DoPost;
*DoPost=*NewAskPageDoPost;
sub NewAskPageDoPost {
my $id = FreeToNormal(shift);
if ($id eq $AskPage and not GetParam('text', undef)) { # comment, not a regular edit
my $currentQuestion = IncrementInFile("$DataDir/curquestion");
$currentQuestion =~ s/[\s\n]//g;
return OldAskPageDoPost($QuestionPage . $currentQuestion, @_); # hack page name
}
OldAskPageDoPost($id, @_); # keep original functionality for regular edits
}
*OldAskPageGetCommentForm=*GetCommentForm;
*GetCommentForm=*NewAskPageGetCommentForm;
sub NewAskPageGetCommentForm {
my ($id, $rev, $comment) = @_;
$NewComment = $NewQuestion if $id eq $AskPage;
OldAskPageGetCommentForm(@_);
}
*OldAskPageJournalSort=*JournalSort;
*JournalSort=NewAskPageJournalSort;
sub NewAskPageJournalSort {
return OldAskPageJournalSort() unless $a =~ m/^$QuestionPage\d+$/ and $b =~ m/^$QuestionPage\d+$/;
($b =~ m/$QuestionPage(\d+)/)[0] <=> ($a =~ m/$QuestionPage(\d+)/)[0];
}

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2004, 2006, 2008 Alex Schroeder <alex@gnu.org>
# Copyright (C) 2004, 2006, 2008, 2014 Alex Schroeder <alex@gnu.org>
#
# 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
@@ -17,7 +17,7 @@ use XML::Atom::Entry;
use XML::Atom::Link;
use XML::Atom::Person;
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/atom.pl">atom.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Atom_Extension">Atom Extension</a></p>';
AddModuleDescription('atom.pl', 'Atom Extension');
push(@MyInitVariables, \&AtomInit);
@@ -140,11 +140,11 @@ sub DoAtomSave {
my $title = $entry->title();
my $author = $entry->author();
SetParam('username', $author->name) if $author; # Used in Save()
my $id = FreeToNormal($title) if ValidIdOrDie($title);
my $id = FreeToNormal($title);
UserCanEditOrDie($id);
$oldid = $id unless $oldid;
ValidIdOrDie($oldid);
my $summary = $entry->summary();
ReportError(Ts('Editing not allowed for %s.', $id), '403 FORBIDDEN') unless UserCanEdit($id, 1);
# Lock before getting old page to prevent races
RequestLockOrError(); # fatal
OpenPage($oldid);

View File

@@ -25,7 +25,7 @@ directory of your Oddmuse Wiki.
=cut
package OddMuse;
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/autolock.pl">autolock.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Autolock_Extension">Autolock Extension</a></p>';
AddModuleDescription('autolock.pl', 'Autolock Extension');
# ....................{ CONFIGURATION }....................

View File

@@ -20,7 +20,7 @@
# ie: http://search.cpan.org/CPAN/authors/id/C/CH/CHAMAS/MLDBM-2.01.tar.gz
use MLDBM qw( DB_File Storable );
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/backlinkage.pl">backlinkage.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Inline_Backlinks">Inline Backlinks</a></p>';
AddModuleDescription('backlinkage.pl', 'Inline Backlinks');
my $debug=1; # Set Text Output Verbosity when compiling
my $backfile = $DataDir . '/backlinks.db'; # Where data lives

2
modules/backlinks.pl Executable file → Normal file
View File

@@ -10,7 +10,7 @@
# For user doc, see:
# http://www.oddmuse.org/cgi-bin/oddmuse/Backlinks_Extension
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/backlinks.pl">backlinks.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Backlinks_Extension">Backlinks Extension</a></p>';
AddModuleDescription('backlinks.pl', 'Backlinks Extension');
*OldGetSearchLink = *GetSearchLink;
*GetSearchLink = *NewGetSearchLink;

View File

@@ -15,14 +15,20 @@
=head1 Balanced Page Directories
By default, Oddmuse disperses page data files into 27 directories
based on the first character of the page name. The directories are "A"
to "Z", and "other". If you use your wiki as a blog, all the pages
starting with a date end up in "other". If your page names start with
letters other than "A" to "Z", all the pages end up in "other". If you
are using comment pages, all your comment pages end in "C". This can
turn into a problem if you reach ten thousand pages and more in a
single directory.
B<WARNING: This module is deprecated.> Oddmuse no longer disperses
page data files into 27 directories based on the first character of
the page name. The directories used to be "A" to "Z", and "other". If
you uses your wiki as a blog, all the pages starting with a date ended
up in "other". If your page names started with letters other than "A"
to "Z", all the pages ended up in "other". If you were using comment
pages, all your comment pages ended in "C". This module was intended
to create more subdirectories and spread them more evenly. This is no
longer necessary, as the typical filesystem's performance no longer
degrades with tens of thousands of files in a directory. I'm assuming
most Oddmuse hosts to use some form of GNU/Linux with ext3 or ext4
with dir_index option.
The remaining info for this module is all deprecated.
=over
@@ -67,7 +73,7 @@ wiki is locked and migration is started.
=cut
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/balanced-page-directories.pl">balanced-page-directories.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Balanced_Page_Directories_Extension">Balanced Page Directories Extension</a>';
AddModuleDescription('balanced-page-directories.pl', 'Balanced Page Directories Extension');
use Digest::MD5 qw(md5_hex);
use File::Find qw(finddepth);

View File

@@ -25,7 +25,7 @@ the IP or hostname will be added to the C<BannedHosts> page for you.
=cut
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/ban-contributors.pl">ban-contributors.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Ban_Contributors_Extension">Ban Contributors Extension</a></p>';
AddModuleDescription('ban-contributors.pl', 'Ban Contributors Extension');
push(@MyAdminCode, \&BanMenu);
@@ -150,7 +150,7 @@ sub NewBanContributorsWriteRcLog {
$q->submit(T('Ban!'))),
$q->end_form();
};
print $q->p(T("Consider banning the hostname or IP number as well: "),
print $q->p(T("Consider banning the IP number as well: "),
ScriptLink('action=ban;id=' . UrlEncode($id), T('Ban contributors')));
};
return OldBanContributorsWriteRcLog(@_);

View File

@@ -15,7 +15,7 @@
# This file must load before logbannedcontent.pl such that quick
# editors will be logged.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/ban-quick-editors.pl">ban-quick-editors.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Banning_Quick_Editors">Banning Quick Editors</a></p>';
AddModuleDescription('ban-quick-editors.pl', 'Banning Quick Editors');
*BanQuickOldUserIsBanned = *UserIsBanned;
*UserIsBanned = *BanQuickNewUserIsBanned;
@@ -25,7 +25,7 @@ sub BanQuickNewUserIsBanned {
if (not $rule
and $SurgeProtection # need surge protection
and GetParam('title')) {
my $name = GetParam('username', $ENV{'REMOTE_ADDR'});
my $name = GetParam('username', GetRemoteHost());
my @entries = @{$RecentVisitors{$name}};
# $entry[0] is $Now after AddRecentVisitor
my $ts = $entries[1];

View File

@@ -14,7 +14,7 @@
package OddMuse;
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/banned-regexps.pl">banned-regexps.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Banning_Regular_Expressions">Banning Regular Expressions</a></p>';
AddModuleDescription('banned-regexps.pl', 'Banning Regular Expressions');
=h1 Compatibility

View File

@@ -12,7 +12,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/bbcode.pl">bbcode.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/bbCode_Extension">bbCode Extension</a></p>';
AddModuleDescription('bbcode.pl', 'bbCode Extension');
push(@MyRules, \&bbCodeRule);
@@ -122,15 +122,15 @@ sub bbCodeRule {
# smiley
elsif (/\G(:-?[()])/cg) {
if (substr($1,-1) eq ')') {
# '☺' 0009786 00263a WHITE SMILING FACE, So, 0, ON, N,
return '&#x263a;'; }
# 😊 1F60A SMILING FACE WITH SMILING EYES
return '&#x1F60A;'; }
else {
# '☹' 0009785 002639 WHITE FROWNING FACE, So, 0, ON, N,
return '&#x2639;'; }}
# 😟 1F61F WORRIED FACE
return '&#x1F61F;'; }}
elsif (/\G:(?:smile|happy):/cg) {
return '&#x263a;'; }
return '&#x1F60A;'; }
elsif (/\G:(?:sad|frown):/cg) {
return '&#x2639;'; }
return '&#x1F61F;'; }
# no match
return undef;
}

View File

@@ -17,7 +17,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/beautify.pl">beautify.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Source_Code_Beautification_Extension">Source Code Beautification Extension</a></p>';
AddModuleDescription('beautify.pl', 'Source Code Beautification Extension');
use Beautifier::Core;
use Output::HTML;

View File

@@ -15,7 +15,7 @@
package OddMuse;
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/big-brother.pl">big-brother.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Big_Brother_Extension">Big Brother Extension</a></p>';
AddModuleDescription('big-brother.pl', 'Big Brother Extension');
use vars qw($VisitorTime);

2
modules/blockquote.pl Executable file → Normal file
View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/blockquote.pl">blockquote.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Comments_on_Text_Formatting_Rules">Comments on Text Formatting Rules</a></p>';
AddModuleDescription('blockquote.pl', 'Comments on Text Formatting Rules');
push(@MyRules, \&BlockQuoteRule);

View File

@@ -22,7 +22,7 @@
# is useless. This extension will not work under Windows/IIS unless cal
# is installed.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/cal3.pl">cal3.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Cal3_Extension">Cal3 Extension</a></p>';
AddModuleDescription('cal3.pl', 'Cal3 Extension');
*OldCalendarGetHeader = *GetHeader;
*GetHeader = *NewCalendarGetHeader;

View File

@@ -17,7 +17,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/calendar.pl">calendar.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Calendar_Extension">Calendar Extension</a></p>';
AddModuleDescription('calendar.pl', 'Calendar Extension');
use vars qw($CalendarOnEveryPage $CalAsTable $CalStartMonday);
@@ -104,7 +104,7 @@ sub DoCollect {
# Now save information required for saving the cache of the current page.
local (%Page, $OpenPageName);
print $q->start_div({-class=>'content journal collection'});
PrintAllPages(1, 1, undef, @pages);
PrintAllPages(1, 1, undef, undef, @pages);
print $q->end_div();
}
$CollectingJournal = 0;

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/canonical.pl">canonical.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Canonical_Names">Canonical Names</a></p>';
AddModuleDescription('canonical.pl', 'Canonical Names');
use utf8;

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/checkbox.pl">checkbox.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Checklist_Extension">Checklist Extension</a></p>';
AddModuleDescription('checkbox.pl', 'Checklist Extension');
# [[ : To do]]
# [[X: Done]]

10
modules/clustermap.pl Executable file → Normal file
View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/clustermap.pl">clustermap.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/ClusterMap_Module">ClusterMap Module</a></p>';
AddModuleDescription('clustermap.pl', 'ClusterMap Module');
use vars qw($ClusterMapPage $ClusterMapTOC $FilterUnclusteredRegExp @ClusterMapAdminPages);
@@ -40,8 +40,8 @@ $PrintTOCAnchor = 0;
%ClusterMap = ();
*OldDoRc = *DoRc;
*DoRc = *ClusterMapDoRc;
*OldPrintRcHtml = *PrintRcHtml;
*PrintRcHtml = *ClusterMapPrintRcHtml;
push(@MyAdminCode, \&ClusterMapAdminRule);
@@ -178,7 +178,7 @@ sub CreateClusterMap {
}
}
sub ClusterMapDoRc {
sub ClusterMapPrintRcHtml {
my ( @options ) = @_;
my $page = "";
my $cluster = GetParam(rcclusteronly);
@@ -195,7 +195,7 @@ sub ClusterMapDoRc {
print "</ul>";
}
OldDoRc(@options);
OldPrintRcHtml(@options);
}
sub PrintUnclusteredMap {

View File

@@ -0,0 +1,55 @@
# Copyright (C) 2014 Alex-Daniel Jakimenko <alex.jakimenko@gmail.com>
# Copyright (C) 2014 Alex Schroeder <alex@gnu.org>
# 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 <http://www.gnu.org/licenses/>.
package OddMuse;
AddModuleDescription('comment-div-wrapper.pl', 'Comment Div Wrapper Extension');
my $CommentDiv = 0;
push(@MyRules, \&CommentDivWrapper);
$RuleOrder{\&CommentDivWrapper} = -50;
sub CommentDivWrapper {
if (substr($OpenPageName, 0, length($CommentsPrefix)) eq $CommentsPrefix) {
if (pos == 0 and not $CommentDiv) {
$CommentDiv = 1;
return $q->start_div({-class=>'userComment'});
}
}
if ($OpenPageName =~ /$CommentsPattern/o) {
if ($bol and m/\G(\s*\n)*----+[ \t]*\n?/cg) {
my $html = CloseHtmlEnvironments()
. ($CommentDiv++ > 0 ? $q->end_div() : $q->h2({-class=>'commentsHeading'}, T('Comments:'))) . $q->start_div({-class=>'userComment'})
. AddHtmlEnvironment('p');
return $html;
}
}
return undef;
}
# close final div
*OldCommentDivApplyRules = *ApplyRules;
*ApplyRules = *NewCommentDivApplyRules;
sub NewCommentDivApplyRules {
my ($blocks, $flags) = OldCommentDivApplyRules(@_);
if ($CommentDiv) {
print $q->end_div();
$blocks .= $FS . $q->end_div();
$flags .= $FS . 0;
$CommentDiv = 0;
}
return ($blocks, $flags);
}

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/commentcount.pl">commentcount.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Comment_Count_Extension">Comment Count Extension</a></p>';
AddModuleDescription('commentcount.pl', 'Comment Count Extension');
*OldCommentcountAddComment = *AddComment;
*AddComment = *NewCommentcountAddComment;

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/compilation.pl">compilation.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Compilation_Extension">Compilation Extension</a></p>';
AddModuleDescription('compilation.pl', 'Compilation Extension');
$Action{compilation} = \&DoCompilation;
@@ -49,7 +49,7 @@ sub PrintCompilation {
local %Page;
local $OpenPageName='';
print '<div class="compilation">';
PrintAllPages(1, 1, undef, @pages);
PrintAllPages(1, 1, undef, undef, @pages);
print '</div>';
}
return @pages;

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/config.pl">config.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Plans">Plans</a></p>';
AddModuleDescription('config.pl', 'Plans');
$Action{config} = \&DoConfig;
$Action{clone} = \&DoClone;
@@ -37,7 +37,7 @@ sub DoConfig {
$SurgeProtection $SurgeProtectionTime $SurgeProtectionViews
$DeletedPage $RCName @RcDays $RcDefault $KeepDays
$KeepMajor $SummaryHours $SummaryDefaultLength $ShowEdits
$UseLookup $RecentTop $RecentLink $PageCluster
$RecentTop $RecentLink $PageCluster
$InterWikiMoniker $SiteDescription $RssImageUrl $RssRights
$RssExclude $RssCacheHours $RssStyleSheet $UploadAllowed
@UploadTypes $EmbedWiki $FooterNote $EditNote $TopLinkBar

View File

@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/context.pl">context.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Calendar_Extension">Calendar Extension</a></p>';
AddModuleDescription('context.pl', 'Calendar Extension');
push (@MyInitVariables, \&ContextMenuItem);

View File

@@ -23,7 +23,7 @@
#
# Of course, you can customize this to store more information
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/creationdate.pl">creationdate.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/CreationDate_Module">CreationDate Module</a></p>';
AddModuleDescription('creationdate.pl', 'CreationDate Module');
*CreationDateOldOpenPage = *OpenPage;
*OpenPage = CreationDateOpenPage;

View File

@@ -14,7 +14,7 @@ directory for your Oddmuse Wiki.
=cut
package OddMuse;
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/creole.pl">creole.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Creole_Markup_Extension">Creole Markup Extension</a></p>';
AddModuleDescription('creole.pl', 'Creole Markup Extension');
# ....................{ CONFIGURATION }....................
@@ -242,6 +242,7 @@ sub CreoleRule {
-class=> 'image outside'},
$q->img({-src=> UnquoteHtml($1),
-alt=> UnquoteHtml($3),
-title=> UnquoteHtml($3),
-class=> 'url outside'})));
}
# image link: [[link|{{pic}}]] and [[link|{{pic|text}}]]
@@ -252,6 +253,7 @@ sub CreoleRule {
ScriptLink(UrlEncode(FreeToNormal($2)),
$q->img({-src=> GetDownloadLink(FreeToNormal($3), 2),
-alt=> UnquoteHtml($text),
-title=> UnquoteHtml($text),
-class=> 'upload'}), 'image')), $text);
}
# image link: [[link|{{url}}]] and [[link|{{url|text}}]]
@@ -262,6 +264,7 @@ sub CreoleRule {
ScriptLink(UrlEncode(FreeToNormal($2)),
$q->img({-src=> UnquoteHtml($3),
-alt=> UnquoteHtml($text),
-title=> UnquoteHtml($text),
-class=> 'url outside'}), 'image')), $text);
}
# image link: [[url|{{pic}}]] and [[url|{{pic|text}}]]
@@ -272,6 +275,7 @@ sub CreoleRule {
$q->a({-href=> UnquoteHtml($2), -class=> 'image outside'},
$q->img({-src=> GetDownloadLink(FreeToNormal($3), 2),
-alt=> UnquoteHtml($text),
-title=> UnquoteHtml($text),
-class=> 'upload'}))), $text);
}
# image link: [[url|{{url}}]] and [[url|{{url|text}}]]
@@ -281,6 +285,7 @@ sub CreoleRule {
$q->a({-href=> UnquoteHtml($1), -class=> 'image outside'},
$q->img({-src=> UnquoteHtml($2),
-alt=> UnquoteHtml($4),
-title=> UnquoteHtml($4),
-class=> 'url outside'})));
}
# link: [[url]] and [[url|text]]
@@ -456,21 +461,16 @@ sub CreoleListAndNewLineRule {
my $is_in_list_item = InElement('li');
# # numbered list
if (($bol and m/\G[ \t]*(#)[ \t]*/cg) or
($is_in_list_item and m/\G[ \t]*\n+[ \t]*(#+)[ \t]*/cg)) {
# * bullet list (nestable; needs space when nested to disambiguate from bold)
if (($bol and m/\G[ \t]*([#*])[ \t]*/cg) or
($is_in_list_item and m/\G[ \t]*\n+[ \t]*(#+)[ \t]*/cg) or
($is_in_list_item and m/\G[ \t]*\n+[ \t]*(\*+)[ \t]+/cg)) {
# Note: the first line of this return statement is --not-- equivalent to:
# "return CloseHtmlEnvironmentUntil('li')", as that line does not permit
# modules overriding the CloseHtmlEnvironments() function to "have a say."
return ($is_in_list_item ? CloseHtmlEnvironmentUntil('li') : CloseHtmlEnvironments())
.OpenHtmlEnvironment('ol', length($1))
.AddHtmlEnvironment ('li');
}
# * bullet list (nestable; needs space when nested to disambiguate from bold)
elsif (($bol and m/\G[ \t]*(\*)[ \t]*/cg) or
($is_in_list_item and m/\G[ \t]*\n+[ \t]*(\*+)[ \t]+/cg)) {
return ($is_in_list_item ? CloseHtmlEnvironmentUntil('li') : CloseHtmlEnvironments())
.OpenHtmlEnvironment('ul', length($1))
.AddHtmlEnvironment ('li');
.OpenHtmlEnvironment(substr($1, 0, 1) eq '#' ? 'ol' : 'ul', length($1), '', 'ol|ul')
.AddHtmlEnvironment('li');
}
# - bullet list (not nestable; always needs space)
elsif ($CreoleDashStyleUnorderedLists and (

View File

@@ -22,7 +22,7 @@ creoleaddition is simply installable; simply:
=cut
package OddMuse;
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/creoleaddition.pl">creoleaddition.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Creole_Addition_Markup_Extension">Creole Addition Markup Extension</a></p>';
AddModuleDescription('creoleaddition.pl', 'Creole Addition Markup Extension');
# ....................{ CONFIGURATION }....................

2
modules/crossbar.pl Executable file → Normal file
View File

@@ -33,7 +33,7 @@ crossbar is easily installable; move this file into the B<wiki/modules/>
directory for your Oddmuse Wiki.
=cut
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/crossbar.pl">crossbar.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Crossbar_Extension">Crossbar Extension</a></p>';
AddModuleDescription('crossbar.pl', 'Crossbar Extension');
# ....................{ CONFIGURATION }....................
use vars qw($CrossbarPageName

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/crumbs.pl">crumbs.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/List_Parent_Pages_Extension">List Parent Pages Extension</a></p>';
AddModuleDescription('crumbs.pl', 'List Parent Pages Extension');
push(@MyRules, \&CrumbsRule);
$RuleOrder{\&CrumbsRule} = -10; # run before default rules!

View File

@@ -15,7 +15,7 @@ automatically.
=cut
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/css-install.pl">css-install.pl</a></p>';
AddModuleDescription('css-install.pl');
=head1 CONFIGURATION

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/csv.pl">csv.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Comments_on_Long_Table_Markup_Extension">Comments on Long Table Markup Extension</a></p>';
AddModuleDescription('csv.pl', 'Comments on Long Table Markup Extension');
push(@MyRules, \&CsvRule);

View File

@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/dates.pl">dates.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Dates_Extension">Dates Extension</a></p>';
AddModuleDescription('dates.pl', 'Dates Extension');
push(@MyAdminCode, \&DatesMenu);

View File

@@ -15,6 +15,8 @@
package OddMuse;
AddModuleDescription('debug.pl');
@Debugging = (\&DebugInterLinks);
sub DebugInterLinks {

View File

@@ -12,7 +12,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/delete-all.pl">delete-all.pl</a></p>';
AddModuleDescription('delete-all.pl');
use vars qw($DeletedAge);

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/despam.pl">despam.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Despam_Extension">Despam Extension</a></p>';
AddModuleDescription('despam.pl', 'Despam Extension');
push(@MyAdminCode, \&DespamMenu);

84
modules/diff.pl Normal file
View File

@@ -0,0 +1,84 @@
# Copyright (C) 2014 Alex-Daniel Jakimenko <alex.jakimenko@gmail.com>
# Copyright (C) 2014 Alex Schroeder <alex@gnu.org>
# 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 <http://www.gnu.org/licenses/>.
package OddMuse;
AddModuleDescription('diff.pl', 'Diff Action Extension');
push(@MyRules, \&DiffActionRule);
$Action{pagediff} = \&DoDiffAction;
sub DiffActionRule {
return PrintDiffActionChooser($3) if (m/\G(&lt;diff( (.*))&gt;)/cgi);
return undef; # the rule didn't match
}
sub DoDiffAction {
print GetHeader('', T('Page diff'), '');
my $page1 = GetParam('page1');
my $page2 = GetParam('page2');
my $pattern = GetParam('pattern');
$pattern ||= '.*';
print PrintDiffActionChooser($pattern);
ValidIdOrDie($page1);
ValidIdOrDie($page2);
my $diff = DoUnifiedDiff("1\n \n" . GetPageContent($page1), "2\n \n" . GetPageContent($page2)); # add extra lines, otherwise diff between identical files will print nothing # TODO fix this, otherwise one day this will fail...
$diff = QuoteHtml($diff);
$diff =~ tr/\r//d; # TODO is this required? # probably not
for (split /\n/, $diff) {
s/(^.)//;
my $type = $1;
if ($type eq '+') {
print '<span class="diffactionnew">' . $type;
} elsif ($type eq '-') {
print '<span class="diffactionold">' . $type;
}
ApplyRules($_);
print '</span>' if $type =~ /[+-]/;
print '<br/>';
}
PrintFooter();
}
sub PrintDiffActionChooser {
my $pattern = shift;
$pattern ||= '.*';
my @chosenPages = ();
for (@IndexList) {
push @chosenPages, $_ if m/$pattern/;
}
return GetFormStart(undef, 'get', 'pagediff')
. GetHiddenValue('action', 'pagediff')
. GetHiddenValue('pattern', $pattern)
. $q->popup_menu(-name=>'page1', -values=>\@chosenPages) . ' '
. $q->popup_menu(-name=>'page2', -values=>\@chosenPages) . ' '
. $q->submit(-name=>'', -value=>T('Diff'))
. $q->end_form();
}
sub DoUnifiedDiff { # copied from DoDiff
CreateDir($TempDir);
my $oldName = "$TempDir/old";
my $newName = "$TempDir/new";
RequestLockDir('diff') or return '';
WriteStringToFile($oldName, $_[0]);
WriteStringToFile($newName, $_[1]);
my $diff_out = `diff -U 99999 -- \Q$oldName\E \Q$newName\E | tail -n +7`; # should be +4, but we always add extra line # TODO that workaround is ugly, fix it!
utf8::decode($diff_out); # needs decoding
$diff_out =~ s/\n\K\\ No newline.*\n//g; # Get rid of common complaint.
ReleaseLockDir('diff');
# No need to unlink temp files--next diff will just overwrite.
return $diff_out;
}

35
modules/div-foo.pl Normal file
View File

@@ -0,0 +1,35 @@
# Copyright (C) 2014 Alex-Daniel Jakimenko <alex.jakimenko@gmail.com>
#
# 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 <http://www.gnu.org/licenses/>.
package OddMuse;
AddModuleDescription('div-foo.pl', 'Div Foo Extension');
push(@MyRules, \&DivFooRule);
sub DivFooRule {
if (m/\G\&lt;([\w ]+)\&gt;\s*\n/cg) {
return CloseHtmlEnvironment('p') . AddHtmlEnvironment('div', qq{class="$1"});
}
if (m/\G\&lt;([\w ]+)\&gt;/cg) {
return AddHtmlEnvironment('span', qq{class="$1"});
}
if (m/\G\&lt;\/\/\&gt;/cg) {
return CloseHtmlEnvironment('div') . (InElement('div') ? '' : AddHtmlEnvironment('p'));
}
if (m/\G\&lt;\/\&gt;/cg) {
return CloseHtmlEnvironment('span');
}
return undef;
}

View File

@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/dojo.pl">dojo.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Using_Dojo_Instead_Of_Wiki_Markup">Using Dojo Instead Of Wiki Markup</a></p>';
AddModuleDescription('dojo.pl', 'Using Dojo Instead Of Wiki Markup');
use vars qw(@DojoPlugins $DojoTheme);

View File

@@ -21,7 +21,7 @@
# edit a page by double-clicking on it. The user must have
# JavaScript enabled for this to work.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/doubleclick.pl">doubleclick.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Doubleclick_Extension">Doubleclick Extension</a></p>';
AddModuleDescription('doubleclick.pl', 'Doubleclick Extension');
*OldDoubleclickGetHeader = *GetHeader;
*GetHeader = NewDoubleclickGetHeader;

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/download.pl">download.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Download_Extension">Download Extension</a></p>';
AddModuleDescription('download.pl', 'Download Extension');
push( @MyRules, \&DownloadSupportRule );

View File

@@ -15,6 +15,8 @@
use File::Glob ':glob';
use vars qw($DraftDir);
AddModuleDescription('drafts.pl');
$DraftDir = $DataDir."/draft"; # directory for drafts
push(@MyInitVariables, \&DraftInit);

View File

@@ -12,7 +12,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/duckduckgo-search.pl">duckduckgo-search.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Use_DuckDuckGo_For_Searches">Use DuckDuckGo For Searches</a></p>';
AddModuleDescription('duckduckgo-search.pl', 'Use DuckDuckGo For Searches');
use vars qw($DuckDuckGoSearchDomain);

View File

@@ -12,7 +12,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/dynamic-comments.pl">dynamic-comments.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Dynamic_Comments_Extension">Dynamic Comments Extension</a></p>';
AddModuleDescription('dynamic-comments.pl', 'Dynamic Comments Extension');
push(@MyInitVariables, \&DynamicCommentsAddScript);

View File

@@ -27,7 +27,7 @@
# $LogoUrl = GetDynLogoUrl();
#
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/dynlogo.pl">dynlogo.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Dynamic_Logo">Dynamic Logo</a></p>';
AddModuleDescription('dynlogo.pl', 'Dynamic Logo');
use vars qw($DynLogoDirectory $DynLogoDefault %DynLogoMap);

View File

@@ -15,7 +15,7 @@
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/edit-assist.pl">edit-assist.pl</a></p>';
AddModuleDescription('edit-assist.pl');
push (@MyInitVariables,
sub {

View File

@@ -1,3 +1,5 @@
AddModuleDescription('edit-cluster.pl');
$EditCluster = 'EditCluster';
sub GetRc {
@@ -88,7 +90,7 @@ sub EditClusterNewRcHeader {
} else {
print $q->h2((GetParam('days', $RcDefault) != 1)
? Ts('Updates in the last %s days', GetParam('days', $RcDefault))
: Ts('Updates in the last %s day', GetParam('days', $RcDefault)))
: Ts('Updates in the last day'))
}
my $action;
my ($idOnly, $userOnly, $hostOnly, $clusterOnly, $filterOnly, $match, $lang) =

View File

@@ -10,7 +10,7 @@
# For user doc, see:
# http://www.oddmuse.org/cgi-bin/oddmuse/Email_Quote_Extension
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/emailquote.pl">emailquote.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Email_Quote_Extension">Email Quote Extension</a></p>';
AddModuleDescription('emailquote.pl', 'Email Quote Extension');
push(@MyRules, \&EmailQuoteRule);

66
modules/emoji.pl Normal file
View File

@@ -0,0 +1,66 @@
# Copyright (C) 2014 Alex Schroeder <alex@gnu.org>
#
# 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 <http://www.gnu.org/licenses/>.
AddModuleDescription('emoji.pl', 'Smilies');
push(@MyRules, \&EmojiRule);
# this must come before tex.pl because of \o/ turning into ø/
$RuleOrder{\&EmojiRule} = 150;
# Some relevant links
# https://en.wikipedia.org/wiki/List_of_emoticons
sub EmojiRule {
if (m/\G:-?D/cg) {
# 😀 1F600 GRINNING FACE
return '&#x1F600;';
} elsif (/\G:[-o]?\)/cg) {
# 😊 1F60A SMILING FACE WITH SMILING EYES
return '&#x1F60A;';
} elsif (/\G\s+:3/cg) {
# 😸 1F638 GRINNING CAT FACE WITH SMILING EYES
return ' &#x1f638;';
} elsif (/\G:-?\(/cg) {
# 😟 1F61F WORRIED FACE
return '&#x1F61F;';
} elsif (/\G;-?\)/cg) {
# 😉 1F609 WINKING FACE
return '&#x1F609;';
} elsif (/\G:'\(/cg) {
# 😢 1F622 CRYING FACE
return '&#x1F622;';
} elsif (/\G&gt;:-?\(/cg) {
# 😠 1F620 ANGRY FACE
return '&#x1F620;';
} elsif (/\G:-?[Ppb]/cg) {
# 😝 1F61D FACE WITH STUCK-OUT TONGUE AND TIGHTLY-CLOSED EYES
return '&#x1F61D;';
} elsif (/\G&lt;3/cg) {
# ❤ 2764 HEAVY BLACK HEART
return '&#x2764;';
} elsif (/\G\^_*\^/cg) {
# 😄 1F604 SMILING FACE WITH OPEN MOUTH AND SMILING EYES
return '&#x1F604;';
} elsif (/\G\b[Oo]_[Oo]\b/cg) {
# 😲 1F632 ASTONISHED FACE
return '&#x1F632;';
} elsif (/\G\\o\//cg) {
# 🙌 1F64C PERSON RAISING BOTH HANDS IN CELEBRATION
return '&#x1F64C;';
} elsif (/\G\\m\//cg) {
# ✊ 270A RAISED FIST
return '&#x270A;';
}
return undef;
}

View File

@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/enclosure.pl">enclosure.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Podcasting">Podcasting</a></p>';
AddModuleDescription('enclosure.pl', 'Podcasting');
use vars qw(@Enclosures);

View File

@@ -23,7 +23,7 @@
# Additionally, lines starting with Q: and A: are rendered using
# the css classes div.question and div.answer.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/faq.pl">faq.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/FAQ_Extension">FAQ Extension</a></p>';
AddModuleDescription('faq.pl', 'FAQ Extension');
$FaqHeaderText = "Questions on this page:" unless $FaqHeaderText;
$FaqQuestionText = "Question: " unless $FaqQuestionText;

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA,
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/fckeditor.pl">fckeditor.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Using_FCKeditor_In_Addition_To_Wiki_Markup">Using FCKeditor In Addition To Wiki Markup</a></p>';
AddModuleDescription('fckeditor.pl', 'Using FCKeditor In Addition To Wiki Markup');
use vars qw($FCKeditorHeight);

View File

@@ -10,7 +10,7 @@
# For user doc, see:
# http://www.oddmuse.org/cgi-bin/oddmuse/Field_List_Extension
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/fieldlist.pl">fieldlist.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Field_List_Extension">Field List Extension</a></p>';
AddModuleDescription('fieldlist.pl', 'Field List Extension');
push(@MyRules, \&FieldListRules);

View File

@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/find.pl">find.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Find_Extension">Find Extension</a></p>';
AddModuleDescription('find.pl', 'Find Extension');
$Action{find} = \&DoFind;

View File

@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/fix-encoding.pl">fix-encoding.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Fix_Encoding">Fix Encoding</a></p>';
AddModuleDescription('fix-encoding.pl', 'Fix Encoding');
$Action{'fix-encoding'} = \&FixEncoding;

View File

@@ -15,7 +15,7 @@ directory of your Oddmuse Wiki.
=cut
package OddMuse;
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/flashbox.pl">flashbox.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Flashbox_Extension">Flashbox Extension</a></p>';
AddModuleDescription('flashbox.pl', 'Flashbox Extension');
# ....................{ CONFIGURATION }....................

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/flickrgallery.pl">flickrgallery.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/FlickrGallery_Module">FlickrGallery Module</a></p>';
AddModuleDescription('flickrgallery.pl', 'FlickrGallery Module');
# NOTE: This API key for Flickr is NOT to be used in any other products
# INCLUDING derivative works. The rest of the code can be used as licensed

View File

@@ -13,7 +13,7 @@ directory for your Oddmuse Wiki.
=cut
package OddMuse;
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/footnotes.pl">footnotes.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Footnotes_Extension">Footnotes Extension</a></p>';
AddModuleDescription('footnotes.pl', 'Footnotes Extension');
# ....................{ CONFIGURATION }....................

106
modules/form_timeout.pl Normal file
View File

@@ -0,0 +1,106 @@
# form_timeout.pl - a form timeout based anti-spam module for Oddmuse
#
# Copyright (C) 2014 Aki Goto <tyatsumi@gmail.com>
#
# Original code is in PHP from http://textcaptcha.com/really
# by Rob Tuley <hello@rob.cx>. Used with permission.
#
# 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 <http://www.gnu.org/licenses/>.
AddModuleDescription('form_timeout.pl');
=head1 DESCRIPTION
This is an anti-spam module for Oddmuse using form timeout method.
Edit permission is timed out in specified duration (default is 30 minutes)
after viewing the edit form. When edit content is posted directly by a spam bot
without viewing the edit form, edit will be denied.
=head1 CONFIGURATION
$FormTimeoutSalt
Mandatory. Token hash salt. Specify arbitrary string.
Default = undef.
$FormTimeoutTimeout
The form timeout in seconds.
Default = 60 * 30 (30 minutes).
=cut
use vars qw($FormTimeoutSalt $FormTimeoutTimeout);
use Digest::MD5 qw(md5_hex);
$FormTimeoutSalt = undef;
$FormTimeoutTimeout = 60 * 30; # 30 minutes
push(@MyInitVariables, \&FormTimeoutInitVariables);
sub FormTimeoutInitVariables {
if (!defined($FormTimeoutSalt)) {
ReportError(T('Set $FormTimeoutSalt.'), '500 INTERNAL SERVER ERROR');
}
}
sub FormTimeoutGetHash {
my ($when) = @_;
return md5_hex($FormTimeoutSalt . $when);
}
sub FormTimeoutGetToken {
return $Now . '#' . FormTimeoutGetHash($Now);
}
sub FormTimeoutGetTime {
my ($token) = @_;
my ($when, $hash) = split /#/, $token;
my $valid_hash = FormTimeoutGetHash($when);
if ($hash ne $valid_hash) {
return '';
}
return $when;
}
sub FormTimeoutCheck {
my $token = GetParam('form_timeout_token', '');
my $when = FormTimeoutGetTime($token);
if ($when eq '' || $when < $Now - $FormTimeoutTimeout) {
return 0;
}
return 1;
}
*OldFormTimeoutGetFormStart = *GetFormStart;
*GetFormStart = *NewFormTimeoutGetFormStart;
sub NewFormTimeoutGetFormStart {
my ($ignore, $method, $class) = @_;
my $form = OldFormTimeoutGetFormStart($ignore, $method, $class);
my $token = FormTimeoutGetToken();
$form .= $q->input({-type=>'hidden', -name=>'form_timeout_token',
-value=>$token});
return $form;
}
*OldFormTimeoutDoEdit = *DoEdit;
*DoEdit = *NewFormTimeoutDoEdit;
sub NewFormTimeoutDoEdit {
my ($id, $newText, $preview) = @_;
if (!FormTimeoutCheck()) {
ReportError(T('Form Timeout'), '403 FORBIDDEN', undef,
$q->p(Ts('Editing not allowed: %s is read-only.', NormalToFree($id))));
}
OldFormTimeoutDoEdit($id, $newText, $preview);
}

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env perl
# ====================[ forms.pl ]====================
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/forms.pl">forms.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Form_Extension">Form Extension</a></p>';
AddModuleDescription('forms.pl', 'Form Extension');
# ....................{ MARKUP }....................
push(@MyRules, \&FormsRule);

View File

@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/fractions.pl">fractions.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Fractions">Fractions</a></p>';
AddModuleDescription('fractions.pl', 'Fractions');
push(@MyRules, \&FractionsRule);

View File

@@ -0,0 +1,398 @@
# GdSecurityImage - a CAPTCHA module for Oddmuse using GD::SecurityImage module
#
# Copyright (C) 2014 Aki Goto <tyatsumi@gmail.com>
#
# Codes reused from MwfCaptcha.pm in mwForum - Web-based discussion forum
# Copyright (c) 1999-2014 Markus Wichitill
#
# Codes reused from questionasker.pl for Oddmuse
# Copyright (C) 2004 Brock Wilcox <awwaiid@thelackthereof.org>
# Copyright (C) 2006, 2007 Alex Schroeder <alex@gnu.org>
#
# 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 <http://www.gnu.org/licenses/>.
AddModuleDescription('gd_security_image.pl');
=head1 DESCRIPTION
This is a CAPTCHA module for Oddmuse using GD::SecurityImage module.
=head1 CONFIGURATION
$GdSecurityImageFont
Mandatory.
Set a TTF font file used for generating CAPTCHA images.
Example: '/usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf'.
$GdSecurityImageRememberAnswer
If 1, once CAPTCHA is answered, the result is cached on cookies
and you need not to re-answer CAPTCHAs for some duration specified
by $GdSecurityImageDuration.
If 0, CAPTCHA is requested everytime you try to submit forms.
Default = 1.
$GdSecurityImageDuration
The duration a CAPTCHA ticket is valid in seconds.
Default = 60 * 10 (10 minutes).
$GdSecurityImageRequiredList
The page name for exceptions, if defined. Every page linked to via
WikiWord or [[free link]] is considered to be a page which needs
questions asked. All other pages do not require questions asked. If
not set, then all pages need questions asked.
%GdSecurityImageProtectedForms
Forms using one of the specified classes are protected.
Default: ('comment' => 1, 'edit upload' => 1, 'edit text' => 1,).
$GdSecurityImageDataDir
When using with Namespaces Extension, specify original root data directory
to concentrate GdSecurityImage data files in it.
Default: $DataDir.
$GdSecurityImageWidth
Default: 250.
$GdSecurityImageHeight
Default: 60.
$GdSecurityImagePtsize
Default: 16.
$GdSecurityImageScramble
Default: 1.
$GdSecurityImageChars
Default: [qw(A B C D E F G H I J K L M O P R S T U V W X Y)].
=head1 API
You can use this module in other modules by using following APIs.
GdSecurityImageGetHtml
returns CAPTCHA HTML form element for embedding in HTML form clause.
GdSecurityImageCheck
returns whether CAPTCHA is answered correctly or not.
=head1 DATA STRUCTURE
Image data and ticket data are stored in $DataDir/gd_security_image directory.
Old data are deleted partially whenever CAPTCHA form is accessed.
You can delete this directory totally harmlessly, although it forces users to
re-answer CAPTCHA.
=cut
use vars qw($GdSecurityImageFont $GdSecurityImageRememberAnswer
$GdSecurityImageDuration $GdSecurityImageRequiredList
%GdSecurityImageProtectedForms $GdSecurityImageDataDir
$GdSecurityImageWidth $GdSecurityImageHeight
$GdSecurityImagePtsize $GdSecurityImageScramble $GdSecurityImageChars
$GdSecurityImageAA);
use vars qw($GdSecurityImageDir $GdSecurityImageId $GdSecurityImagePngToAA);
use Digest::MD5;
use File::Glob ':glob';
$GdSecurityImageRequiredList = '';
$Action{gd_security_image} = \&GdSecurityImageDoImage;
push(@MyInitVariables, \&GdSecurityImageInitVariables);
sub GdSecurityImageGetImageFile {
my ($id) = @_;
return "$GdSecurityImageDir/$id.png";
}
sub GdSecurityImageGetTicketFile {
my ($id) = @_;
return "$GdSecurityImageDir/$id.ticket";
}
sub GdSecurityImageGenerate {
# Load modules
my $gd = eval { require GD };
eval { require Image::Magick }
or ReportError(T('GD or Image::Magick modules not available.'), '500 INTERNAL SERVER ERROR') if !$gd;
eval { require GD::SecurityImage }
or ReportError(T('GD::SecurityImage module not available.'));
# Generate captcha image
GD::SecurityImage->import($gd ? () : (use_magick => 1));
my $img = GD::SecurityImage->new(
width => $GdSecurityImageWidth,
height => $GdSecurityImageHeight,
font => $GdSecurityImageFont,
ptsize => $GdSecurityImagePtsize,
scramble => $GdSecurityImageScramble,
rnd_data => $GdSecurityImageChars,
bgcolor => '#000000',
);
$img->random();
my $newCaptchaStr = $img->random_str();
$img->create('ttf', int(rand(2)) ? 'default' : 'ec', '#ffffff', '#ffffff');
$img->particle(3000);
### experimental ###
#my $raw = $img->raw;
#my $w2 = $GdSecurityImageWidth * 2 / 3;
#my $h2 = $GdSecurityImageHeight * 2 / 3;
#my $raw2 = GD::Image->new($w2, $h2);
#$raw2->copyResampled($raw, 0, 0, 0, 0, $w2, $h2, $raw->getBounds);
#my $png = $raw2->png;
# Store captcha image
my ($imgData) = $img->out(force => 'png');
my $ticketId = Digest::MD5::md5_hex(rand());
CreateDir($GdSecurityImageDir);
my $file = GdSecurityImageGetImageFile($ticketId);
open my $fh, ">:raw", $file
or ReportError(Ts('Image storing failed. (%s)', $!), '500 INTERNAL SERVER ERROR');
print $fh $imgData;
#print $fh $png; ### experimental ###
close $fh;
# Insert captcha ticket
my %page = ();
$page{id} = $ticketId;
$page{generation_time} = $Now;
$page{string} = $newCaptchaStr;
CreateDir($GdSecurityImageDir);
WriteStringToFile(GdSecurityImageGetTicketFile($ticketId), EncodePage(%page));
return $ticketId;
}
sub GdSecurityImageIsValidId {
my ($id) = @_;
return $id =~ /^[0-9a-f]+$/;
}
sub GdSecurityImageReadImageFile {
my $file = shift;
utf8::encode($file); # filenames are bytes!
if (open(IN, '<:raw', $file)) {
local $/ = undef; # Read complete files
my $data=<IN>;
close IN;
return (1, $data);
}
return (0, '');
}
sub GdSecurityImageDoImage {
my $id = GetParam('gd_security_image_id', '');
if (!GdSecurityImageIsValidId($id)) {
ReportError(T('Bad gd_security_image_id.'), '400 BAD REQUEST');
}
my ($status, $data) = GdSecurityImageReadImageFile(GdSecurityImageGetImageFile($id));
binmode(STDOUT, ":raw");
print $q->header(-type=>'image/png');
print $data;
unlink(GdSecurityImageGetImageFile($id));
}
sub GdSecurityImageCleanup {
my ($id) = @_;
if (!GdSecurityImageIsValidId($id)) {
return;
}
my @files = (bsd_glob("$GdSecurityImageDir/*.png"), bsd_glob("$GdSecurityImageDir/*.ticket"));
foreach my $file (@files) {
if ($Now - (stat $file)[9] > $GdSecurityImageDuration) {
unlink($file);
}
}
}
sub GdSecurityImageCheck {
if (defined($GdSecurityImageId)) {
return $GdSecurityImageId eq '';
}
my $id = GetParam('gd_security_image_id', '');
my $answer = GetParam('gd_security_image_answer', '');
GdSecurityImageCleanup($id);
if ($answer ne '' && GdSecurityImageIsValidId($id)) {
my ($status, $data) = ReadFile(GdSecurityImageGetTicketFile($id));
if ($status) {
my %page = ParseData($data);
if ($page{generation_time} + $GdSecurityImageDuration > $Now) {
if ($answer eq $page{string}) {
$GdSecurityImageId = '';
if (!$GdSecurityImageRememberAnswer) {
SetParam('gd_security_image_id', '');
SetParam('gd_security_image_answer', '');
}
return 1;
}
}
}
}
if (GdSecurityImageIsValidId($id)) {
unlink(GdSecurityImageGetTicketFile($id));
}
$GdSecurityImageId = GdSecurityImageGenerate();
return 0;
}
sub GdSecurityImageGetHtml {
if (GdSecurityImageCheck()) {
return '';
}
my $form = '';
SetParam('gd_security_image_answer', '');
$form .= $q->start_div({-class=>'gd_security_image'});
$form .= $q->start_div();
$form .= T('Please type the six characters from the anti-spam image');
$form .= $q->end_div();
$form .= $q->start_div();
$form .= $q->input({-type=>'hidden', -name=>'gd_security_image_id', -value=>$GdSecurityImageId});
$form .= $q->textfield(-name=>'gd_security_image_answer', -id=>'gd_security_image_answer');
$form .= $q->submit(-name=>'Submit', -value=>T('Submit'));
$form .= $q->end_div();
$form .= $q->start_div();
$form .= $q->img({-src=>"$FullUrl?action=gd_security_image&gd_security_image_id=$GdSecurityImageId", -alt=>T('CAPTCHA'), -width=>$GdSecurityImageWidth, -height=>$GdSecurityImageHeight});
$form .= $q->end_div();
if ($GdSecurityImageAA) {
$form .= $q->start_div({class=>'aa_captcha'});
$form .= $q->start_pre();
my $png_file = GdSecurityImageGetImageFile($GdSecurityImageId);
$form .= `$GdSecurityImagePngToAA $png_file`;
$form .= $q->end_pre();
$form .= $q->end_div();
}
$form .= $q->end_div();
return $form;
}
*OldGdSecurityImageDoPost = *DoPost;
*DoPost = *NewGdSecurityImageDoPost;
sub NewGdSecurityImageDoPost {
my(@params) = @_;
my $id = FreeToNormal(GetParam('title', undef));
my $preview = GetParam('Preview', undef); # case matters!
unless (UserIsEditor()
or $preview
or GdSecurityImageCheck()
or GdSecurityImageException($id)) {
print GetHeader('', T('Edit Denied'), undef, undef, '403 FORBIDDEN');
print $q->p(T('You did not answer correctly.'));
print GetFormStart(), GdSecurityImageGetHtml(),
(map { $q->input({-type=>'hidden', -name=>$_, -value=>UnquoteHtml(GetParam($_))}) }
qw(title text oldtime summary recent_edit aftertext)), $q->end_form;
PrintFooter();
# logging to the error log file of the server
# warn "Q: '$QuestionaskerQuestions[$question_num][0]', A: '$answer'\n";
return;
}
return (OldGdSecurityImageDoPost(@params));
}
*OldGdSecurityImageGetEditForm = *GetEditForm;
*GetEditForm = *NewGdSecurityImageGetEditForm;
sub NewGdSecurityImageGetEditForm {
return GdSecurityImageAddTo(OldGdSecurityImageGetEditForm(@_));
}
*OldGdSecurityImageGetCommentForm = *GetCommentForm;
*GetCommentForm = *NewGdSecurityImageGetCommentForm;
sub NewGdSecurityImageGetCommentForm {
return GdSecurityImageAddTo(OldGdSecurityImageGetCommentForm(@_));
}
sub GdSecurityImageAddTo {
my $form = shift;
if (not $upload
and not GdSecurityImageException(GetId())
and not UserIsEditor()) {
my $question = GdSecurityImageGetHtml();
$form =~ s/(.*)<p>(.*?)<label for="username">/$1$question<p>$2<label for="username">/;
}
return $form;
}
sub GdSecurityImageException {
my $id = shift;
return 0 unless $GdSecurityImageRequiredList and $id;
my $data = GetPageContent($GdSecurityImageRequiredList);
if ($WikiLinks) {
while ($data =~ /$LinkPattern/g) {
return 0 if FreeToNormal($1) eq $id;
}
}
if ($FreeLinks) {
while ($data =~ /\[\[$FreeLinkPattern\]\]/g) {
return 0 if FreeToNormal($1) eq $id;
}
}
return 1;
}
sub GdSecurityImageInitVariables {
ReportError(T('$GdSecurityImageFont is not set.'), '500 INTERNAL SERVER ERROR') unless defined $GdSecurityImageFont;
$GdSecurityImageRememberAnswer = 1 unless defined $GdSecurityImageRememberAnswer;
$GdSecurityImageDuration = 60 * 10 unless defined $GdSecurityImageDuration;
$GdSecurityImageRequiredList = FreeToNormal($GdSecurityImageRequiredList);
# Forms using one of the following classes are protected.
%GdSecurityImageProtectedForms = ('comment' => 1,
'edit upload' => 1,
'edit text' => 1,)
unless defined %GdSecurityImageProtectedForms;
$GdSecurityImageDataDir = $DataDir unless defined $GdSecurityImageDataDir;
$GdSecurityImageWidth = 240 unless defined $GdSecurityImageWidth;
$GdSecurityImageHeight = 75 unless defined $GdSecurityImageHeight;
$GdSecurityImagePtsize = 16.75 unless defined $GdSecurityImagePtsize;
$GdSecurityImageScramble = 1 unless defined $GdSecurityImageScramble;
$GdSecurityImageChars = [qw(A B C D E F G H I J K L M O P R S T U V W X Y)] unless defined $GdSecurityImageChars;
$GdSecurityImageAA = 0 unless defined $GdSecurityImageAA;
$GdSecurityImageDir = "$GdSecurityImageDataDir/gd_security_image";
$GdSecurityImageId = undef;
$GdSecurityImagePngToAA = "$ModuleDir/pngtoaa";
$CookieParameters{'gd_security_image_id'} = '';
$InvisibleCookieParameters{'gd_security_image_id'} = 1;
$CookieParameters{'gd_security_image_answer'} = '';
$InvisibleCookieParameters{'gd_security_image_answer'} = 1;
}

72
modules/git-another.pl Normal file
View File

@@ -0,0 +1,72 @@
# Copyright (C) 2014 Alex-Daniel Jakimenko <alex.jakimenko@gmail.com>
# Copyright (C) 2011 Alex Schroeder <alex@gnu.org>
# 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 <http://www.gnu.org/licenses/>.
package OddMuse;
AddModuleDescription('git-another.pl', 'Another Git Extension');
use Cwd;
use Capture::Tiny ':all';
use vars qw($GitBinary $GitMail);
$GitBinary = 'git';
$GitMail = 'unknown@oddmuse.org';
sub GitCommit {
my ($message, $author) = @_;
my $oldDir = cwd;
chdir("$DataDir/page");
capture {
system($GitBinary, qw(add -A));
system($GitBinary, qw(commit -q -m), $message, "--author=$author <$GitMail>");
};
chdir($oldDir);
}
sub GitInitRepository {
return if -d "$DataDir/page/.git";
capture {
system($GitBinary, qw(init -q --), "$DataDir/page");
};
GitCommit('Initial import', 'Oddmuse');
}
sub RenderHtmlCacheWithoutPrinting { # requires an open page
$FootnoteNumber = 0;
my $blocks, $flags;
capture {
($blocks, $flags) = ApplyRules(QuoteHtml($Page{text}), 1, 1, $Page{revision}, 'p');
};
if ($Page{blocks} ne $blocks and $Page{flags} ne $flags) {
$Page{blocks} = $blocks;
$Page{flags} = $flags;
SavePage();
}
}
*GitOldSave = *Save;
*Save = *GitNewSave;
sub GitNewSave {
GitInitRepository();
GitCommit('No description available', 'Oddmuse'); # commit any changes before this edit
GitOldSave(@_);
RenderHtmlCacheWithoutPrinting();
my $message = $Page{summary};
$message =~ s/^\s+$//;
$message ||= T('No summary provided');
my $author = $Page{username} || T('Anonymous');
GitCommit($message, $author); # commit this edit
}

View File

@@ -31,7 +31,7 @@ Set these variables in the B<config> file within your data directory.
=head2 $GitBinary
Default: C</usr/bin/git>
Default: C<git>
The fully qualified name for the binary to run. Your PATH will not be searched.
@@ -48,31 +48,56 @@ Default: C<unknown@oddmuse.org>
The email address used to identify users in git.
=head2 $GitDebug
Default: 0
If set, we capture the output of the git command and store it in
$GitResult. This is useful when writing tests.
=head2 $GitResult
If $GitDebug is set, this variable holds STDOUT of the git command.
=cut
use vars qw($GitBinary $GitRepo $GitMail);
use Cwd;
use File::Temp ();
use vars qw($GitBinary $GitRepo $GitMail $GitPageFile $GitDebug $GitResult);
$GitBinary = '/usr/bin/git';
AddModuleDescription('git.pl', 'Git Extension');
$GitBinary = 'git';
$GitMail = 'unknown@oddmuse.org';
$GitPageFile = 0;
push(@MyInitVariables, \&GitInitVariables);
sub GitRun {
my $result = '';
local *STDOUT;
open(STDOUT, '>', \$result) or die "Can't open memory file: $!";
system($GitBinary, @_) == 0
or ReportError("git failed: $!",
"500 INTERNAL SERVER ERROR",
undef,
$q->p($q->tt(join(' ', $GitBinary, map {
if (index($_, ' ') == -1) {
$_;
} else {
"'$_'";
}
} @_))),
$q->pre($result));
my $oldDir = cwd;
my $exitStatus;
# warn join(' ', $GitBinary, @_) . "\n";
chdir($GitRepo);
if ($GitDebug) {
# capture the output of the git comand in a temporary file
my $fh = File::Temp->new();
open(my $oldout, ">&STDOUT") or die "Can't dup STDOUT: $!";
open(STDOUT, '>', $fh) or die "Can't redirect STDOUT: $!";
# run git in the work directory
$exitStatus = system($GitBinary, @_);
# read the temporary file with the output
close($fh);
open(STDOUT, ">&", $oldout) or die "Can't dup \$oldout: $!";
open(F, '<', $fh) or die "Can't open temp file for reading: $!";
local $/ = undef; # Read complete files
$GitResult = <F>;
close(F);
} else {
$exitStatus = system($GitBinary, @_);
}
chdir($oldDir);
return $exitStatus;
}
sub GitInitVariables {
@@ -80,39 +105,50 @@ sub GitInitVariables {
}
sub GitInitRepository {
if (not -d "$GitRepo/.git") {
CreateDir($GitRepo);
chdir($GitRepo); # important for all the git commands that follow!
GitRun('init', '--quiet');
foreach my $id (AllPagesList()) {
OpenPage($id);
WriteStringToFile("$GitRepo/$id", $Page{text});
GitRun('add', $id);
}
GitRun('commit', '--quiet', '-m', 'initial import',
"--author=Oddmuse <$GitMail>");
} else {
chdir($GitRepo); # important for all the git commands that follow!
return if -d "$GitRepo/.git";
my $exception = shift;
CreateDir($GitRepo);
GitRun(qw(init --quiet));
# Add legacy pages: If you installed this extension for an older
# wiki, all the existing pages need to be added. We do this for all
# the pages except for the one we just saved. That page will get a
# better author and log message.
foreach my $id (AllPagesList()) {
next if $id eq $exception;
OpenPage($id);
WriteStringToFile("$GitRepo/$id", $GitPageFile ? EncodePage(%Page) : $Page{text});
GitRun(qw(add --), $id);
}
GitRun(qw(commit --quiet -m), 'initial import', "--author=Oddmuse <$GitMail>");
}
*GitOldSave = *Save;
*Save = *GitNewSave;
sub GitNewSave {
# Save is called within lock, with opened page. That's why we cannot
# call GitInitRepository right away, because it opens all the legacy
# pages to save them, too. We need to save first.
GitOldSave(@_);
GitInitRepository();
my ($id) = @_;
WriteStringToFile("$GitRepo/$id", $Page{text});
if ($Page{revision} == 1) {
GitRun('add', $id);
}
# We also need to save all the data from the open page.
my $message = $Page{summary};
$message =~ s/^\s+$//;
$message ||= T('no summary available');
my $author = $Page{username} || T('Anonymous');
GitRun('commit', '--quiet', '-m', $message,
"--author=$author <$GitMail>", $id);
my $data = $GitPageFile ? EncodePage(%Page) : $Page{text};
my $id = shift;
# GitInitRepository will try to add and commit all the pages already
# in the wiki. These are assumed to be legacy pages. The page we
# just saved, however, should not be committed as a legacy page
# because legacy pages are committed with a default author and log
# message!
GitInitRepository($id);
WriteStringToFile("$GitRepo/$id", $data);
GitRun(qw(add --), $id);
GitRun(qw(commit --quiet -m), $message,
"--author=$author <$GitMail>", '--', $id);
}
*GitOldDeletePage = *DeletePage;
@@ -123,11 +159,11 @@ sub GitNewDeletePage {
return $error if $error;
GitInitRepository();
my ($id) = @_;
GitRun('rm', '--quiet', '--ignore-unmatch', $id);
GitRun(qw(rm --quiet --ignore-unmatch --), $id);
my $message = T('page was marked for deletion');
my $author = T('Oddmuse');
GitRun('commit', '--quiet', '-m', $message,
"--author=$author <$GitMail>", $id);
GitRun(qw(commit --quiet -m), $message,
"--author=$author <$GitMail>", '--', $id);
return ''; # no error
}
@@ -140,8 +176,7 @@ sub DoGitCleanup {
print GetHeader('', 'Git', '');
print $q->start_div({-class=>'content git'});
RequestLockOrError();
print $q->p(T('Main lock obtained.')), '<p>',
T('Cleaning up git repository');
print $q->p(T('Main lock obtained.')), '<p>', T('Cleaning up git repository');
GitCleanup();
ReleaseLock();
print $q->p(T('Main lock released.')), $q->end_div();
@@ -150,7 +185,7 @@ sub DoGitCleanup {
sub GitCleanup {
if (-d $GitRepo) {
print $q->p("Git cleanup starting");
print $q->p('Git cleanup starting');
AllPagesList();
# delete all the files including all the files starting with a dot
opendir(DIR, $GitRepo) or ReportError("cannot open directory $GitRepo: $!");
@@ -163,20 +198,20 @@ sub GitCleanup {
}
closedir DIR;
# write all the files again, just to be sure
print $q->p("Rewriting all the files, just to be sure");
print $q->p('Rewriting all the files, just to be sure');
foreach my $id (@IndexList) {
OpenPage($id);
WriteStringToFile("$GitRepo/$id", $Page{text});
WriteStringToFile("$GitRepo/$id", $GitPageFile ? EncodePage(%Page) : $Page{text});
}
# run git!
chdir($GitRepo); # important for all the git commands that follow!
# add any new files
print $q->p("Adding new files, if any");
GitRun('add', '.');
print $q->p('Adding new files, if any');
GitRun(qw(add -A));
# commit the new state
print $q->p("Committing changes, if any");
# try to protect against mysterious crashes
print $q->pre(`$GitBinary commit --quiet -a -m 'maintenance job' --author=Oddmuse <$GitMail>` . ' ');
print $q->p("Git done");
print $q->p('Committing changes, if any');
my $exitStatus = GitRun(qw(commit --quiet -m), 'maintenance job',
"--author=Oddmuse <$GitMail>");
print $q->p('git commit finished with ' . $exitStatus . ' exit status.');
print $q->p('Git done');
}
}

View File

@@ -20,7 +20,7 @@ use vars qw($GoogleCustomSearchEngine);
$GoogleCustomSearchEngine = 'http://www.google.com/cse?cx=004774160799092323420:6-ff2s0o6yi&q=';
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/google-custom-search.pl">google-custom-search.pl</a></p>';
AddModuleDescription('google-custom-search.pl');
# disable search form
sub GetSearchForm {}

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/google-search.pl">google-search.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Use_Google_For_Searches">Use Google For Searches</a></p>';
AddModuleDescription('google-search.pl', 'Use Google For Searches');
use vars qw($GoogleSearchDomain $GoogleSearchExclusive);

View File

@@ -1,22 +1,18 @@
# Copyright (C) 2006 Alex Schroeder <alex@emacswiki.org>
# Copyright (C) 2006-2014 Alex Schroeder <alex@gnu.org>
#
# 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 2 of the License, or
# (at your option) any later version.
# 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.
# 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, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/gotobar.pl">gotobar.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Gotobar_Extension">Gotobar Extension</a></p>';
AddModuleDescription('gotobar.pl', 'Gotobar Extension');
use vars qw($GotobarName);
@@ -32,18 +28,20 @@ sub GotobarInit {
$AdminPages{$GotobarName} = 1;
if ($IndexHash{$GotobarName}) {
OpenPage($GotobarName);
return if $DeletedPage && $Page{text} =~ /^\s*$DeletedPage\b/o;
return if PageMarkedForDeletion();
# Don't use @UserGotoBarPages because this messes up the order of
# links for unsuspecting users.
@UserGotoBarPages = ();
$UserGotoBar = '';
my $count = 0;
while ($Page{text} =~ m/($LinkPattern|\[\[$FreeLinkPattern\]\]|\[\[$FreeLinkPattern\|([^\]]+)\]\]|\[$InterLinkPattern\s+([^\]]+?)\])/og) {
my $page = $2||$3||$4||$6;
my $text = $5||$7;
while ($Page{text} =~ m/($LinkPattern|\[\[$FreeLinkPattern\]\]|\[\[$FreeLinkPattern\|([^\]]+)\]\]|\[$InterLinkPattern\s+([^\]]+?)\]|\[$FullUrlPattern[|[:space:]]([^\]]+?)\])/og) {
my $page = $2||$3||$4||$6||$8;
my $text = $5||$7||$9;
$UserGotoBar .= ' ' if $UserGotoBar;
if ($6) {
$UserGotoBar .= GetInterLink($page, $text);
} elsif ($8) {
$UserGotoBar .= GetUrl($page, $text);
} else {
$UserGotoBar .= GetPageLink($page, $text);
# The first local page is the homepage, the second local page
@@ -58,4 +56,3 @@ sub GotobarInit {
}
}
}

View File

@@ -12,7 +12,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/gravatar.pl">gravatar.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Gravatar">Gravatar</a></p>';
AddModuleDescription('gravatar.pl', 'Gravatar');
use Digest::MD5 qw(md5_hex);
@@ -26,7 +26,7 @@ push(@MyRules, \&GravatarRule);
sub GravatarRule {
if ($bol && m!\G$gravatar_regexp!cog) {
my $url = $1;
my $gravatar = "http://www.gravatar.com/avatar/$3";
my $gravatar = "https://secure.gravatar.com/avatar/$3";
my $name = FreeToNormal($2);
$url = ScriptUrl($name) unless $url;
return $q->span({-class=>"portrait gravatar"},

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/grep.pl">grep.pl</a></p>';
AddModuleDescription('grep.pl');
push(@MyRules, \&GrepRule);

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/header-and-footer-templates.pl">header-and-footer-templates.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Comments_on_HTML_Templates">Comments on HTML Templates</a></p>';
AddModuleDescription('header-and-footer-templates.pl', 'Comments on HTML Templates');
use vars qw($HtmlTemplateDir);
use HTML::Template;

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/headers.pl">headers.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Header_Markup_Extension">Header Markup Extension</a></p>';
AddModuleDescription('headers.pl', 'Header Markup Extension');
# After toc.pl but before usemod.pl
push(@MyRules, \&HeadersRule);

View File

@@ -19,7 +19,7 @@
use vars qw($HeadlineNumber);
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/headlines.pl">headlines.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Headlines_Extension">Headlines Extension</a></p>';
AddModuleDescription('headlines.pl', 'Headlines Extension');
push(@MyRules, \&HeadlinesRule);

2
modules/hibernal.pl Executable file → Normal file
View File

@@ -45,7 +45,7 @@ for posts having such a subtitle.
# "David_Curry".
package OddMuse;
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/hibernal.pl">hibernal.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Hibernal_Extension">Hibernal Extension</a></p>';
AddModuleDescription('hibernal.pl', 'Hibernal Extension');
# ....................{ CONFIGURATION }....................

View File

@@ -23,7 +23,7 @@
# on a pattern matching the page id or to a membership to a certain
# page cluster.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/hiddenpages.pl">hiddenpages.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Hidden_Pages_Extension">Hidden Pages Extension</a></p>';
AddModuleDescription('hiddenpages.pl', 'Hidden Pages Extension');
use vars qw($HiddenCluster $HideEditorPages $HideAdminPages
$HideRegExEditor $HideRegExAdmin);

View File

@@ -22,7 +22,7 @@ automatically.
=cut
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/honeypot.pl">honeypot.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Comments_on_Monitor_Extension">Comments on Monitor Extension</a></p>';
AddModuleDescription('honeypot.pl', 'Comments on Monitor Extension');
=head1 CONFIGURATION

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/html-template.pl">html-template.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/HTML_Templates">HTML Templates</a></p>';
AddModuleDescription('html-template.pl', 'HTML Templates');
# The entire mechanism of how pages are built is now upside down.
# Instead of writing code that assembles pages, we load templates,

View File

@@ -16,7 +16,7 @@
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/html-uploads.pl">html-uploads.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Restricted_HTML_Upload">Restricted HTML Upload</a></p>';
AddModuleDescription('html-uploads.pl', 'Restricted HTML Upload');
$Action{download} = \&HtmlUploadsDoDownload;

View File

@@ -10,7 +10,7 @@
# For user doc, see:
# http://www.oddmuse.org/cgi-bin/oddmuse/Html_Comment_Extension
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/htmlcomment.pl">htmlcomment.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Html_Comment_Extension">Html Comment Extension</a></p>';
AddModuleDescription('htmlcomment.pl', 'Html Comment Extension');
push(@MyRules, \&HtmlCommentRules);

Some files were not shown because too many files have changed in this diff Show More