Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-05-03 07:55:20

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

[plugin] [ORPHAN] sed_display_code

sed display code

Latest version: 0.5
You can find it on the display code homepage .

Summary

This implementation of Dunstan’s idea allows for file listings…

  • with alternate row styling,
  • from a defined start to a defined end line,
  • with up to three sets of row highlights,
  • that preserve tabulation at the beginning of lines and also preserve blank lines from the source file

It does not include syntax highlighting—the GeSHi plugin does that just fine.

New features

  • Countable file downloads via TXP’s file handling interface.

Requested Features.

  • Options for producing the display as an ordered list rather than a table.

Last edited by net-carver (2006-06-10 10:37:15)


Steve

Offline

#2 2006-05-10 11:23:11

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: [plugin] [ORPHAN] sed_display_code

I could fall in love with this plugin if…

  1. It used order lists instead of tables (or at least gave the option to do so)
  2. It made use of Txp’s built-in file management so I could track downloads of my code samples

Pretty please? ;-)

Offline

#3 2006-05-10 11:55:59

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: [plugin] [ORPHAN] sed_display_code

Logoleptic wrote:

I could fall in love with this plugin if…
… It used order lists instead of tables (or at least gave the option to do so)…

If you look back at version 0.1 you’ll find that it did, indeed, use an ordered list for the output. I dumped the ordered list approach for two reasons…

  1. because if a line from the source file wrapped then the tabulation of the output messed up.<br/> Specifically, the wrapped section of the source line started at the beginning of the next displayed line and did not take the correct tab position.
  2. because I wanted to support file snippets starting and ending at any arbitrary line.<br/>I did try this using an ordered list and CSS counters but the browser support was pretty lame.

Displaying the code as tabulated data fixed both of these.

I think the first point might be worked out through the CSS so if you want to take v0.1 and see if you can fix that wrapping problem via CSS styling that would be just fine with me. The second one is a little more problematic.

… It made use of Txp’s built-in file management so I could track downloads of my code samples.

Now that’s a neat idea. I’ll need to research it a little first though as all the examples I use come out of the /code directory at the moment (but that’s easy to change). Yeah, this can go on the requested feature list!

BTW: Thanks for your feedback on this one and help regarding the contact form too.


Steve

Offline

#4 2006-05-11 00:34:25

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: [plugin] [ORPHAN] sed_display_code

net-carver wrote:

<blockquote>

I dumped the ordered list approach for two reasons…

  1. because if a line from the source file wrapped then the tabulation of the output messed up.<br/> Specifically, the wrapped section of the source line started at the beginning of the next displayed line and did not take the correct tab position.
  2. because I wanted to support file snippets starting and ending at any arbitrary line.<br/>I did try this using an ordered list and CSS counters but the browser support was pretty lame.

snipped

I think the first point might be worked out through the CSS so if you want to take v0.1 and see if you can fix that wrapping problem via CSS styling that would be just fine with me. The second one is a little more problematic.

</blockquote>
  1. Dunstan found a way around this with his original code presentation solution. Look at the code samples in this article under the heading “Inserting code examples into posts.” Not only to they have nicely-manicured tabs, but the code itself also tells you how to do it! CSS is helpfully included below the PHP.
  2. Browser support for advanced uses of generated content is, unfortunately, awful. For those willing to use a transitional DOCTYPE, however, there is a way! By using <a href=“http://www.w3.org/TR/html401/struct/lists.html#h-10.2”>the deprecated <code>start</code> attribute</a>, you can give an ordered list an arbitrary starting point. Again, the drawback is that it’s not valid under the strict DOCTYPE for either XHTML 1.0 or HTML 4.01. I use transitional XHTML for reasons exactly like this. Since about HTML 4 or so, almost every time the W3C has tried to make HTML “better” they’ve taken away another handful of useful, practical, semantically rich tools. That, however, is a rant I’ll leave to more well-known web pundits.

Now that’s a neat idea. I’ll need to research it a little first though as all the examples I use come out of the /code directory at the moment (but that’s easy to change).

Have a look at glx_code, which uses the built-in file manager. You might be able to get some ideas there.

BTW: Thanks for your feedback on this one and help regarding the contact form too.

Happy to help. :-)

Offline

#5 2006-05-11 09:55:26

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: [plugin] [ORPHAN] sed_display_code

Adam wrote:

1. Dunstan found a way around this with his original code presentation solution. snipped

Yeah, looks like it does wrap nicely (even on IE). Must be something I missed/misunderstood in the CSS that gets it working. OK, so that one can be overcome.

2. Browser support for advanced uses of generated content is, unfortunately, awful. For those willing to use a transitional DOCTYPE, however, there is a way! snipped

Again, looks like you have a way out of that but a shame it won’t validate in strict. I’d definitely want to keep this as a non-default option for the output format if I did go down that road.

Have a look at glx_code, which uses the built-in file manager. You might be able to get some ideas there.

That’s where my original inspiration came from (it’s credited somewhere in the help file—or at least it should be!) Unfortunately, on re-inspecting the source from v0.3 I cannot see where it is using TXPs built-in file handling.

In the absence of that info from the source, let me list what I think you are talking about when you say “using the built-in file manager.”

  1. prep your .txt version of the code locally
  2. upload using the file tab of the TXP admin interface, giving it a suitable category like “examples code” (or whatever), and it gets uploaded to the TXP files folder
  3. set the file attribute of my tag to point to file just saved Correction… <br/> set the dir attribute of my tag to point to the TXP files directory.
  4. the tag auto generates the URL to the said file so that when you click the download link it goes via the TXP core and gets registered as a download
  5. you can track the downloads on the admin side via the files tab and on your website pages if you use a suitably categorized <txp:file_download_list />
  6. perhaps include a new attribute in my tag to append the number of downloads to the download link.

Ok, that’s it for my imagining what you want. Let me know if I got anything right! :0) It’s actually this new feature that’s the highest priority for me for this plugin.

FYI: I’m doing this stuff in my (vanishing) spare time whilst looking after my 3 month old daughter so it won’t get done in a hurry.

Last edited by net-carver (2006-05-13 08:42:46)


Steve

Offline

#6 2006-05-16 10:22:29

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: [plugin] [ORPHAN] sed_display_code

New version available that adds integration with TXP’s file handling as described in the last post.

It isn’t publicly available yet but if anyone wants to grab it early, try it out and feed back to me via this thread I would be very grateful.

You can download it here

Instructions are in the plugin’s help.

Thank you.


Steve

Offline

#7 2006-05-17 19:58:34

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: [plugin] [ORPHAN] sed_display_code

Excellent! I’m going to be starting a Txp-powered weblog sometime in the next couple of weeks. I’ll give this a spin as part of that process. I got your e-mail about preliminary ordered list support, which sounds like a great update as well.

Sorry I didn’t respond to your earlier post asking for details about my feature request. I’ve been so busy lately that the forum subscription e-mail must’ve slipped by undetected. Seems I was wrong about glx_code; on closer examination of the forum thread, it doesn’t use the Txp file manager after all. Somehow I got confused, thinking that the file attribute accepted a file ID number as a value. As for your breakdown of what such a workflow would look like, you’ve pretty much got it nailed. For #3, though, you can grab the info from the Textpattern database. It’s in the file_base_path field of the txp_prefs table.

Offline

#8 2006-05-18 00:24:58

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: [plugin] [ORPHAN] sed_display_code

Hello Adam,

your idea about using the prefs directory is good and will help avoid setup problems too. I’ll work that into the code.

Thank you.

Last edited by net-carver (2006-05-18 10:16:50)


Steve

Offline

#9 2006-06-10 10:40:42

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: [plugin] [ORPHAN] sed_display_code

v0.5 released. (See top post)

Please feedback with any problems here.


Steve

Offline

Board footer

Powered by FluxBB