Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-01-20 13:59:08

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

rah_flat (template file extensions)

I’m still kind of new to rah_flat, but it seems to output templates with extension .txp. Is there a reason for that, instead of having something more useful like .textile? Every time I have to edit a template, TextMate doesn’t like it, and understandably so. If the extension was .textile, TextMate would immediately throw the appropriate bundle on it and that would be nice. Can that be changed? Even better, I suppose, would be a preference for the plugin that allows you to choose what extension you want to use, so that one could more easily edit in .md, .txt, .textile, or whatever else.

Offline

#2 2016-01-20 14:10:19

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,565
Website GitHub Mastodon

Re: rah_flat (template file extensions)

Can’t you associate filenames to modes in TextMate? That’s what I do in Panic Coda to associate .txp with the Textpattern Syntax Mode within.

For our Textpattern 4.7 core theme versions the filename is still up for debate. It would probably stay as .txp or just use .html. Since the template files are not Textile, I doubt that is right filename to use.

Offline

#3 2016-01-20 14:19:34

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: rah_flat (template file extensions)

philwareham wrote #297506:

Can’t you associate filenames to modes in TextMate?

If I can, I’m not sure how. I can assign an unknown type to .textile, which will effect any other unknown type too, but I don’t see anywhere to make a special association from .txp alone. But I could be missing it.

Offline

#4 2016-01-20 17:08:24

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: rah_flat (template file extensions)

philwareham wrote #297506:

Can’t you associate filenames to modes in TextMate?

Just figured that out now. They call it “grammars” in TM. Ha! Thanks for the tip.

Offline

#5 2016-01-21 00:15:45

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: rah_flat (template file extensions)

tip: sublime text works awesomely with textpattern rah_flat projects. It’ll let you have a window with a collection of files that you can save as a workspace, and you can even set up .txp as an .html equivalent which allows automatic closing of textpattern tags.

Love me some sublime text.

Offline

#6 2016-01-22 21:58:42

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: rah_flat (template file extensions)

I use a lot of forms… which can get confusing at times.

I realized the other day that if rah_flat were to look recursively under the forms directory and not just one level deep we would have a killer organizational tool.

Everything would be WAY, WAY easier to find.

Unfortunately Jukka is MIA, and it exceeds my skillset to do so. Anyone else wanna try?

-D

Offline

#7 2016-01-23 14:11:08

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,192
Website GitHub

Re: rah_flat (template file extensions)

mrdale wrote #297541:

I use a lot of forms… which can get confusing at times.

I realized the other day that if rah_flat were to look recursively under the forms directory and not just one level deep we would have a killer organizational tool.

Can you give an example of how you would organise things, or how the resulting forms should be named based on the folders? I generally try and use prefixes to make forms more findable.

Was just wondering if you could achieve this another way, i.e. work in parallel folder on templates and have a watch script create the templates in the naming scheme you want for rah_flat. Ideas here and here.


TXP Builders – finely-crafted code, design and txp

Offline

#8 2016-01-23 18:51:43

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: rah_flat (template file extensions)

Maybe you have…

  • 6 forms that deal with user profile management
  • 4 forms that deal with image galleries
  • 3 Page structure forms

I’d like to be able to simply have the following directories under “forms”

  • forms
    • user
      • user_login
      • user_password_reset
      • etc…
    • galleries
      • hero_large
      • hero_small
      • etc…
    • page
      • page_header
      • page_footer
      • etc…

Simply making rah_flat to look at the contents of subdirectories as well would be an elegant way to arrive at simple but effective organization… I can’t imagine it would be a difficult mod to rah_flat.

For extra points you could have it create custom form types

Offline

#9 2016-01-24 16:58:44

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: rah_flat (template file extensions)

mrdale wrote #297541:

I realized the other day that if rah_flat were to look recursively under the forms directory and not just one level deep we would have a killer organizational tool.

+1000, I had exactly the same request months ago

and Yes, with grunt you can organize files into subfolders and copy to another folder at the same level. but it’s turning a routine with a watcher and systematically copy all template files from one folder to another for every small change on a file. Briefly, the simplest would still be an update of the plugin… But this plugin is orphan.

I hope that core solution with the new core template system (4.7… 4.8 ?) will allow a free organization of template files in subfolders.

Offline

#10 2016-01-24 17:09:09

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: rah_flat (template file extensions)

sacripant wrote #297560:

I hope that core solution with the new core template system (4.7… 4.8 ?) will allow a free organization of template files in subfolders.

I think that’s where the solution really needs developed, for example. First to provide custom labeling and organization in the Forms panel itself, and then for a plugin (rah_flat or any similar one that comes along) to mimic that structure in a flat-file tree as sub-folders. Likewise, to be able to edit the flat tree structure, and have Txp “suck up” that structure change in the Forms panel via the plugin, but that might be asking too much.

Offline

#11 2016-01-24 17:43:11

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: rah_flat (template file extensions)

Yep, custom form types would be ideal, but to be frank, since I started using rah_flat I almost never visit anything under Presentation in the UI… It’s just way way way slower.

Consequently I’d prefer a simple mod to rah_flat. Anyone with a great big brain wanna help?

Offline

#12 2016-02-03 17:48:51

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: rah_flat (template file extensions)

So I’m still looking into making rah_flat recursive, ie look into subfolders for imports to keep largeprojects more organized.

It seems that rah flat creates a class Rah_Flat_TemplateIterator that extends public class DirectoryInterator info»

There is a similar public class called RecursiveDirectoryIterator info»

I did try simply replacing the class DirectoryInterator with RecursiveDirectoryInterator to no avail.

Anyone with a brain feel like making this sucker recursive?

for extra points have it avoid a foldder called “disabled”.

Offline

#13 2016-02-04 00:48:13

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,192
Website GitHub

Re: rah_flat (template file extensions)

mrdale wrote #297552:

I’d like to be able to simply have the following directories under “forms”

  • forms
    • user
      • user_login
      • user_password_reset
      • etc…
    • galleries
      • hero_large
      • hero_small
      • etc…
    • page
      • page_header
      • page_footer
      • etc…

Yeah, I get you with the file organisation … a bit like components in sass. What I meant was how do you envisage mapping these to form names for txp?

When using rah_flat it’s irrelevant for the Presentation > Form tab because you can’t see it (only when you switch it off) but you’ll need to put those in your form="form-name" attribute of your txp-tags. In your example, you duplicate the folder name in the file prefix in all but one case (galleries), so I wasn’t sure.

Maybe a pattern like:

/directory/form.type.txp --> directory.form of type {type}

which would give you:

/forms/user/login.misc.txp --> user.login of type misc
/forms/galleries/hero_large.misc.txp --> galleries.hero_large of type misc

You could also simply ignore the file directory name and only read out the file name, but then you’d need to trap the problem of duplicate forms names in separate directories.

That said, at present you can already name your files like this:

user.login.misc.txp --> user.login
user.password-reset.misc.txp --> user.password-reset
galleries.hero-large.misc.txp --> galleries.hero-large
galleries.hero-small.misc.txp --> galleries.hero-small
page.header.misc.txp --> page.header
page.footer.misc.txp --> page.footer

as the second-to-last extension is always expected to be the form type and dot is an allowed character. According to jukka, it must only:

  • be fewer than 64 characters long,
  • start with an ASCII character, followed by A-z, 0-9, -, _ and
  • end with a file extension

For extra points you could have it create custom form types

At present these are hard-coded in txp.

for extra points have it avoid a foldder called “disabled”.

You can use invalid template names such as starting your form name with an underscore or dot to ‘hide’ forms from rah_flat.


TXP Builders – finely-crafted code, design and txp

Offline

#14 2016-02-04 02:52:40

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: rah_flat (template file extensions)

Good thoughts and clarifications jakob.

For now I use all forms as .misc because form types are functionally irrelevant.

My immediate desire is to have rah_flat simply look at and process forms in subdirectories (simple)

The ideal for rah_flat and textpattern is to

  1. have textpattern provide an interface for creating and using custom form types
  2. have rah_flat use a subdirectory structure that maps to form types instead of name spaces. ie templates/forms/foo/my_form.txp is a “foo” form with a name of “my_form”

Then one could merrily arrange a project in a semantic file structure

Offline

#15 2016-02-04 07:55:01

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,192
Website GitHub

Re: rah_flat (template file extensions)

mrdale wrote #297728:

For now I use all forms as .misc because form types are functionally irrelevant.

I haven’t tried this but rah_flat says it defaults to misc if it can’t find the the type, but I’m not sure if you can leave out the misc altogether because rah_flat currently tests if the filename matches the template pattern:

something . something . something

You could try that. As far as I can tell it doesn’t actually check whether the type is one of the standard types, so you could theoretically use anything if txp doesn’t mind.

1. have textpattern provide an interface for creating and using custom form types

This depends on txp accommodating that, and on a plugin being able to modify/override the list. I can’t see any pluggable bits in include/txp_form.php as yet, though. As you say, though, this bit would be irrelevant until the point that you switch off rah_flat.

2. have rah_flat use a subdirectory structure that maps to form types instead of name spaces. ie templates/forms/foo/my_form.txp is a “foo” form with a name of “my_form”

This might work by modifying the form processing bit of rah_flat so that it:

  • recursively processes directories
  • uses a folder based matching pattern where the directory name is then used for getTemplateType().
  • (and ideally make rah_flat backwards compatible to the normal method for those legacy projects)

But you would still have the problem of possible duplicate form names. That would require either that:

  • Textpattern tolerates forms with the same form name but different types and if it does, also knows which of them to output when you put it in a form="my-form" attribute. You could try that out. If it doesn’t you’d need a mechanism for letting txp know which form is which, which would affect lots of txp tags. If that’s the case, IMHO, a naming convention would be easier than specifying another formtype attribute.
  • rah_flat filters out duplicates. In rah_flat you’d need to have a policy for which would be kept or dropped (first come first served, last one overwrites), and rah_flat would need to report it in the tag trace (not visible enough?) or as an error (too visible?), or you wouldn’t know why it’s not working.

That isn’t a problem if you use the directory name as the form prefix, as in my last post. The problem there would be exceeding the max number of characters.

BTW: I’m not trying to shoot this down – I think it’s a good idea too – just thinking it through.

BTW II: My initial idea with a task runner could still work without modifying txp or rah_flat.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB