[Moin-user] Suggestions sought to how best to implement this request ...
Paul Boddie
paul at boddie.org.uk
Tue Sep 24 16:38:05 EDT 2013
On Tuesday 24. September 2013 17.44.05 Philip Colmer wrote:
> Sorry that I couldn't come up with a better subject line ... I've been
> asked to migrate
>
> http://www.linaro.org/linux-on-arm/meet-the-team
>
> onto our internal MoinMoin wiki. The content from that page comes from the
> CMS that sites behind www.linaro.org and I am *not* going to be migrating
> that. Instead, my intention is to use the corporate LDAP directory to store
> the data and use some Python code to pull the data back from LDAP.
>
> I am, however, hitting some mental stumbling blocks and I'd welcome
> thoughts or comments on these:
>
> - The way that the lists are arranged into three columns seems to be
> some CSS voodoo that I'm trying to unpick. I'm not sure how to mimic
> that in MoinMoin since calling CSS directly is tricky ...
Without actually looking at the CSS, my way of reproducing this would be to
use "float: left" on the lists. That might actually do enough, but usage of
"clear: left" and "clear: right" would also help. If you were doing this in
the source of a normal wiki page, you'd be able to attach CSS to tables using
tablestyle...
||<tablestyle="float:left"> This table floats left! ||
|| Some content in the page. ||
...but putting lists inside table cells would be awkward: the standard Moin
tables allow only single line cells/rows, and I think you'd have to use the
MiniPage macro which doesn't really lend itself to readability:
http://moinmo.in/MacroMarket/MiniPage
You could use my ImprovedTableParser to put lists inside the extended tables
it supports, since it does allow cells to be defined across multiple lines:
http://moinmo.in/ParserMarket/ImprovedTableParser
I imagine, however, that since you're using content dynamically fetched from
LDAP, you're probably just going to write your own Moin extension, perhaps a
macro that you then insert into a page like this...
<<GetLDAPList(Office of the CEO)>>
...and then you will have the freedom to generate whatever HTML you like for
the retrieved content. In your macro, you'd probably use the formatter API to
make the lists like this:
def execute(macro, args):
fmt = macro.formatter
...
output = []; append = output.append
...
append(fmt.bullet_list(on=1, attr={"class" : "stafflist"}))
...
append(fmt.listitem(on=1))
...
append(fmt.listitem(on=0))
...
append(fmt.bullet_list(on=0))
...
return u"".join(output)
If you can re-use the CSS from before, you could name the CSS class for each
list as above. Otherwise, I think you can define a style attribute. If not, I
probably have a patch against Moin that lets you define one. ;-)
See the MacroMarket for examples of macros:
http://moinmo.in/MacroMarket
There is some sort of guide to writing macros, but just looking at existing
simple ones in the MoinMoin.macro package can be just as informative:
http://moinmo.in/MoinDev/CreatingMacros
> - Clicking on an individual (e.g.
> http://www.linaro.org/linux-on-arm/meet-the-team/philip-colmer/) results
I thought I recognised your name from the Acorn era! :-)
> in more "normal" layout although, again, the HTML seems to have some
> "interesting" CSS references but I might be able to ignore more of that
> and use a table instead to try to get to a similar look. My thinking here
> is that a script running directly on the server would run regularly and
> build static wiki pages based off LDAP data. For the person's photo, my
> research into MoinMoin seems to suggest that an attachment would seem to
> be the best solution as I can transfer the JPEG data from the LDAP server
> and store it inside the attachments directory for that page. Is there an
> API for storing attachments or should I just write directly to the page's
> directory structure?
You could certainly have a special homepage template and populate it from
backend data, either generating the entire page every time something changes
or generating an initial page that then uses macros to fetch backend data
(maybe caching it if you're worried about performance).
Meanwhile, if you're looking to store images inside the wiki instead of just
referencing them in some conventional Web space, attachments are probably the
way to go. The MoinMoin.action.AttachFile module contains functions to work
with attachments in a nicer way than manipulating the filesystem directly. I'd
be inclined to serve images from a vanilla Web directory unless you need the
possibility for people to change them in the wiki itself, however.
> - Similarly with the lists of people in a group (e.g.
> http://www.linaro.org/linux-on-arm/meet-the-team/office-of-the-coo), my
> intention is to build a wiki page for each group. However, if I've gone
> for the aforementioned approach of storing the images as an attachment for
> an individual page, can I reference that from another page? If not, I
> guess the better solution would be to store all of the staff images in a
> central directory and then consistently link to them as external images.
You can certainly reference attachments on another page. The following should
do the trick for images:
<<Image(attachment:pagename/filename)>>
> Any other suggestions or thoughts occur to you?
>
> Thanks for any input that anyone can provide on this.
All of this is possible as Moin is effectively just another Web framework. The
strength of Moin is in the integration with the content management it already
provides, meaning that you can introduce dynamic features like this without
throwing the existing collaborative editing environment away or substituting
it for some inferior solution (probably involving Markdown).
Let us know if you're wondering about anything and we'll try and give you
pointers to the occasionally crazy things that some of us have already done
with Moin. ;-)
Paul
More information about the Moin-user
mailing list