Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

File include in Global Vars?

Quote Reply
File include in Global Vars?
Is GForum able to use file include tags in globals?

e.g.: <%include test.html%> ?

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] File include in Global Vars? In reply to
No, they can't. Globals are stored as strings for the template parser, and aren't parsed again themselves. The include would have to go into a template.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] File include in Global Vars? In reply to
Aren't parsed again themselves? Why again? It seems globals are not parsed at all!

Is there any reason why you did not wanted to parse it?
I think parsing the globals is a necessary thing (or at least to make it available optionally).
And I don't think, that there are any disadvantage of parsing the globals. Are there?

Just imagine the situation of the Body starting & closing globals.
Let we create a 2 column table in the body:
- In the first column we want to place (include) a menu from test.html
- In the second column we place the Forum itself
Imagine how easy would it be to do it, if we have global parsing, and how could we solve it without it.

GForum is fully dynamic, so using SSI tags are not posible in cgi output. Body tags are useful so we must keep them. Finally, if we don't do parsing of globals, we are not able to include any menu file in the left table column.

Adding parsing of globals, I think is an easy task. The question is, if GT wants to implement it, or not?
I suggest to implement global parsing, and make parsing of globals OPTIONAL, so the user can decide if he needs this feature or not.
This way the feature is available, but if somebody doesn't want to use it, the user turns off parsing option and will not feel any speed decrease. It is that easy.

I think it would be a fair solution. But that's only my opinion.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] File include in Global Vars? In reply to
>>
Aren't parsed again themselves? Why again? It seems globals are not parsed at all!

Is there any reason why you did not wanted to parse it?
I think parsing the globals is a necessary thing (or at least to make it available optionally).
And I don't think, that there are any disadvantage of parsing the globals. Are there?
<<

Globals are perl code or simple strings.....the parser is a template parser.

If you parsed it again it would be doing twice the amount of parsing and would slow things down considerably.

I don't unserstand why you'd want to do it. Any output created by a tag can be done with perl code anyway without loading the parser.

>>
Finally, if we don't do parsing globals, we are not able to include any menu file in the left table column.
<<

Of course you can. You know how to use open() and close() right? Wink

Last edited by:

Paul: Apr 29, 2002, 5:50 AM
Quote Reply
Re: [Paul] File include in Global Vars? In reply to
Paul,

Quote:
If you parsed it again it would be doing twice the amount of parsing and would slow things down considerably.
Let me know why it is parsed 2x?
If I place <%include test.html%> it is left untouched in the source code, so you can view the tag in the browser source.

What this means?
a) The template is parsed first
b) The global content is inserted into the template (or executed if it is a sub)
c) The global was not parsed

I suggested to parse only the global (not the full template again).
Paul, please explain me, why the global is parsed 2x?

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] File include in Global Vars? In reply to
>>
I suggested to parse only the global (not the full template again).
Paul, please explain me, why the global is parsed 2x?
<<

Yeah but in order for the global to be processed you need to put a tag in your template...there is parse number one.....then you are suggesting putting tags into the global which need to be parsed...there is parse number two.

Also how are you going to distinguish between perl globals that don't need parsing and non-perl globals that do?

It just doesn't seem like a practical idea imo.

Last edited by:

Paul: Apr 29, 2002, 6:57 AM
Quote Reply
Re: [Paul] File include in Global Vars? In reply to
Paul,

Quote:
Yeah but in order for the global to be processed you need to put a tag in your template...there is parse number one.....
Not really. Currently there are unnecessary tags used in the templates such
<%body_table%> and
<%/body_table%>, right?
Yes are right, user would not need to add extra tags, because these are already used in original templates... Wink

The bottom line... No, there are no need to place extra tags into your template, and No there will be no need to parse anything 2x.
In addition I suggested global tag parsing as an option (you can turn it on-off), so if you really hate to place tags into globals, just turn off this option... Wink Or even better, if the default option value is to be turned off.


Quote:
then you are suggesting putting tags into the global which need to be parsed...there is parse number two.
Yes of course.
Because:
a) once there is a need to put something into a global, the global needs a global tag. Now we already have the <%body_table%> tags, so we do not need to add them.
b) once we have a global tag, and we would like to place some tags into that global, we should able to place it there. Therefore global would be need to be parsed for tags (only if global template tag option is turned on).


Quote:
Also how are you going to distinguish between perl globals that don't need parsing and non-perl globals that do?
Are you asking seriously?
Perl globals have the exact syntax... Perl globals Must have the following format:
sub { your code }
So why is a problem for you, to distinguish between perl globals and non-perl globals? Smile

Paul, my opinion is still the same: I think, it is a good idea to implement this feature as I suggested.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Post deleted by Paul In reply to

Last edited by:

Paul: Apr 29, 2002, 9:13 AM
Quote Reply
Re: [Paul] File include in Global Vars? In reply to
Oh, you just deleted your post. Anyway, I aggree you.
Alex & GT staff will decide if they aggree to make template tag parsing available in Globals or not.
If yes, this will affect both Links SQL & GForum scripts.

We will wait their opinion.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] File include in Global Vars? In reply to
Hi,

The template parser doesn't understand the concept of globals. It just parses a template, and a hash ref of tags to do replacements of. If you allowed template tags themselves to be parsed, you are opening up the possiblity of cgi input being parsed (i.e. someone passes into your script tag=<%include /etc/passwd%>).

The application (Links SQL, GForum, etc) would need to mark ceartain tags as safe, and allow the template parser to reparse them. You couldn't preparse the tag, as you might not have all the variables, i.e.:

<%loop some_loop%>
<%global%>
<%endloop%>

When does the output of <%global%> get parsed? After it's displayed? What if the output to of global contains temlate tags, it would then get parsed as well. It gets very nasty, very quickly.

This would add a significant overhead as every global would need a separate call through GT::Template->parse. I can see the use for it in some cases, but I think the performance hit is too great.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] File include in Global Vars? In reply to
Alex,

The template parser would not need to know very much about the globals.
The sub { ...perl code... } information could be used to find the perl code parts in globals and
ignore parsing of anything between sub { and }, therefore I don't aggree with you,
that there is security leak using the way I suggested here.


Quote:
This would add a significant overhead as every global would need a separate call through GT::Template->parse. I can see the use for it in some cases, but I think the performance hit is too great.
Yes, I aggree with you about the performance hit. It is only worth to implement parsing of globals, if the performance will be not affected very much.
But I think, ignoring the sub { ...perl code... } in globals would not affect performance very much, just a bit. And remember globals means mostly small strings, especially if we ignore the perl code parts...

In addition, if you add the Global parsing feature option which make possible to turn off parsing of globals, then users could decide themself, if they need to use this feature or not.
Because the performance thing we discussed, I suggest the Global parsing feature option
to be turned OFF by default.

Let me know your opinion.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] File include in Global Vars? In reply to
>>
The sub { ...perl code... } information could be used to find the perl code parts in globals and
ignore parsing of anything between sub { and },
<<

If you could get around the security implications it will still mean that perl code has to be filtered out from parsing which would again affect performance.
Quote Reply
Re: [Paul] File include in Global Vars? In reply to
Paul, I did not write such, that it will not affect performance!
I wrote that it is possible, that it will be not affect performance very much.

In addition, if the Global parsing feature option is added, and it is turned off,
then performance will be not affected at all
!

I'm curious what Alex thinks finally about that.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...

Last edited by:

webmaster33: Apr 29, 2002, 2:13 PM
Quote Reply
Re: [webmaster33] File include in Global Vars? In reply to
Hi,

It would be difficult to implement. Currently the template parser recognizes:

scalar => regular string
scalar_ref => string that does not get html escaped
code_ref => execute code
array_ref => loop variables
hash_ref => new tags to include

How would it recognize a regular string versus a string that should get parsed?

Also, wouldn't it be much simpler to just do <%include someglobal.txt%> instead?

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] File include in Global Vars? In reply to
Hi Alex,

Thanks your response & your time! I accept your opinion.

BTW: I posted an another suggestion to Links SQL: Discussions forum, post "[Suggestion] Template path change for file includes".
It is related to <%include something.html%>. Could you check it and post your opinion?
I would appreciate it.


Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...