Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2011-04-01 17:39:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,632
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

MattD wrote:

It looks to me like the image is cachable for 24 hours.

Hmm, well if it is, the plugin isn’t honouring it so I need to rethink how it’s done. At the moment it always inserts the URL to the charts API inside the <img> tag’s src attribute which means it goes to the server every time. I haven’t studied the traffic yet but certainly Firebug’s Net pane confirms that a request is going to Google every page refresh. Whether Google returns some kind of Not-modified header or if the browser catches it and serves the local image I don’t know yet.

In the meantime I’ve been toying with manual (plugin) cacheing today and it’s almost working. Since I can’t rely on allow_url_fopen I can’t just see if site.com/images/smd_qr_codes/cached_file exists and serve it from there. Shame :-(

So I’ve elected to store the image data (base64 encoded) in the cache directory and then, if the file exists and you’ve chosen to use the cache (it’s on by default) it serves it as src="data:image/png;base64,file_contents_here". It’s doing it and it technically looks ok, but it’s not rendering the image in the browser for some reason. And this precludes <IE7 from the mix, but I don’t very much care.

I’m sure I’ll figure it out but the simplest solution by far would be if I could render something in the src attribute that the browser could figure was identical and serve the cached copy. If anyone can confirm or deny what’s going on between the server and the browser here I’d be very grateful. Saves me getting Wireshark out and might save me a lot of code if it’s already cacheing it.


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

#12 2011-04-01 17:45:14

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,632
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

Wait, maybe it is cacheing it already. W00t! That saves me some headaches. Anyone confirm this?


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

#13 2011-04-01 23:29:55

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,251
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

I’d be suprised if the browser wasn’t cacheing it at least for those 24 hours.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#14 2011-04-02 08:51:03

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,632
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

MattD wrote:

I’d be suprised if the browser wasn’t cacheing it at least for those 24 hours.

Confirmed. The browser saves the day, yay! Internet biscuits all round. I’ve added a few more features to the plugin. Final testing in progress. Should be out later today when I get a chance to tart up the docs.


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 2011-04-02 22:30:38

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,632
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

v0.20 released.

Features:

  • added title attribute for the <img> tag (when using format="view" and no wraptag)
  • added validate attribute to allow custom validation by regex (overrides the built-in regexes)
  • added validelim and debug attributes to suport validate
  • added limited vcard type (thanks gomedia). Just name, email, web site, address and phone number supported. Please test!
  • improved error reporting and documentation
  • fixed URL regex

If you want to be more restrictive in your regexes (some of the defaults are just “any character”) then you can now do custom validation on selected fields. Please remember that the regex you supply must be a complete regex string including start and end delimiters, e.g. /[0-9A-Za-z. \-]/. If you omit the surrounding delimiters things will probably go wrong.

See how you get on with this one and let me know.


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

#16 2011-04-02 23:40:30

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

Re: smd_qr_code: embed Quick Response barcodes on your site

Bloke wrote:

added limited vcard type (thanks gomedia). Just name, email, web site, address and phone number supported. Please test!

Thanks Stef. It seems to work OK, although I note that “http://” has to be used on the URL and that a data value can’t be omitted (for example, I don’t give anyone my address).

Rather than forcing fixed data types and positions – data = "name | email | url | address | phone" – would something like:

data = 'FN="abc", EMAIL="me@abc.com", URL="www.abc.com"'

be a bit more flexible for the user and easier for you to maintain?

Offline

#17 2011-04-03 01:37:18

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

Re: smd_qr_code: embed Quick Response barcodes on your site

or if type="text" recognised the delimiter and generated new lines in the output:

type="text" data="BEGIN:VCARD | FN:My Business Name | TEL:01234 123456 | URL:www.mybusinessname.com.au | EMAIL:nobody@mybusinessname.com.au | END:VCARD"

… unfortunately couldn’t get “\r\n” to work as a delimiter!

Offline

#18 2011-04-03 13:54:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,632
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

gomedia wrote:

I note that “http://” has to be used on the URL

That’s just the built-in regex at work. You could override that for the time being until I can figure out a better system.

and that a data value can’t be omitted (for example, I don’t give anyone my address).

Yeah, that kind of annoyed me that I couldn’t actually remove the ADR from the output, even though you could specify {smd_empty} to state that you didn’t want to provide it. Your suggestion of allowing someone to specify the fields is interesting. I’d been racking my brain to find a better way to handle it so you could a) decide what data went into the code, and b) define your own codes. Haven’t found a neat system yet.

One solution is an admin interface that has all the current codes loaded into it and allows you to edit/delete them and/or add new ones. A bit like the way smd_macro works. But that seemed very expensive in terms of code for something that might not be used that often so perhaps an ‘inline’ mechanism to specify a layout in the tag might be useful. The problem there is it gets very clunky very quickly, especially as you found when trying to set delimiters to \r\n. A hidden pref is another way, but again it’d be nice to be able to configure it graphically.

I’ll have a play with some ideas. If anybody has any others to throw into the mix I’ll check them out while I’m at it. Gotta be a way to make this a generic QR code plugin somehow. I’m a bit hamstrung by the Charts API interface I robbed off the Internet at the moment. After having played with it for some time I realised it really is a bit limiting compared with what can be done directly with the API, so perhaps dropping the interface and writing my own generic one that hooks directly into the Charts API might be a simpler way forward. Heck that might even pave the way for smd_charts… :-)

Will see.

Last edited by Bloke (2011-04-03 13:58:03)


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

#19 2011-04-03 15:23:31

shayne
Member
From: Toronto
Registered: 2005-02-22
Posts: 34
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

Hey Stef – great plugin, margin doesn’t seem to be working, always stays at the default of 4…

Offline

#20 2011-04-04 04:29:28

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 583
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

Heck that might even pave the way for smd_charts… :-)

Genericized charting in TXP would be awesome! I would totally find a nail to hit with that hammer.

Offline

Board footer

Powered by FluxBB