0

I have previously used MediaWiki's excellent CreateBox plugin to make page creation really easy.

Essentially, CreateBox presents the user with some pre-defined parameters (e.g. name of page possibly with suggestions from the current date) which will be used to populate a template (PageTemplates are perfect targets for this).

Is there an equivalent plugin/feature for TRAC? (must work with 0.11.7) It would be really amazing if there were a drop-down menu for creating new wiki pages, with the PageTemplates as the options.

UPDATE: the answer is to use ParameterizedPageTemplates to get the /newpage/ handler which accepts /newpage/?page=Page&template=Template formatted URLs. Then use TRAC's built-in HTML processor to create a form input like this

{{{
#!html
<form name="input" action="/project/template/newpage">
    <input type="text" name="page" />
    <input type="submit" name="template" value="Template" />
</form>
}}}
fommil
  • 5,757
  • 8
  • 41
  • 81

3 Answers3

1

I've done something like this outside of Trac. As you've mentioned, you can put together a small HTML page and a few lines of Javascript to implement an interface that auto-redirects to a specific wiki page based on user-supplied parameters. Instead of trying to implement this inside Trac, you can host this page outside of Trac and link to it from the Trac interface.

For example, my system uses URLs that look like http://myserver/trac for Trac, and I'm hosting a page at http://myserver/tools/NewWikiPage that implements my "new wiki page" creation interface. I have a link to this page listed on WikiStart for easy access, but you can just as easily add it to the toolbar if you like.

I found this to be the simplest solution. It's quite possible to wrap this up and make it a Trac plugin, but for my purposes I found it sufficient to host it as a separate page.

bta
  • 43,959
  • 6
  • 69
  • 99
  • Can you share the static page? I was also thinking ServerSideRedirect (or mod-rewrite) would do it. – fommil Aug 15 '12 at 06:47
  • I've gone with HTML processor in trac pointing at `/newpage/?page=MyPage&template=Template` from the `ParameterizedPageTemplates` plugin. I've selected you as the answer because nobody it is the closest thing to what I ended up doing and I didn't want the bounty to go to waste :-) – fommil Aug 16 '12 at 13:49
1

A plugin has recently been written that I think does what you want:

https://github.com/netjunki/trac-NewPageMacro

It provides a [[NewPage]] macro that you can insert in your wiki pages. It supports parameters for wiki page templates, specifying a parent page, and some other customizations; and it includes a permission check before rendering the form.

ejucovy
  • 907
  • 9
  • 10
  • This looks great! I'll try it out later, shame I've already assigned the answer to someone. Might be worth reassigning. – fommil Oct 03 '12 at 18:01
0

I am not aware of a plug-in to provide a similar CreateBox experience but I found the default Trac behavior to be pretty close. After you create a template following the instructions on PageTemplates, the next time you try to create a new page, you are presented with page similar to the one below.

In the example below, I created the page by just typing in the new URL https:///wiki/WorkFlow, where WorkFlow was the new page I wanted to create. Trac gave me suggestions as to pages I might have been looking for or the ability to create a new page based on the templates I have available.

enter image description here

Josh Laase
  • 326
  • 1
  • 13
  • That's not what I'm after. I want to have an `input` which then redirects to the page you're talking about. The template type (and perhaps some pre-generated text for the title) would be customisable. e.g. let's say I have a template called `Idea`, I want to put an `input` form anywhere, which lets me insert the name of the idea I want to create, and click "create `Idea`". Then I'll be redirected to `/wiki/prepend_name_append`. Combined with [`ParametrizedTemplatesPlugin`](http://trac-hacks.org/wiki/ParametrizedTemplatesPlugin) it would be a very powerful way to manage knowledge. – fommil Aug 10 '12 at 23:50
  • If you type a CamelCase word in the search box, located in the upper right corner of any page in Trac, it will jump you to the wiki page if it exists or it will take you to the same create page I mentioned above. The only downside to this is that if you want to create a page in a hierarchy, you have to type the entire hierarchy into the box. – Josh Laase Aug 11 '12 at 00:25
  • Unfortunately, the search box is also not exactly what you are looking for and I do not know of a plug in that gives you exactly what you are looking for. – Josh Laase Aug 11 '12 at 00:34
  • it's very frustrating because I know I could implement this with about 4 lines of HTML! :-) – fommil Aug 11 '12 at 12:16
  • 1
    ParametrizedTemplatesPlugin is a good starting point indeed. You can easily create even forms by Trac's HTML WikiProcessor, but to have interaction (the redirect) you'll need some server-side-code, or at least provide a page with suitable JavaScript included (less reliable). Why now trying to extend the ParametrizedTemplatesPlugin in that direction? I've not seen a corresponding enhancement request by now. – hasienda Aug 12 '12 at 13:09