Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2004-11-08 21:34:15

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: [archived] glx_code: Dunstans code presentation

I think a slight mod to this plugin is in order for cases in which code might be stored in varying directories. To keep things organized, I often put my code in subdirectories under /code/. I was thinking of something allowing for an optional parameter ‘dir’ like this:

<pre>
$dirname = empty($dir) ? ‘/code’ : $dir;
$filename = $file.”.txt”;
$theFile = $dirname.’/’.$filename;
</pre>

So someone could call it one of two ways:

<code><txp:glx_code file=“mysrc.php” /></code>
or
<code><txp:glx_code file=“mysrc.php” dir=”/code/plugins” /></code>

Offline

#17 2004-11-09 20:47:09

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: [archived] glx_code: Dunstans code presentation

(This extends my previous post)

I’ve also done this modification in the event that I just want to display code, but I don’t want it available for download (entirely possible for small code examples). Basically, I allow for an optional attribute of ‘nosource’ to be passed, i.e. <code><txp:glx_code file=“mysrc.php” nosource=“1” /></code>

<pre>
// add in the link to the file
$list .= ($nosource) ? ‘’ : “<li class=\“source\”>”.$linkText.” <a href=\”/”.$theFile.”\” title=\”“.$linkTitle.”\”>”.$filename.”</a></li>\n”;
</pre>

Offline

#18 2004-11-09 21:19:26

osei
Plugin Author
From: Stockholm, Sweden
Registered: 2004-07-01
Posts: 178
Website

Re: [archived] glx_code: Dunstans code presentation

this is great extends to the plugin, i will update it with this proubably tomorrow, thanks compooter


Johan Nilsson

Offline

#19 2004-11-13 00:53:49

ralfgoeke
New Member
From: Essen | Germany
Registered: 2004-10-12
Posts: 4
Website

Re: [archived] glx_code: Dunstans code presentation

Whoa… my first post ;-)

First off, let me say hi to anybody. Great Community here!

I just ran into an issue with empty lines. Maybe it´s just a MAC-only issue, but however:

In my case, empty lines in the code.txt haven´t been detected properly by the script. Checking for an empty string by simply asking for “” didn´t make the magic if there´s hidden whitespace in the code.

I did a little mod as you can see:

<code>

// if the line is blank, put a space in to stop some browsers collapsing the line

// Here goes the little mod
$trimmed = trim($line);
if ($trimmed == “”)
{
// end of mod

// insert all the information and close the list item
$list .= “<li”.$class.”> </li>”.”\n”;


}
</CODE>

cheers, Ralf

Last edited by ralfgoeke (2004-11-13 00:54:19)

Offline

#20 2004-11-13 01:16:56

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: [archived] glx_code: Dunstans code presentation

welcome to the forum!

Offline

#21 2005-01-16 19:09:40

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

Re: [archived] glx_code: Dunstans code presentation

osei, in the plugin documentation (on the plugin code page in TXP) the tag example contains an error. It says <txp:code file="1" /> while it should be <txp:glx_code file="1" />.

Offline

#22 2005-01-18 09:19:28

osei
Plugin Author
From: Stockholm, Sweden
Registered: 2004-07-01
Posts: 178
Website

Re: [archived] glx_code: Dunstans code presentation

New version 0.3

  • dir parameter added
  • nosource parameter added
  • Added supoort for html comments like <code><!— Comment —></code>
  • Default language changed to English instead of swedish
  • Typos

todo:
There are some problems both with the <code>/* comment */</code> and <code><!— html comment —></code> they dont work when they are on just one line.

I have to come up with some solution here, or if anybody out there have any idea i sure will listen.

And thanks for all the great ideas you are sharing compooter.

Last edited by osei (2005-01-18 09:21:37)


Johan Nilsson

Offline

#23 2005-01-18 13:47:16

ChrisJ
Member
From: Vienna, Austria
Registered: 2004-03-30
Posts: 54
Website

Re: [archived] glx_code: Dunstans code presentation

osei, you are a &#9733;

Offline

#24 2006-01-02 19:44:08

alexandra
Member
From: Cologne, Germany
Registered: 2004-04-02
Posts: 1,370

Re: [archived] glx_code: Dunstans code presentation

Could anybody installed this plugin on txp 4.0.3 ??

I get a:
Notice: unserialize(): Argument is not a string in /www/htdocs/…/include/txp_plugin.php on line 155

Last edited by alexandra (2006-01-02 19:45:56)

Offline

#25 2006-01-03 07:05:57

1beb
Plugin Author
From: Canada, Ontario, Toronto
Registered: 2004-11-22
Posts: 169
Website

Re: [archived] glx_code: Dunstans code presentation

Offline

#26 2006-05-10 11:11:29

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

Re: [archived] glx_code: Dunstans code presentation

1beb wrote:

Updated link to file

Which version is that? Latest I’m aware of is 0.3…

Offline

Board footer

Powered by FluxBB