Tags:
template_system1Add my vote for this tag create new tag
view all tags
I have recently been working to make the view.tmpl more "editable" from within the TWiki. I have a working example at NevadaMissouri.net, although it will need a lot more work before it will be a packaged "skin" contact TravisBarker and request "edit" access to this example if interested.

-- TravisBarker - 15 Jan 2003

Sounds interesting Travis. Would you please attach your view.tmpl to this topic so I can see how it works? thanks.

-- MattWilkie - 15 Jan 2003

Hi Travis! Good to see you here on TWiki and not just TWikiIRC. I hope you also get the registration email problem fixed so I can finish my registration. wink

Travis mentioned to me his new view.tmpl is spread across several files, but zipping it would create a nice downloadable file.

-- GrantBow - 16 Jan 2003

ModularTemplates would also greatly help translating TWiki templates into new languages (see InternationalisationEnhancements, under Useful TWiki Pages, localisation section, and TWikiInSpanish). MoreCommonHeaderFooterTemplate addresses this specifically, for a Korean translation.

Restructuring templates is really a pre-requisite for TWiki translations, which are already provided 'out of the box' by MoinMoin, PhpWiki, etc.

-- RichardDonkin - 16 Jan 2003

By replacing most of the information in the template by variables which represent information contained in various topics i was able to create a skin that is editable on the fly, which also allows for a way to "preview" your template changes (using your back button). The new view.tmpl file consists mostly of %INCLUDES{""}% that "call" information between %START/STOP,INCLUDE% which actually exists INSIDE a TWikiTopic. the origional .tmpl file was actually broken up into 1 modified ("macrofied") view.tmpl and some 15 " TemplateTopics " which can then be edited (being template information) just as a "normal" topic is.

I can upload the modified view.tmpl but since it relys on information in several topics in order to properly resolve, I must also include those topics as files, as Grantbow pointed out i can zip it all together for you, but im not actually sure how to save a topic as an actual file on my harddrive (never had to do anything like this before)any pointers would be helpful.

-- TravisBarker - 26 Jan 2003

That's easy -- topics are already saved as files. wink On my private TWiki (which I believe is a standard installation), topic files are stored as <topic_name>.txt (and RCS files as <topic_name>.txt,v) under directories under the /home/httpd/twiki/data/<web_name> hierarchy. (Attachments are stored under directories named the <topic_name> under the /home/httpd/twiki/*pub*/<web_name> hierarchy.

Oops, I intended the pub to appear in bold -- ignore the asterisks -- I guess this is another instance of what I would call TWiki's lack of orthogonality (although maybe I have the wrong word) -- IMHO, if asterisks work anywhere to mark something as bold they should work everywhere. I know that next time I'll argue for just the opposite. wink

-- RandyKramer - 26 Jan 2003

Randy, did you want something like "under the /home/httpd/twiki/pub/<web_name> hierarchy"? Because stars are inside, they are not recognized as TWikiML markup ==> go with HTML. Or use color: "under the /home/httpd/twiki/pub/<web_name> hierarchy"? You can fix your comment and remove mine, if you want.

-- PeterMasiar - 27 Jan 2003

Thanks, Peter, that is exactly what I was looking for (well I did remove an extraneous > from your comment). But, I'll leave my petulant comment there -- I still think that if asterisks work anywhere to mark something as bold they should work everywhere. Maybe tomorrow I'll revise my statement, or maybe I should revise my concept of what it takes to mark something as bold -- it requires " " and " " around an item, and the space can be an existing space? (That's true, the question mark is just my questioning as to whether that's the best way to think about it -- it might be.) Hmm, my asterisks don't show up, I guess there must be a <whatchamacallit> entity for asterisk -- I'll have to watch for it. rhk - 12 Feb 2003

-- RandyKramer - 27 Jan 2003

Look what I just found! Plugins.FlexibleSkin

-- GrantBow - 02 Feb 2003

If we are going to have most of the skin in TWiki the the .tmpl files might as well be done should be completely removed and that all Templates should be in a separate (hidden) Skin web.

AHA! I knew I'd read about this before, what we need is WebBasedTemplateMaintenance. I'm going to find everything I can that's relevent and then revive that topic.

-- SamHasler - 11 Feb 2003

(Off topic comment): Randy said: ...if asterisks work anywhere to mark something as bold.... But they do not. Whitespace is required on opening and closing side of asterisks. This allows asterisk to have standard meaning inside text. Without this exception, ie. 2*3 would start bold text - does not make sense, right?

-- PeterMasiar - 12 Feb 2003

Yes, you're right -- I did realize that sometime after I wrote my first comment. Although I would write 2 * 3, not 2*3. wink

-- RandyKramer - 12 Feb 2003

Koala Themes

In looking at what could be needed for having modular templates in the KoalaSkin, I enhanced the standard template mecanism used by TWiki ( TMPL:INCLUDE{...} ) in compatible way by:

  1. expansing the templates at "compilation" time, so that you can split the templates in hundreds of small parts at will. Note that this could be possible even with the approach of having templates in topics, as you could "compile" via a save hook on these pages.
  2. add and "inheritance" mecanism, via what I call "themes", so that users can tweak strongly the KoalaSkin without having to write a different skin. You can say that you use a list of themes ,e.g, fancy,normal,terse, with the koala skin, and the system will try to expand TMPL:INCLUDE{foo} into, by order:
    1. foo.koala-fancy.tmpl
    2. foo.koala-normal.tmpl
    3. foo.koala-terse.tmpl
    4. foo.koala.tmpl
    5. foo.tmpl

The reason of my post is that the point 1 makes it practical to have a template for each button of the interface, to let people redefine at will some parts of the interface. However, there is a problem with the current templating system in that it always adds a newline after including a template file, which makes some constructs impossible to do as it inserts spaces at unwanted places.

So my question is: I guess that the solution is to trim the last newline of included templates, the code being in lib/TWiki.pm around line 1042:

        $text =~ s/%TMPL\:INCLUDE{[\s\"]*(.*?)[\"\s]*}%/&_readTemplateFile( $1, $theSkin )/geo;

As a perl novice, I would rewrite this as:

        my $included_template = &_readTemplateFile( $1, $theSkin );
        chomp($included_template);
        $text =~ s/%TMPL\:INCLUDE{[\s\"]*(.*?)[\"\s]*}%/$included_template/geo;

The code above works, but I would like to have some perl expert feedback:

  1. Isn't it too slow?
  2. This removes all the trailing newlines. I do not see this as a problem, as one can always append an html comment if he wants to keep the newlines, but it would be more satisfying to have a construct removing only the last line...

Thanks for any help

-- ColasNahaboo - 08 Aug 2003

There might be some side effects if you remove the last newline. For example, RCS gets confused if the last line has no new line. But then, this does probably not apply to templates. This change needs to be tested carefully before taking it into the core.

-- PeterThoeny - 10 Aug 2003

Note that it does not apply in this case:

  • newline trim occurs only on included templates, not on "top-level" ones, so the whole HTML document sent has still its terminating newline.
  • it removes the NL only in the copy in working memory, not on disk files, so RCS is not impacted.
Basically, it allows to have all files on disk having a terminating newline, even if for internal processing by TWiki they shouldn't.

-- ColasNahaboo - 10 Aug 2003

Ok, the most efficient way seems:

        my $included_template;
        chop($included_template = &_readTemplateFile( $1, $theSkin ));
        $text =~ s/%TMPL\:INCLUDE{[\s\"]*(.*?)[\"\s]*}%/$included_template/geo;

It will remove the last char, so templates should always end by a newline, but as you say, it is important that all disk files are newline-terminated anyways, otherwise many problems may arise.

-- ColasNahaboo - 11 Aug 2003

How about using chomp again so that it doesn't remove the last character if it's not a newline? Note that this should also be tested on Windows since Perl there (particularly ActivePerl) may or may not work well with the Unix-format template files distributed with TWiki. It might be easier to just do $included_template =~ s/\n$//, which should be fine.

-- RichardDonkin - 11 Aug 2003

Altho I never uploaded my view.tmpl as requested frown It is easy enough to explain what it consisted of. I simply replaced every section of the existing template possible with %INCLUDES% calling for the code from within a series of TemplateTopics such as HeaderTemplate1 HeaderTemplate2 etc etc.... this allowed for the template to be altered from within a TWikiTopic by any person who was allowed to edit the topic as set in the TemplateEditorsGroup. a fairly straight-forward approach.

-- TravisBarker - 15 Dec 2003

Edit | Attach | Watch | Print version | History: r21 < r20 < r19 < r18 < r17 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r21 - 2003-12-15 - TravisBarker
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.