Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2004-10-28 23:21:48

paularms
Member
From: University of Minnesota
Registered: 2004-10-21
Posts: 155
Website

Re: [archived] glx_code: Dunstans code presentation

I made my own changes to this plugin so that it doesn’t say the path to the file in the link, basically just changed the line to use a different variable $nicefilename = $file.“txt”

I use text-indent instead of padding just in case Internet Explorer has issues. This would obviously be related to a box-model problem, which in general, and with the previously posted styles won’t happen, but it is better general practice to use text-indent for this scenario.

Last edited by paularms (2004-10-28 23:36:50)

Offline

#14 2004-10-29 07:43:11

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

Re: [archived] glx_code: Dunstans code presentation

You could use the attribute <code>sublinktitle</code> to change the title, or change the deafult which is in swedish by edit this line at the top of the plugin code

<code>$linkTitle = “Ladda ner ovanstående kod som en textfil”;</code>

And mayby you want to change the line abow that one to, that line is the default text that shows up under the code

<code>$linkText = “Ladda ner denna kod: “; </code>

> I use text-indent instead of padding just in case Internet Explorer has issues. This would obviously be related to a box-model problem, which in general, and with the previously posted styles won’t happen, but it is better general practice to use text-indent for this scenario.

ahh, good point i think i will change to text-indent later


Johan Nilsson

Offline

#15 2004-11-02 22:41:22

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: [archived] glx_code: Dunstans code presentation

Thanks, this helped a lot and I think it’s definitely more readable! It’ll be even better when I get the background color sorted out.

Offline

#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

Board footer

Powered by FluxBB