Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-04-09 11:27:53

mikewest
Archived Plugin Author
From: Deutschland
Registered: 2006-04-09
Posts: 16
Website

[plugin] [ORPHAN] mcw_templates: export/import pages, forms, css to files

<p>This plugin creates a new tab under `extensions`, enabling the trivial export of pages, forms, and CSS rules to a specified folder for convenient editing, and the subsequent import of new and updated files.</p>

<h2>Requirements</h2>

<p>This plugin has only been tested on my <strong>4.03</strong> installations. It might work on other version, but no promises! Consider this a public beta. :)</p>

<p>Regardless of where it’s been tested, this plugin messes around with your database. <strong>Do not use it without backing up your database</strong>.</p>

<h2>Setup</h2>
<p>By default, the plugin looks for a directory named <code>_templates</code> in your <code>textpattern</code> directory. If the directory doesn’t exist, the plugin will attempt to create it the first time you export your templates. This creation will almost certainly fail, since the <code>textpattern</code> directory usually isn’t writable. In that case, you’ll need to create this directory, and ensure that the web server has write access. If your site is hosted at <code>/users/home/myuser/web/public/</code>, then the following commands could be used:</p>
<pre>
<code> cd /users/home/myuser/web/public/ mkdir ./textpattern/_templates chmod 777 ./textpattern/_templates
</code>
</pre>

<h2>Usage</h2>
<p>To use the plugin, simply select ‘import’ or ‘export’ from the dropdown on the plugin’s tab. Couldn’t be simpler.</p>

<h2>Download</h2>

<p><a href=‘http://mikewest.org/file_download/4’>Download the current version (<strong>0.2</strong>) of the plugin here</a>, or <a href=‘http://mikewest.org/file_download/3’>grab the previous version (<strong>0.1</strong>)</a>.</p>

<h2>Credits</h2>
<p>This is a complete rewrite of <a href=‘http://www.woods-fehr.com/txp/8/link-template-2-file’>Scott Woods’ brilliant Link Template 2 File scripts</a>. I used his code as a jumping-off point, but ended up rewriting just about everything to fit the functionality into an admin plugin and beef up the error checking.</p>

Last edited by mikewest (2006-04-10 20:23:19)

Offline

#2 2006-04-09 12:23:47

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] mcw_templates: export/import pages, forms, css to files

So far the export feature tested on MAC OS, worked well , question though ,before testing the import feature , the forms get an html filename extension,wouldn’t it make more sense to have them set to text ?


⌃ ⇧ < ⌃ ⇧ >

Offline

#3 2006-04-09 12:31:27

mikewest
Archived Plugin Author
From: Deutschland
Registered: 2006-04-09
Posts: 16
Website

Re: [plugin] [ORPHAN] mcw_templates: export/import pages, forms, css to files

If the files have a ‘.html’ extension then many editors will automagically enable syntax highlighting, which I enjoy. However, you can change the file extensions fairly easily, if you like, by editing `$mcw_templates[‘extension_*’]` in the plugin code to match your preferences.

-Mike

Offline

#4 2006-04-09 14:50:19

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] mcw_templates: export/import pages, forms, css to files

Ok, I hadn’t thought about the syntax highlighting aspect, import feature worked as intended as well,
I tested this by just making an unsignificant change in the CSS file, and works as intended.
One thing that I noticed though,having taking a small look at the relavant database table, it shows an overhead of ~600 bytes,
What could be causing this, is it because the query isn’t done by TXP itself ?

In general, I think that this could prove a real milestone in improving authoring workflow, if using skedit for example you’re just a few clicks away from real live syncing.
Probably the most usefull plugin of the year after Inspired’s revolutionary plugincomposer

It works pretty fast allso on my install,4.03(live)

EDIT.: It should be a really valuable Tool allso for Template authors, and makes packeging up templates a snap,

regards, marios

Last edited by marios (2006-04-09 15:01:13)


⌃ ⇧ < ⌃ ⇧ >

Offline

#5 2006-04-09 15:00:10

mikewest
Archived Plugin Author
From: Deutschland
Registered: 2006-04-09
Posts: 16
Website

Re: [plugin] [ORPHAN] mcw_templates: export/import pages, forms, css to files

Exactly. As soon as I saw Scott’s scripts, I knew this workflow was exactly what I was looking for in terms of an authoring mechanism. Specifically, it lets me control pages, forms, and css rules with SVN, which is absolutely critical for me since I end up accidentally deleting things all the time. :)

I’m glad to hear the script works for you on 4.02. As far as the overhead in the relevant table goes, you got me. I’m using the internal db functions to do the import… maybe I can run `optimize table` after the import. I’ll look into that.

-Mike

Offline

#6 2006-04-09 15:26:39

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] mcw_templates: export/import pages, forms, css to files

EDIT.: Small typo above,I’ve used an 4.03 install(updated post above),
If anybody want’s to join the party to test on older versions, I don’t have any older install right now, neither locally.

I’ve thought about an update feature,the file extension could be made an option (choose between. txt, .html,)That way it would suit the needs for template packeging as well,
(But if not, it wouldn’t be a big deal either)

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#7 2006-04-09 22:54:28

jameslomax
Member
From: UK
Registered: 2005-05-09
Posts: 448
Website

Re: [plugin] [ORPHAN] mcw_templates: export/import pages, forms, css to files

Nice. I was going to put in a feature request for this.
Got a problem though, changing .html to .txt
I get this message:

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

which is incorrect, because the server is still operational. For some reason, modifying the plug in code brings up problems.

Offline

#8 2006-04-10 05:04:31

mikewest
Archived Plugin Author
From: Deutschland
Registered: 2006-04-09
Posts: 16
Website

Re: [plugin] [ORPHAN] mcw_templates: export/import pages, forms, css to files

Hrm. Odd. I don’t get an error like that when I edit the config variables… it just works.

Is the error happening for you every time, or is it periodic? It sounds like it might have been an issue with the server as opposed to the script. Still, would you mind sending me a copy of the modified PHP code to test out?

-Mike

Offline

#9 2006-04-10 07:41:05

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] mcw_templates: export/import pages, forms, css to files

Tested now, allso on forms, and pages:
Works flawless,importing and exporting,

A short summary with some observations, working with this:

@mike, it seems that the beforementioned overhead appears only on _CSS, and _pages of the import feature and not on _forms,
would that help, to track down what is doing this?

Allso, I had overlooked the configuration option yesterday,that does everything that’s needed and works as intended.

Another notice, for authors:

<del>When doing changes inbetween import sessions right from the backend, don’t forget to delete the contents of your _template folder,
else you just overwrite your changes with the old ones, since there is no way of telling the plugin which files to overwrite, and which not.</del>

EDIT.: Obsolete now, the below as well, the plugin <strong>rocks</strong>

The same helds true before exporting as well, in case you had been working locally on your remote Server files.
(This is probably crucial, when you have multiple authors working on one site)

Other than that, it’s pretty convenient.
<strong>What else ?</strong>
Do we wait for TXP’s super dupers Theme engine?
Answer: No, we have what we need, right now, today, thanks for doing this ,

regards, marios

Last edited by marios (2006-06-30 04:05:32)


⌃ ⇧ < ⌃ ⇧ >

Offline

#10 2006-04-10 08:25:43

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: [plugin] [ORPHAN] mcw_templates: export/import pages, forms, css to files

this sounds awesome.ill test asap


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#11 2006-04-10 10:25:39

mikewest
Archived Plugin Author
From: Deutschland
Registered: 2006-04-09
Posts: 16
Website

Re: [plugin] [ORPHAN] mcw_templates: export/import pages, forms, css to files

@mario: 0.1 of the plugin is pretty much a straight rewrite of the functionality in Scott’s scripts. My plan for future iterations includes a bit of warning for overwrites and the like. I haven’t quite figured out how I want it to work yet from a UI perspective, but there will certainly be a “this file has changed since the last export, are you sure you want to overwrite?” message of some sort.

With regard to themes, my plan is to start looking at subdirectories of `_templates`. In other words, when you’re importing or exporting, you can choose a subdirectory to import from or export to. `_templates/theme1` might be one set of pages, forms, and css rules, while `_templates/theme2` might be another. That would make packaging up changes pretty trivial, and give the very important option of creating backups when you import (e.g. when an import is requested, an export would automatically happen, targeting`_templates/previous_version`). That’s an idea I love, I’m just testing it locally before putting a UI together and pushing anything out.

-Mike

Offline

#12 2006-04-10 14:05:12

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] mcw_templates: export/import pages, forms, css to files

That sounds good, this would require some serious thinking though, mainly about what the plugin should be allowed to do and what not, before even going to think about the UI stuff,
I am still wondering why it’s messing the CSS and pages tables,

I feel quite enthusiastic about all this, this could change a big deal of things.

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

Board footer

Powered by FluxBB