Skip to content

Commit

Permalink
Merge branch 'master' into new-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
cintek committed Nov 7, 2023
2 parents 18d8d9b + e787e8f commit 09ed207
Show file tree
Hide file tree
Showing 44 changed files with 1,134 additions and 1,550 deletions.
9 changes: 1 addition & 8 deletions docs/admin/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,6 @@ For MoinMoin we require the following XStatic Packages in setup.py:
is loaded at template modify_svg-edit. It is a fast, web-based, Javascript-driven
SVG editor.

* `twikidraw_moin <https://pypi.org/project/XStatic-TWikiDraw-moin>`_
a Java applet loaded from template file of modify_twikidraw. It is a simple drawing editor.

* `anywikidraw <https://pypi.org/project/XStatic-AnyWikiDraw>`_
a Java applet loaded from template file of modify_anywikidraw. It can be used for
editing drawings and diagrams on items.

* `jquery_tablesorter <https://pypi.org/project/XStatic-JQuery.TableSorter/2.14.5.1>`_
used to provide client side table sorting.

Expand All @@ -444,7 +437,7 @@ These packages are imported in wikiconfig by::
'font_awesome',
'ckeditor',
'autosize',
'svgedit_moin', 'twikidraw_moin', 'anywikidraw',
'svgedit_moin',
'jquery_tablesorter',
'pygments',
]
Expand Down
7 changes: 5 additions & 2 deletions docs/admin/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,11 @@ then you will likely want to keep your master branch up-to-date:
git pull # if you cloned the moinwiki master repo OR
git pull moinwiki master # if you cloned your fork and added a remote

After pulling updates, it is best to also rerun the quickinstall process
to install any changes or new releases of the dependent packages:
Also check to see if there are changes to /src/moin/config/wikiconfig.py
by comparing a diff to the wikiconfig.py in the wiki root.

After pulling updates and updating wikiconfig.py, rerun the quickinstall
process to install any new releases of dependent packages:

::

Expand Down
10 changes: 3 additions & 7 deletions docs/admin/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ moin2 installation process. For a list of dependencies, see setup.py.

Clients
=======
On the client side, you need:
On the client side, you need a web browser that supports W3C standards HTML 5, CSS 2.1, and JavaScript:

* a web browser that supports W3C standards HTML 5, CSS 2.1, and JavaScript:

- any current version of Firefox, Chrome, Opera, Safari, Maxthon, Internet Explorer (IE9 or newer).
- use of older Internet Explorer versions is not recommended and not supported.

* a Java browser plugin is required only if you want to use the TWikiDraw or AnyWikiDraw drawing applets.
* any current version of Firefox, Chrome, Opera, Safari, Maxthon, Internet Explorer (IE9 or newer).
* use of older Internet Explorer versions is not recommended and not supported.
2 changes: 1 addition & 1 deletion docs/admin/serve.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ The following three commands are equivalent as the
specified options are the defaults. ::

moin dump-html
moin dump-html --directoy HTML --theme topside_cms --exclude-ns userprofiles --query .*
moin dump-html --directory HTML --theme topside_cms --exclude-ns userprofiles --query .*
moin dump-html -d HTML -t topside_cms -e userprofiles -q .*

The --directory option may be a relative or absolute path. The default directory,
Expand Down
53 changes: 47 additions & 6 deletions docs/devel/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ moin2 is a WSGI application and uses:
* for stores: filesystem, sqlite3, sqlalchemy, memory
* jquery javascript lib, a simple jQuery i18n plugin `Plugin <https://github.com/recurser/jquery-i18n>`_
* CKeditor, the GUI editor for (x)html
* TWikiDraw, AnyWikiDraw, svgdraw drawing tools
* svgdraw as drawing tool

How MoinMoin works
==================
Expand Down Expand Up @@ -470,17 +470,58 @@ Note the test starup will be rather slow, be patient.

Documentation
=============
Sphinx (https://www.sphinx-doc.org) and reST markup are used for documenting
moin. Documentation reST source code, example files and some other text files
are located in the `docs/` directory in the source tree.
Moin provides two types of documention. The Sphinx docs (https://www.sphinx-doc.org)
are written in reST markup, and have a target audience of developers and wiki admins.
The Help docs have a target audience of wiki editors and are written in markups supported by moin.

Creating docs
-------------
The Help docs are a minor subset of the Sphinx docs
and may be available in several languages. The Sphinx docs are available only in English.

Sphinx docs are available at https://moin-20.readthedocs.io/en/latest/ or
may be created locally on Moin wiki's installed by developers.
Documentation reST source code, example files and some other text files
are located in the `moin/docs/` directory in the source tree.

Creating local Sphinx docs
--------------------------
Sphinx can create all kinds of documentation formats. The most common are
the local HTML docs that are linked to under the User tab. To generate local docs::

./m docs # Windows: m docs

Loading the Help docs
---------------------
Wiki admins must load the help docs to make them available to editors. Help docs are
located in the `moin/src/moin/help/` directory in the source tree. Most themes
will provide a link to the markup help above the edit textarea or the entire help namespace
may be accessed through the User tab. Write permission to help files is granted by default.
Wiki admins can change permissions via the ACL rules.

To load the help docs::

moin load-help --namespace common # images common to all languages
moin load-help --namespace en # English text

Multiple languages may be loaded. Current languages include::

en

Updating the Help docs
----------------------
Developers may update the help files or add new files through the normal edit process.
When editing is complete run one or more of::

moin maint-reduce-revisions # updates all items in all namespaces
moin maint-reduce-revisions -q <item-name> -n help-en --test true # lists selected items, no updates
moin maint-reduce-revisions -q <item-name> -n help-en # updates selected items

Dump all the help files::

moin dump-help -n en

The above command may update meta files even though the data files have not changed, see #1533.
Commit only the target data and meta files. Revert the other meta files.

Moin Shell
==========

Expand Down
12 changes: 6 additions & 6 deletions docs/user/markdown.rst
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,11 @@ As shown in the second table below, use of outside borders and neat alignment of

**Markup**: ::

|Tables |Are |Very |Cool |
|------------------|:-------------:|-----:|:-------|
|col 2 is |centered |$12 |Gloves |
|col 3 is |right-aligned |$1600 |Necklace|
|col 4 is |left-aligned |$100 |Hat |
| Tables |Are |Very |Cool |
|-------------------|:-------------:|-----:|:-------|
| col 2 is |centered |$12 |Gloves |
| col 3 is |right-aligned |$1600 |Necklace|
| col 4 is |left-aligned |$100 |Hat |

`Tables` |*Are* |Very |Cool
------------|:-------------:|-----:|:-------
Expand Down Expand Up @@ -565,7 +565,7 @@ As shown in the second table below, use of outside borders and neat alignment of
================== ================= ======== ==========


**reST NOTE**: reST does not support cell alignment.
**reST NOTE**: reST does not support cell alignment, therefore the last example shown above does not reflect the resulting alignment.

Syntax Highlighting of Preformatted Code
----------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions scripts/coding_std.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# Copyright: 2012-2018 by MoinMoin:RogerHaase
# Copyright: 2012-2018 MoinMoin:RogerHaase
# Copyright: 2023 MoinMoin project
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
Expand Down Expand Up @@ -306,7 +307,7 @@ def check_js_phrases(lines, filename):
Print error message if not defined in phrases, else add phrase to used phrases set.
"""
global phrases_used
if filename.endswith('jquery.i18n.min.js'):
if filename.endswith('jquery.i18n.min.js') or filename.endswith('dictionary.js'):
return
pattern = re.compile(r"""_\("([\w\s\d~`@#$%^&*()+=:;'<,>.?/!-?]+)"\)""")
bad_pat = re.compile(r"""_\(([\w\s\d~`@#$%^&*()+=:;'<,>.?/!-?]+)\)""")
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright: 2001 by Juergen Hermann <[email protected]>
# Copyright: 2011 MoinMoin:ThomasWaldmann
# Copyright: 2023 MoinMoin project
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

# MoinMoin - Distutils config
Expand Down Expand Up @@ -28,6 +29,7 @@ output_file = src/moin/translations/MoinMoin.pot
keywords = _ gettext L_ lazy_gettext N_ ngettext
msgid_bugs_address = English <[email protected]>
copyright_holder = Moin Core Team, see http://moinmo.in/MoinCoreTeamGroup
width = 116

[init_catalog]
input_file = src/moin/translations/MoinMoin.pot
Expand All @@ -36,6 +38,7 @@ output_dir = src/moin/translations/
[update_catalog]
input_file = src/moin/translations/MoinMoin.pot
output_dir = src/moin/translations/
width = 116

[compile_catalog]
directory = src/moin/translations/
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
'Jinja2>=3.1.0', # template engine
'markupsafe<=2.2.0', # safe html and xml
'pygments>=1.4', # src code / text file highlighting
'Werkzeug<2.4.0', # wsgi toolkit
'Werkzeug', # wsgi toolkit
'whoosh>=2.7.0', # needed for indexed search
'pdfminer.six', # pdf -> text/plain conversion
'passlib>=1.6.0', # strong password hashing (1.6 needed for consteq)
Expand All @@ -100,8 +100,6 @@
'XStatic-autosize',
'XStatic-jQuery>=1.8.2',
'XStatic-jQuery-File-Upload>=10.31.0',
'XStatic-TWikiDraw-moin>=2004.10.23.2',
'XStatic-AnyWikiDraw>=0.14.2',
'XStatic-svg-edit-moin>=2012.11.15.1',
'XStatic-JQuery.TableSorter>=2.14.5.1',
'XStatic-Pygments>=1.6.0.1',
Expand Down
2 changes: 1 addition & 1 deletion src/moin/_tests/test_wikiutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def testParentItemName():
def testdrawing2fname():
# with extension not in DRAWING_EXTENSIONS
result = wikiutil.drawing2fname('Moin_drawing.txt')
expected = 'Moin_drawing.txt.tdraw'
expected = 'Moin_drawing.txt.svgdraw'
assert result == expected
# with extension in DRAWING_EXTENSIONS
result = wikiutil.drawing2fname('Moindir.Moin_drawing.jpg')
Expand Down
8 changes: 5 additions & 3 deletions src/moin/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright: MoinMoin:FrankieChow, MoinMoin:NirSoffer
# Copyright: 2005-2012 MoinMoin:ThomasWaldmann
# Copyright: 2007 MoinMoin:JohannesBerg
# Copyright: 2023 MoinMoin project
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
Expand Down Expand Up @@ -133,9 +134,10 @@
name of the authentication method.
"""

from urllib.parse import quote, quote_plus
from werkzeug.exceptions import abort
from werkzeug.urls import url_quote, url_quote_plus
from werkzeug.utils import redirect

from flask import url_for, session, request
from flask import g as flaskg
from flask import current_app as app
Expand Down Expand Up @@ -411,8 +413,8 @@ def handle_login(userobj, **kw):
if ret.redirect_to:
nextstage = get_multistage_continuation_url(authmethod.name)
url = ret.redirect_to
url = url.replace('%return_form', url_quote_plus(nextstage))
url = url.replace('%return', url_quote(nextstage))
url = url.replace('%return_form', quote_plus(nextstage))
url = url.replace('%return', quote(nextstage))
abort(redirect(url))
msg = ret.message
if msg and msg not in flaskg._login_messages:
Expand Down
84 changes: 50 additions & 34 deletions src/moin/cli/maint/reduce_revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
from flask import current_app as app
from flask.cli import FlaskGroup

from whoosh.query import Every, Term, And, Regex
from whoosh.query import Term, And, Regex, Not

from moin.constants.keys import NAME, NAME_EXACT, REVID, WIKINAME, PARENTID, REV_NUMBER
from moin.constants.keys import NAME, NAME_EXACT, NAMESPACE, REVID, WIKINAME, PARENTID, REV_NUMBER
from moin.constants.namespaces import NAMESPACE_USERPROFILES
from moin.app import create_app, before_wiki

from moin import log
Expand All @@ -31,46 +32,61 @@ def cli():


@cli.command("maint-reduce-revisions",
help="Remove all revisions but the last one from all selected items")
help="Remove all revisions but the last one from all selected items.")
@click.option('--query', '-q', type=str, default='',
help='Only perform the operation on items found by the given query.')
def ReduceRevisions(query):
@click.option('--namespace', '-n', type=str, default='',
help='Limit selection to this namespace.')
@click.option('--test', '-t', type=bool, default=0,
help='List selected items, but do not update.')
def ReduceRevisions(query, namespace, test):
logging.info("Reduce revisions started")
before_wiki()
if query:
q = And([Term(WIKINAME, app.cfg.interwikiname), Regex(NAME_EXACT, query)])
q = And([Term(WIKINAME, app.cfg.interwikiname), Not(Term(NAMESPACE, NAMESPACE_USERPROFILES))])
if query or namespace:
if query:
q = And([q, Regex(NAME_EXACT, query)])
if namespace:
q = And([q, Regex(NAMESPACE, namespace)])
else:
q = Every()
q = Not(Term(NAMESPACE, NAMESPACE_USERPROFILES))

for current_rev in app.storage.search(q, limit=None):
current_name = current_rev.meta[NAME]
current_revid = current_rev.meta[REVID]
print("Destroying historical revisions of {0!r}:".format(current_name))
has_historical_revision = False
for rev in current_rev.item.iter_revs():
revid = rev.meta[REVID]
if revid == current_revid:
# fixup metadata and overwrite existing revision; modified time will be updated if changed
changed = False
meta = dict(rev.meta)
if REV_NUMBER in meta and meta[REV_NUMBER] > 1 or REV_NUMBER not in meta:
changed = True
meta[REV_NUMBER] = 1
if PARENTID in meta:
changed = True
del meta[PARENTID]
if changed:
current_rev.item.store_revision(meta, current_rev.data, overwrite=True)
print(" (current rev meta data updated)")
continue
has_historical_revision = True
name = rev.meta[NAME]
if name == current_name:
print(" Destroying revision {0}".format(revid))
else:
print(" Destroying revision {0} (named {1!r})".format(revid, name))
current_rev.item.destroy_revision(revid)
if not has_historical_revision:
print(" (no historical revisions)")
current_namespace = current_rev.meta[NAMESPACE]
current_revno = current_rev.meta[REV_NUMBER]
current_full_name = current_namespace + '/' + current_name[0] if current_namespace else current_name
if test:
print("Item named {0!r} selected but not updated, has {1} revisions :".format(current_full_name,
current_revno))
else:
print("Destroying historical revisions of {0!r}:".format(current_full_name))
has_historical_revision = False
for rev in current_rev.item.iter_revs():
revid = rev.meta[REVID]
if revid == current_revid:
# fixup metadata and overwrite existing revision; modified time will be updated if changed
changed = False
meta = dict(rev.meta)
if REV_NUMBER in meta and meta[REV_NUMBER] > 1 or REV_NUMBER not in meta:
changed = True
meta[REV_NUMBER] = 1
if PARENTID in meta:
changed = True
del meta[PARENTID]
if changed:
current_rev.item.store_revision(meta, current_rev.data, overwrite=True)
print(" (current rev meta data updated)")
continue
has_historical_revision = True
name = rev.meta[NAME]
if name == current_name:
print(" Destroying revision {0}".format(revid))
else:
print(" Destroying revision {0} (named {1!r})".format(revid, name))
current_rev.item.destroy_revision(revid)
if not has_historical_revision:
print(" (no historical revisions)")

logging.info("Reduce revisions finished")
2 changes: 1 addition & 1 deletion src/moin/config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def __init__(self, exprstr):
from the filesystem as url .../+serve/<name>/...
"""),

('supplementation_item_names', ['Discussion', ],
('supplementation_item_names', [_('Discussion'), ],
"List of names of the supplementation (sub)items [Unicode]"),

('interwiki_preferred', [], "In dialogues, show those wikis at the top of the list [list of Unicode]."),
Expand Down
2 changes: 1 addition & 1 deletion src/moin/config/wikiconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Config(DefaultConfig):
'font_awesome',
'ckeditor',
'autosize',
'svgedit_moin', 'twikidraw_moin', 'anywikidraw',
'svgedit_moin',
'jquery_tablesorter',
'pygments',
]
Expand Down
Loading

0 comments on commit 09ed207

Please sign in to comment.