Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2014-11-17 20:29:23

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Making plugins first-class citizens

I don’t think it’ll matter much as far as parsing speed is concerned. That last rewrite with the mega else tag may even be faster than the earlier version I posted. I’d have to test to make sure, because you’d be trading multiple strpos() calls for executing a preg_match() more often.

Offline

#14 2014-11-17 20:30:29

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Making plugins first-class citizens

ruud wrote #285847:

That last rewrite with the mega else tag may even be faster than the earlier version I posted.

Well in that case, it might be worth a shot!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#15 2014-11-17 21:25:31

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Making plugins first-class citizens

Simple benchmark with 6 test strings:
$thing = ‘some very long text that does not contain an else tag’;
$thing = ‘<txp:else />some very long text that does contain an else tag’;
$thing = ‘some very long text that does contain an else tag… but no other tags<txp:else />’;
$thing = ‘some <b>very long</b> text: that does contain an else tag and other tag <txp:else />’;
$thing = ‘some very long text that does contain an else tag and <txp:other /> tag <txp:else />’;
$thing = ‘<txp:other />some very long text that does contain an else tag and other tag <txp:else />’;

Running that through EvalElse 250.000 times for the above strings gives these results (in seconds):

---
	0.1563	0.1600	0.1795
	0.3106	0.3191	0.6979
	0.3170	0.3202	0.7330
	0.3231	0.7217	0.7891
	1.8087	2.2145	2.2133
	1.8040	2.1788	2.1954

First column: current TXP version
Second column: parsing tags with a 3-char prefix, but with just <txp:else />
Third column: parsing tags with a 3-char prefix, including Stef’s mega else tag.

The impact here is at most 0.4 seconds per 250.000 iterations, which is nothing compared to total page load time. I’d trade that for being able to write templates that are more easy to read.

Offline

#16 2014-11-17 21:51:22

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Making plugins first-class citizens

ruud wrote #285853:

I’d trade that for being able to write templates that are more easy to read.

Hear, hear … one of Textpattern’s great strengths.

Offline

#17 2014-11-17 22:47:47

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Making plugins first-class citizens

gomedia wrote #285854:

Hear, hear … one of Textpattern’s great strengths.

Which is one of the main reasons I was attracted to Textpattern and why I am still here.

Offline

#18 2014-11-18 11:46:16

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: Making plugins first-class citizens

Guys, I hope you know what you are doing. There are many common 3-letters xml namespaces (rdf, owl, geo, …). By registering some geo_plugin, you are seriously compromising the possibility to export an article (with, say, rah_eo) as

xml
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
  <geo:Point>
    <geo:lat><txp:custom_field name="lat" /></geo:lat>
    <geo:long><txp:custom_field name="long" /></geo:long>
  </geo:Point>
</rdf:RDF>

Provide at least the possibility to “unregister” some namespaces in parse(), etc. We can still call <txp:geo_lat /> if needed.

Please get me right, I like the idea, but life is life.

Offline

#19 2014-11-18 12:48:36

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Making plugins first-class citizens

When registering tags it’s possible to collect a list of used prefixes and only allow only those to be parsed. You’d still get into problems with a plugin that registers the “geo” prefix combined with those <geo:lat> tags.

In addition to that, we could limit this new prefix stuff to tags that are registered. That should motivate plugin authors to update their plugins ;)

Offline

#20 2014-11-18 12:59:40

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: Making plugins first-class citizens

ruud wrote #285888:

You’d still get into problems with a plugin that registers the “geo” prefix combined with those <geo:lat> tags.

That’s what I say too. An opt-out entry in Preferences, maybe?

Offline

#21 2014-11-18 13:00:20

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Making plugins first-class citizens

ruud wrote #285888:

You’d still get into problems with a plugin that registers the “geo” prefix combined with those <geo:lat> tags.

We should probably reserve some of the well-known prefixes as off-limits. And someone had better tell geoff77 that his prefix is on the banned list :-o


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#22 2014-11-18 13:09:10

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: Making plugins first-class citizens

Bloke wrote #285891:

And someone had better tell geoff77 that his prefix is on the banned list :-o

And someone should sue tools.ietf.org/html/draft-lozano-tmch-smd-02 for using smd prefix ;)

Offline

#23 2014-11-18 13:21:43

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: Making plugins first-class citizens

What about <smd::magic /> scheme?

Offline

#24 2014-11-18 13:30:38

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Making plugins first-class citizens

etc wrote #285892:

And someone should sue tools.ietf.org/html/draft-lozano-tmch-smd-02 for using smd prefix ;)

Oh, now the gloves are well and truly off! How dare they ;-)

The double-colon, or some other unique identifier, is a good suggestion for side-stepping other namespace clashes. Not sure how the regex would need to be altered, but that’s not my area of expertise.

Anyone have any other cool ideas?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB