rejetto forum
Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: Mars on December 08, 2007, 06:21:58 PM
-
Some ideas of macro for the continuation
%symbols% : Text HFS symbols
%mysection% : HTML Text for compatibility with old templates
// Boolean must be TRUE or FALSE , nothing else
{{ not | Boolean | /not }} : Boolean result= not(Boolean)
{{ and | Boolean1 | Boolean2 | ... | BooleanN | /and }} : Boolean result= Boolean1 AND .... AND BooleanN
{{ or | Boolean1 | Boolean2 | /or }} : Boolean result= Boolean1 OR .... OR BooleanN
{{ xor | Boolean1 | Boolean2 | /xor }} : Boolean result= Boolean1 XOR Boolean2
{{ is == | Num1 | Num2 | /is }} : Boolean To be NEW
{{ is >= | Num1 | Num2 | /is }} : Boolean To be NEW
{{ is <= | num1 | Num2 | /is }} : Boolean To be NEW
{{ is <> | Num1 | Num2 | /is }} : Boolean To be NEW
{{ is >> | Num1 | Num2 | /is }} : Boolean To be NEW
{{ is << | Num1 | Num2 | /is }} : Boolean To be NEW
{{ is def | urlvar| /is }} : Boolean return TRUE if URLVAR is defined in url To be NEW
{{ is equal | Text1 | Text2 | /is }} : Boolean
{{ is empty | Text | /is} : Boolean To be NEW
{{ is substring | subText | Text | /is} : Boolean
{{file|name|url}} '' or a name To be NEW
{{file|size|url}} '' or >=0 To be NEW
{{file|date|url}} '' or a date To be NEW
{{file|empty|url}} true or false To be NEW
{{file|exist|url}} true or false To be NEW
{{if | Boolean | then | else | /if }} : Text
{{ if not | Boolean | then | else | /if }} : Text
{{ switch | What | Text1 | Result1 | Text2 | Result2 | .... | TextN | ResultN_ as_Default | /switch }} : Text
{{ pos | subText | Text }} : Num To be NEW
{{ length | Text }} : Num
{{abs| value}} Abs Returns the absolute value of a signed number
{{max| value1 | value2 |...| valueN }} Max Gives the maximum of some integer values
{{max| value1 | value2 |...| valueN }} Min Gives the minimum of some integer values
{{calc | numerical expression to be evaluated }}
syntax:
{{calc | num1 | + | num2 | - | ( | num3 | / | num4 | ) | * | -num5 }} or
{{calc |num1+num2-(num3/num4)*(-num5) }}
{{ left | Text | Num }} : Text To be NEW
{{ right | Text | Num }} : Text To be NEW
{{ mid | Text | Num-From | Num-Upto }} : Text To be NEW
{{ upper | Text }} : Text
{{ lower | Text }} : Text
{{ trim | Text }} :Text
{{ repeat | Num | Text }} : Text
{{ substring | From-After-Text | To-Before-Text | Text-Source }} : Text
{{ cut | Num-From(begin) | Num-Upto(end) | Text }} :Text
{{ replace | Text-Old | Text-New | Text-Source }}
{{ chopline | Num | Text-Source}} : HTML Text To be NEW
{{ section | mysection }} : HTML Text load section from active template
(included "diff template" and hfs.diff.tpl) idem as %[mysection]%
{{ section | mysection | external_file}} : HTML Text load mysection from external template
{{load | external_file}} : HTML Text
{{load | external_file | from-line | Upto-line }} : HTML Text To be NEW
{{translate|text}} translate any text to UTF-8 To be NEW
{{alias| name | html-text}} call by {{$name}} To be NEW
return html-text can be use as variable
{{inc | $name | value }} To be NEW
{{dec| $name | value }} To be NEW
at the place of {{alias|name|{{calc|{{$name}}+ value}} }}
{{define | newmacro | {{macro|$1|$2|$3|....}} }} To be NEW
call by {{newmacro| param1|param2|.....}}
http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros
-
Mars:
I'am far from trying to discourage you from proposing new macros, but we should care not to increase the number of macro-functions without increasing funcitionality.
{{ left | Text | Num }} : Text
{{ right | Text | Num }} : Text
{{ mid | Text | Num-From | Num-Upto }} : Text
for example can already be done wit cut.
Also it would be very nice if you could explain what the macros that are not already en the wiki should do, like 'chopline' and 'replace'.
-
cut | A | B | C
cut C from position A, for B characters. The difference with macro substring is that here you specify where to cut by numeric positions. Example: with A=2 and B=3 and C=abcdef you will get bcd because it is from character 2 and for a length of 3.
The name of this macro seems to me misleading, the "copy" word would been more adequate
How many programmers uses exclusively the function 'copy(string, from, to) ??
Mainly in the programs, we find rather its by-products which are left, mid, right.
To return to the macro 'cut' there, she executes what makes the function 'copy', excepted for the negative values where it makes exception for the rule.
On this question I would rather have seen the macro cut under this aspect
cut | A | B | C
Example: with C=ABCDEFGHIJ A=3 and B=4 and ,you will get ABGHIJ
It was everything made possible to make the difference enter
{{substring| AB | GHIJ | ABCDEFGHIJ }}
and
{{substring| 3 | 4 | ABCDEFGHIJ }}
without passing by the macro CUT, because few chances to meet itself in the indecision with
{{substring| 3 | 4 | 428635710]4598 }}
Rejetto I have nothing against the command CUT it is simply to argue against bacter ;),I excuse him for it. I shall put that at the account of the difference of age, the other time(period), the other philosophy. ;D ;D ;D ;D ::)
At least this debate has to make nothing in this topic.!!!
-
The name of this macro seems to me misleading, the "copy" word would been more adequate
I guess you are proposing the word "copy" because you are used to Delphi. This is not what i call "a good reason", and people are not required to know Delphi.
The name copy in Delphi is due to the fact the function does a copy of a piece of the string.
If you use {{cut}}, you are not storing the original string, that is, you didn't copied.
On this question I would rather have seen the macro cut under this aspect
yes, i guess not everyone will agree with the meaning.
At least this debate has to make nothing in this topic.!!!
indeed, i moved it
-
;)
C++
size_t copy ( char* s, size_t n, size_t pos = 0) const;
http://www.cplusplus.com/reference/string/string/copy.html
*************************************************************
autre chose:
{{TRANSLATE | récursif ou linéaire, où à n'être rien }}
result = récursif ou linéaire, où à n'être rien
{{TRANSLATE |
<PRE>
L'accent en italien est écrit uniquement sur la dernière syllabe.
ex: città, virtù, libertà, lunedì, Nicolò, cioè
Dans ce cas, ces mots sont invariables au pluriel.
</PRE>
}}
result= .....
la macro convertirait les codes accentués en leur equivalent html unifié.
usage {{translate | {{load|texte_accentué.txt}} ]]
-
if your template is UTF-8 you don't need to convert characters.
also external .txt files can be saved as UTF-8, even with notepad.
if for any reason you have external ANSI files that you need to include, i will create a macro to convert in UTF8, because it would be easier to do.
-
{{ is == | Num1 | Num2 | /is }} : Boolean To be NEW
{{ is >= | Num1 | Num2 | /is }} : Boolean To be NEW
{{ is <= | num1 | Num2 | /is }} : Boolean To be NEW
{{ is <> | Num1 | Num2 | /is }} : Boolean To be NEW
{{ is >> | Num1 | Num2 | /is }} : Boolean To be NEW
{{ is << | Num1 | Num2 | /is }} : Boolean To be NEW
{{ is def | urlvar| /is }} : Boolean return TRUE if URLVAR is defined in url To be NEW
These would be very useful.
Posted on: December 10, 2007, 03:15:44 PM
to save creating a new topic im posting my sugestion here
user created macros aka user created functions. The possibility to write a complex macro and place it in a user created function with custom parameters would be useful.
to call it {{call function | function-name | $A$ | $B$ |...}} A and B are the custom parameters.
to create {{function | function-name | $A$ | $B$ |...}}{{the macros to execute}} A and B define the parameters just like in javascript function (A,B,C){}...
eg {{call function | addition | 1 | 3 | 5}} 9 would be returned.
{{function | addition | $A$ | $B$ | $C$}}{{{{add | $A$ | $B$ | $C$}}}}
or you could even have the commands to execute as the last parameter, so the example above would be
{{function | addition | $A$ | $B$ | $C$ | {{add | $A$ | $B$ | $C$}}}}
Edit: Simple addition and subtraction, etc would be useful. Im working on something now that I must subtract one number from another so i know how many times to repeat itself.
-
is it possible to check the user agent, cause i have some macro's that are just IE fixes... be nice to turn em off for IE.
-
The possibility to write a complex macro and place it in a user created function with custom parameters would be useful.
to call it {{call function | function-name | $A$ | $B$ |...}} A and B are the custom parameters.
A macro is a function to her alone, it uses parameters and returns a result as string, actualy only one macro give a numeric value :{{length|string}
For your demand I propose a macro one specialized in the calculation, of the genre:
{{calc | num1 | + | num2 | - | ( | num3 | / | num4 | ) | * | -num5 }}
identical to
num1 + num2 - ( num3 / num4 )*(-num5)
it will be posible to have
{{calc|num1+num2-(num3/num4)*(-num5)}} to reduce length
then simply functions as A+B, A-B, A*B are possible
A/B is more complicate if result is not an integer, he can be truncated or rounded to the nearest integer. result of A/B can be the quotient and result of (A%B) give the rest of the division (modulo)
Or result can be a real, rejetto has the choice
I will search code to this macro
-
another 3 macros to add
Abs Returns the absolute value of a signed number {{abs| value}}
Max Gives the maximum of some integer values {{max| value1 | value2 |...| valueN }}
Min Gives the minimum of some integer values {{max| value1 | value2 |...| valueN }}
Quote a macro and give your opinion for or against ( If possible, only favorable notices; ;) to bacter)
-
Still I
Instead of writing several times the same macro in a template, we could use alias
{{ alias | alias-name | {{macro defined to be an alias}} }}
Working on the same principle as the call to sections {{$section}}
{{ alias | myalias | {{ my macro}} }} talking by {{$myalias}}
Replaceable also by
{{$myalias}}
[myalias]
{{my macro}}
it is possible to put any alias in an external file and load it by {load|alias.tpl}
{{alias|...}} don't appear into user's browser and is considered by hfs as macro {{comment ...}} , but who works as a [section].
NOTE: It will be possible to use {{alias| name | some text}} and call it by {{$name}} and then we have a string var
{{alias| rejetto | The person without whom we would not be on this forum there}}
{{$rejetto}} ---> The person without whom we would not be on this forum there
{{alias | minval | -2 }} {{$minval}} ---> -2
{{alias | maxval | 255 }} {{$maxval}} ---> 256
I hope to have been rather precise so that everybody understands
-
Now we are getting more close to what macros can be!
The idea of 'alias' and rejettos idea of (pound or &)name in a [special] section -->http://www.rejetto.com/forum/index.php?topic=5349.msg1030874#msg1030874 (http://www.rejetto.com/forum/index.php?topic=5349.msg1030874#msg1030874).
First we have to pay attention: a {{comment ...}} will just be ignores when building the page, but when parsing the tpl, it's different if there appears a 'normal' macro that will be evaluated and applied, or if there appears a 'special' ,as i would like to say, definitions macro: there is nothing to evaluate, only to 'learn or remember' the new definition for future use.
Both things, the alias proposed by mars and rejettos idea of [special ...] could be done the same way. You could think about it in the style of #define in C-preprocessor.. if we could enhance de macrodefinition with parameter replacing, the need for 'hardwired' functions would be less and users could write definitions of their preference:
Look at this (alias or define, may be the same) in a headerfile or section:
{{ define | left{{#str|#len}} | {{cut | 0 | #len |#str }} }}
.. and in the same style mid, right etc.
-
Look at this (alias or define, may be the same)
NO they are different
define use parameters over parameters like
define function left(str,len);
{
result:=copy(str,0,len);
};
ALIAS do not work in the same way
ALIAS is transparent as the macro COMMENT,
{{alias|name|text you want}}
but what you define is accessible simply by {{$name}}
bacter, you must read all line from begin to end in my posts ??? here I repeat twice same things
{{$myalias}}
[myalias]
{{my macro}}
or
{{$myalias}}
[myalias]
my text
with this sample {{$myalias}} is fixed
but with {{alias|myalias|text you want}} you can redefine it
<HTML>
<HEAD>
{{alias|myalias| my alias is in head}}
</HEAD>
<body>
here,
{{$myalias}}
{{alias|myalias|-->now he is in body}}
<br>
{{$myalias}}
</BODY>
</HTML>
here, my alias is in head
-->now he is in body
but {{define| ....} is not a bad thing,
-
These would be very useful.
ok, in next build
user created macros aka user created functions. The possibility to write a complex macro and place it in a user created function with custom parameters would be useful.
i will look if that's possible
Edit: Simple addition and subtraction, etc would be useful. Im working on something now that I must subtract one number from another so i know how many times to repeat itself.
in next build
-
is it possible to check the user agent, cause i have some macro's that are just IE fixes... be nice to turn em off for IE.
you long wondered what the {{header}} was for
{{header|user-agent}}
but also have a look at http://www.quirksmode.org/css/condcom.html
Posted on: 11 December 2007, 02:03:44
{{calc|num1+num2-(num3/num4)*(-num5)}} to reduce length
i will work onto this, and maybe tha alias/define story
-
lol, yes i am already doing that. But i noticed the {{header}} macro and was wondering if i can turn all off all IE js events, they fix IE6's lack of support for the css param :hover on objects other than a:, in firefox and opera i just have 2 fake functions so it doesn't fire off errors. But i would rather not have them at all. I will play with {{header|user-agent}}
EDIT: It seems i need a macro with indexOf... or match... in javascript you say, if(navigator.userAgent.indexOf("MSIE")!=-1)
{{if|{{header|user-agent}}|indexOf|{{string|MSIE 6.0}}|{{$DO THAT}}|{{$DO THIS}}/if}}
i don't know the exact syntax but ye... something like that.
scrap that {{if|{{is substring|MSIE 6|{{header|user-agent}}/is}}|CONTENT/if}}
Posted on: December 11, 2007, 10:55:59 AM
Ok another idea, im trying to do my entire filelist in the single [file] by looking at %item-ext%.
I need the ability to go either, if else if else if else or
if value = this or this or this, print this, else print this.
possible? ;) this new template of ours i want to be the cutting edge of template technology :) and im bored.
reason for this is easy editing, if i can have it all in one section it'll be so much easier than copy/pasting to 5 or 6 sections, which i believe is one of the purposes of the macro :P
-
I'm trying to use this for the not found error page but I'm not getting anything returned where the header macro is. I think I have done the syntax for it right, so am I doing something wrong?
The requested URL {{header | GET}} was not found on this server.
-
alias mars:
you can be sure i read your post from start to end, sometimes even several times, when i'm not sure that i have understood what you mean.
What i understand with redefining an alias, is that you want to use this thing in some way like a variable, that could be very useful.
On the other hand you use it in some way as a section, then its used like %section%, being able to call different section by the same name.
What i do not see now, is if you assign to the alias name the expression or the value of the expression!
Example (to see what i mean i dont use {{}}macro syntax):
Somebody wants to show what file of the list was most downloaded and how many times.
So in the files section he inicializes: {{alias | fname | noname }} {{alias | maxhit | 0}}
in the file section then he compares and assigns :
// as 'ifgreater | val1 |val2 | dosometing | elsedosomething' or {{ is >> | Num1 | Num2 | /is }} are not already impelemented, i use borrowed sintax:
{{ifgreater | %item-hit% | maxhit | {{alias | maxhit | %item-hit%}}{{ alias | fname | %item-name% }} | }}
if the order of evaluation is ok, something like this may work ... but supose you have 10 files, and file number 6 had most hits.
at he end of the list {{maxhit}} will show 22 (numer of hits of file number 6) or 3 (number of hits of the last file, as %item-hit% holds value of the last item or will it be undefined as outside [file] %item-hit% does not exist? (same problem for fname!)
-
template to your sample (when all macros are ok to rejetto)
[files]
{!--
{{alias|fname|}} fname=''
{{alias|maxhits|0}} maxhits=0
--}
....
%list%
....
{{if|{{$fname}}|Best hits to {{$fname}} with {{$maxhits}} downloads}}
....
[folder]
....
[link]
....
[file]
{!--
{{if |{{is >>| %item-hit% | maxhit}} | {{alias | maxhit | %item-hit%}}{{ alias | fname | %item-name% }} }}
--}
...
that all
initiate values
%list%
see the result
in this order to what you hope to do
-
Mars:
You have expanded a little the code i put as example, but you didn't answer to the important point of the question ! I wonder if i should use in the same way
bacter mars, you must read all line from begin to end in my posts Huh? here I repeat twice same things
:D :D :D
So, if you are saying that your example code works, this means that with alias the expression is evaluated when the macro is defined, e.g the macro will hold the value of the expression.
{{ alias | name | expression } :
so if expression is %item-dl-count% , name will hold the value of %item-dl-count%
So far, that's very good. That implies ve have variables!
But here arises the big problem:
{{ alias | alias-name | {{macro defined to be an alias}} }}
example:
if i define this alias in the files section before list:
{{ alias | isimage | {{ if |=|{{cut(-3|3|%item-name%}}||img | This is a disk image|}}}}
and then try tu use it in the file section:
[file]
<tr><td>%new% <a href="%item-url%"><img src="/~img_file" /> %item-name%</a>%comment%{{isimage}}<td align=right>%item-size%<td align=right>%item-modified%<td align=right>%item-dl-count%
what would happen?
If your first example (the maxhit code) works because the value of expression is evaluated ad assigned to the alias, i think the second example can't work, because when the expession is evaluated, %item-name% is not already defined and evaluation should produce an error!
Is there something i missed to understand or could you explain what would be the behaviour of alias with expression?
alias assigns expression or value of expression to alias-name?
Thanks
-
>%comment%{{$isimage}}<td
this means that with alias the expression is evaluated when the macro is defined,
yes it is
{{ alias | isimage | {{ if |=|{{cut(-3|3|%item-name%}}||img | This is a disk image|}}}}
{{ if |=|{{cut(-3|3|%item-name%}}||img | This is a disk image|}} is evualuted, and isimage get the result
if i define this alias in the files section before list:
{{ alias | isimage | {{ if |=|{{cut(-3|3|%item-name%}}||img | This is a disk image|}}}}
{{ alias | isimage | {{ if |{{=|{{cut|-3|3|%item-name%}}|img}} | This is a disk image /if}} }} is more correct
Symbols available in section [files]
%list%
%item-archivable%
%item-ext%
Symbols available in sections [file], [folder] and [link]
%new%
%comment%
%item-url%
%item-name%
%item-folder%
%item-added%
Quote
user created macros aka user created functions. The possibility to write a complex macro and place it in a user created function with custom parameters would be useful.
i will look if that's possible
http://www.rejetto.com/forum/index.php?topic=5353.msg1030947#msg1030947
to have what you will there is new feature {{define|user-function|rejetto-function}}
Is there something i missed to understand or could you explain what would be the behaviour of alias with expression?
you can use
{{alias|hfsini|{{load|/hfs.ini}} }}
and then alias='
HFS 2.3 beta - Build #161
active=yes
.....
folders-before=yes
'
{{alias|my alias|<body>........</body>}}
whats you put after myalias| must be a string as result
{{alias|len|{{length|%user%}} }}
ce ne sont pas le possibilités qui manquent....
if you will a not evaluated then you must use sections instead alias
[isimage]
{{ if |{{=|{{cut|-3|3|%item-name%}}|img}} | This is a disk image /if}}
and talk it by {{$isimage}} in the section [file] (because you use %item-name%)
-
It would be nice to detect if a file is not available. Atm for our image gallery we use javascript, and it can be quite a load on cpu with big galleries.
The ability to server side with a simple if, will reduce this dramatically :) and have a more professional finish.
What we need, is the ability to say, {{If|The file At This Directory Is Unavailable|DO THIS|DO THIS}}, another reason is that onError="" is very unreliable, and we rely on it :P
I tried the below but as you would think, doesn't work :P
{{if|{{load|previews_and_thumbnails/thumb-%item-name%.jpg}}|DO THIS|DO THAT}}
-
Eh TSG! What do you think of that?
{{if|{{length|{{load|/rien.txt}}}}|file exist|file is empty or not exist}}
{{if|{{length|{{load|/hfs.ini}}}}|file exist|file is empty or not exist}}
-
I need to detect jpg images though?
Sorry that was vague..
I need to detect if a file exists, but i don't think load will work cause it only supports text files, or code, etc.
-
I am anxious to remind a very important thing:
ALL THE MACROS ARE EXECUTED AT THE LEVEL OF THE SERVER
ALL THE JAVASCRIPT IS EXECUTED AT THE LEVEL OF THE BROWSER
***********************************************************************
Everything depends on how much file are to be detected and also of the size, because every file is read in its entirety to determine its size. If you make this for all the items, it will be longer than for one ?ecursive, and hfs risks to make an out of memeory (file-size >100Mo by sample)
The ideal would be to have complements to macro for the load function without loading all the file in memory
{{load|url}}
{{file|name|url}}
{{file|size|url}}
{{file|date|url}}
...
sample (it is only a sample):
{{file|size|c:\.....\file.ext}} will rerturn the exact size
but {{file|size|http://server/......./file.ext}} has no sense then you can by-pass the problem by using
{{length|{{load|http://server/......./file.ext}} }}
-
I don't want to detect the file size, just IF its there, if there is actually an object available to download or not. If its a dead link, do this else do that. And i agree, i don't want to increase the cpu on the server side too much.
-
- If the file is in a real folder, even as virtual file, if it is not available on your hard drive, he does not appear in the list (by [file] %item-name% ) hfs exclud possibility to see this file)
- If the file is stored at an external address to the server and accessible only by http or ftp
you can just use in template {{length|{{load|http://server/......./file.ext}} }} to detect if file is accessible. if you use a [link] as http://...../file.ext then file is in hfs list, even if the link is void.
(virtual link with set url file:///c:/..../file.ext seem not working but appear in hfs list)
in [link] and [file] sections you can test {{if|{{length|{{load|%item-url%}}}}| file exist|file not exist }}. you receive the same result as at the first possibility.
I can certenly help you TSG, but it would be necessary to be more precise to allow me to see the reach of your wait by a little example in tpl.
-
ehmm... it is hard for me to give as an example... but i can give pieces.
This determines if the filetype is a compatible image file with our generator, and prints out the correct overlay image.
{{switch|%item-ext%|,|jpg,png,bmp|
<div style="background:url('previews_and_thumbnails/thumb-%item-name%.jpg') center center no-repeat"></div>|}}
Now, for our preview button, if there is no thumbnail available, it is assumed that there is no preview available, so in the ToG and Terayon we use <img blah onError="DO THIS"> but with large galleries, this can be harsh on the client cpu usage. What i am suggesting is the ability to say, if the file does not exist, disable the preview button. We have to disable the button, it prevents js errors.
This file is located at... 'previews_and_thumbnails/thumb-%item-name%.jpg' in the image gallery or folder. I really hate the way onError works and i hope this can be achieved with a little server side scripting. :) macro
Note the image without a thumbnail.
-
Suggestion for new macro:
{{ if filexist | filepath | dosomething | elsedothat }}
in the case of TSG this could mean:
filepath : thumbnailfilepath,
dosomething : <img src={{$thumbnailpath}} / >,
elsedothat: <img src="%itemurl%" width=160 height=140 >
other possible uses could be:
- sidebarinfo: if a file with additional information for a folder exists, when this folder is opened, show content of this file in sidebar (something like a huge foldercomment, that is only read when folder is open)
- look for personal messagefile for a user and display it on homepage when he logs in.
- if displaymode is slideshow, if musicfile for this folder exists , playit.
-
It increases the number of macros IF and reduct the field of application
It is easier to have a macro which returns a result and to include him in a IF THEN ELSE
{{file|name|url}} '' or a name
{{file|size|url}} '' or >=0
{{file|date|url}} '' or a date
{{file|empty|url}} true or false
{{file|exist|url}} true or false
*************
{{ not | Boolean | /not }} true or false
{{ and | Boolean1 | Boolean2 | ... | BooleanN | /and }} true or false
{{ or | Boolean1 | Boolean2 | /or }} true or false
{{ xor | Boolean1 | Boolean2 | /xor }} true or false
you dont having
{{if and|.....|then|else}}
{{if or|.....|then|else}}
{{if xor|.....|then|else}}
{{if not |.....|then|else}} is an exeption
then
{if|{{file|exist|url}}|then|else}}
-
{{if|{{file|exist|url}}|then|else}}
I like it. :D
-
The requested URL {{header | GET}} was not found on this server.
the command line (the first line) of the header is not handled.
what you need it for?
-
user created macros aka user created functions. The possibility to write a complex macro and place it in a user created function with custom parameters would be useful.
to call it {{call function | function-name | $A$ | $B$ |...}} A and B are the custom parameters.
to create {{function | function-name | $A$ | $B$ |...}}{{the macros to execute}} A and B define the parameters just like in javascript function (A,B,C){}...
eg {{call function | addition | 1 | 3 | 5}} 9 would be returned.
{{function | addition | $A$ | $B$ | $C$}}{{{{add | $A$ | $B$ | $C$}}}}
or you could even have the commands to execute as the last parameter, so the example above would be
{{function | addition | $A$ | $B$ | $C$ | {{add | $A$ | $B$ | $C$}}}}
Edit: Simple addition and subtraction, etc would be useful. Im working on something now that I must subtract one number from another so i know how many times to repeat itself.
{{ define | left{{#str|#len}} | {{cut | 0 | #len |#str }} }}
After a lot of reflection, I think of having found the solution:
To overload a macro or define a macro instead of the other one, we can use this macro
{{yourmacro|A|B|C|D|.....}} to use it
parameters A,B,C,D,.... are passed in this order $1,$2,$3,$4,..... to the overloaded macro
to define your macro you must use
{{define| yourmacro| {{one_macro|$1|$2|$3|$4}} }}
you can invert some parameters as ...
{{define| yourmacro| {{one_macro|$4|$2|$1|$3}} }}
...to accommodate the order of your parameters in agreement with the macro overloaded
by sample {{ define | left | {{cut|0|$1|$2}} }} usage {{left|($1)|$2}}
It will be possible to extend to more macros as
{{define| yourmacro | {{firstmacro|$3|$4}} {{secondmacro|$1|$2|$3}} {if|$4| then|else}} {{$5}} }}
but is is important that $5 must be passed as '$name' with the $ before name, otherwise the call of macro {{$name}} will not work, the risk is that you obtain {{name}} on the place.
-
{{ if filexist | filepath | dosomething | elsedothat }}
ok, in next build you'll find {{file size|PATH}}
so you will be able to do it with {{if| {{file size ...
it will return 0 for non existant files, and zero is "false" in macros.
99% we won't need a {{file exists}} because we are normally not interested in empty files.
-
if the order of evaluation is ok, something like this may work ...
at the moment there's a problem with evaluation order: ALL is evalutade.
in {{if|test|then|else}} both then and else are executed, but else is discarded.
this was ok till now, but it's not good for some useful macros to come, so i will work on it.
-
{{define| yourmacro| {{one_macro|$1|$2|$3|$4}} }}
yes, this is good. I would call it {{set}}
to avoid name collision with existing and future macro names, a starting character will be required. I propose {{!mymacro}}
Is there something i missed to understand or could you explain what would be the behaviour of alias with expression?
i think we need just 2 different types of macros: one that will be evaluated immediately, and one that will be evaluated when called.
maybe {{set}} will evaluate, while {{set later}} will do it later.
i think they should share the same namespace, then you would call always by {{!the-name-i-want}}
of course parameters $1 $2 will make sense only for {{set later}}. {{set}} will handle things like they would be "variables".
-
rejetto
That do you ask SET is I ask ALIAS
That do you ask SET LATER is I ask DEFINE
'set' is good instead 'alias' but 'set later' can make confuse, you must choice another word like 'set macro' because their syntax are differents
{{set | name | text or macro}} call by {{$name}}
{{set var| varname | text or macro immediatly evaluated}} call by {{!varname}}
{{set macro| macroname | {{M1|...}}{{M2|....}}....}} call by {{macroname}}
*****************
{{set |.....}}
{{set | you | %user%}} it is a fixed string value you can redefine
{{$you}} is replaced by %user% (working like{{$section}})
works as you use
[you] call by {$you}
%user%
*****************
{{set var|.......}}
can be use as a variable you increase or decrease
{{set var| varname | num value }} call by {{!varname}}
{{set var|x | 5}} {{inc | x |2}} and then {{!x}} give 7
{{inc | name | value }} same as {{set var| x | {{!x}} +2 }}
{{dec | name | value }} same as {{set var| x | {{!x}} -2 }}
result must be stored by hsf to can to work later with {{inc|..}} and {{dec|..}}
*****************
{{set macro|....}}
{{set macro | yourmacro | {{macro1|$1|$2|$4|$3...}} {{macro2|$5|$6}} {{..}}....}}
call as a normal macro {{yourmacro}} and by {{yourmacro|parameters}} there is no confusion, IT IS A MACRO
The substitute macro 'yourmacro' is in an array of 'section', every 'item-string' contains the text to be substituted ( as a DIFF Template) when the macro {{yourmacro|parameters}} is found then we substitute it in the template by the 'item-string' and replacing every $x by the correct parameter of 'yourmacro'
one example with no parameters as section [file] in your template
{{set macro|item-file|<tr><td>%new% %protected% <a href="%item-url%"><img src="/~img_file" /> %item-name%</a>%comment%<td align=right>%item-size%<td align=right>%item-modified%<td align=right>%item-dl-count%}}
and use
[file]
{{item-file}} no parameters here but it is an 'alias'
[folder]
{{item-folder}}
{{$file}} is converted to {{item-file}} Which is converted in his turn there 'alias'
See you the difference now?
-
'set' is good instead 'alias' but 'set later' can make confuse, you must choice another word like 'set macro' because the syntax are differents
names are not the main problem and can even be chosen later
{{set macro | yourmacro | {{onemacro|$1|$2|$4|$3...}} /macro}} is more representative than
{{set later| yourmacro | {{macro1|$1|$2|$4|$3...}} {{macro2| $5|$6}} {{..}}..../set}}
i don't understand why you are making different examples for set macro and set later.
and call as a normal macro not with {{!mymacro}} but by {{$yourmacro|parameters}} there is no confusion
using $ both for sections and things defined by "set" may lead to colliding names.
you reading a new template see $xx, and may search for section [xx] in the template, but you don't find because it's a variable. I don't like this scenario.
The substitute macro 'yourmacro' is in an array of section,
it's just a string (the name) paired with a content (the body). why you call it array.
See you the difference now?
between set and set macro/later? yes
between set macro and set later? no
-
using $ both for sections and things defined by "set" may lead to colliding names.
j'ai modifié mon post précédent pendant que tu écrivais
between set macro and set later? no
We see at first glance that the functioning is the one of a macro. It seems to me more significant, with ' later ', one do not know when it will take place.
-
yes, i see it's like a macro. and that's exactly what i thought "set later" would be.
i told you i don't understand the difference of behaviour, not the difference in the name. later/macro.
-
The requested URL {{header | GET}} was not found on this server.
the command line (the first line) of the header is not handled.
what you need it for?
I was trying to display what was requested on a 404 error page.
-
you can use %url% since next build
-
Thanks :D
-
till now i proposed and made examples by {{!name}} but ! is already used for localization.
so, i propose {{^name}} instead.
-
Thanks for your work, rejetto and mars !
before entering to concrete macros, some general points to think about:
1. Security of execution: As the number of macros grow and their use will be growing, the possibility of hard to find errors increases. This means that the implementation in the delphi source should do some error checking, allowing a message where or what kind of error ocurred. For this, y suggest to include in the generated page some <p style="display:none" >{{ macro error and/or expanded macro }}</p> This could probably be switched on or off with a pseudomacro: {{debug | 1 }} . Not present: Search error by beating your head against the monitor. debug 1: see errormessage or offending expression. debug 2: see full expanded macro
2. Probably it would make reading more clear if macro names would not contain spaces:
: if not --> ifnot
: is substring -> issubstring
: file size --> filesize,
this makes reading of foreign template more simple, nobody would look for macrodefinitions like is,if,file,size,substring(this one already has confusion implementated, as macro substring exists!)
Macro 'define':
This macro is a real macro for the macro-'language', it must never be evaluated!
but i think it should not be overloaded and its definition should contain the exact number of parameters, that could be instead $n any meaningfull combination of caracteres to make it more understandable. This would also allow to check for errors if the numbers of parameters is not correct, when the definition should be applied.
{{ define | {{left | string | count } | {{ cut {{ 0 | count |string }}}}}}
then when parsing the tpl '{{ left ' is found it should be substituted by the second expression of define, applying by the way the substitution of the named parameters. When this is done, evaluation can begin.
by the way: it would be nice (because simpler to understand) to use in the wiki instead of A B C ... meaningful things:
issubstring | sample | string
cut | start | count | string .....
Namespace to use by macros:
I think there is no need to use another special caracter. But the namespace could hold an atribute-flag: 1-intrinsic macro definition 2-user definition of macro (define) 3-user set-alias macro.
If we establish some rules (all intrinsic functions are lowercase) the templatewriter can use a naming-scheme or use uppercase to distinguish intrinsic an userdefinded functions/macros.
I would propose set(preferable) or alias for inmediate execution
an define as definition, with no execution, only used to be substituted with executable macros.
-
{{ define | {{left | string | count } | {{ cut {{ 0 | count |string }}}}}} is to long, you duplicate the expressions and this code is not good
by using 'define' or 'set macro'
{{set macro| left | {{ cut| 0|$2|$1}} }}
it is more simple to rejetto to evaluate the expression
{{left|mystring|count}}
if you look at code delphi
left is the variable(delphi) 'name'
mystring is pars[0] alias $1
count is pars[1] alias $2
....
and in template you see that $1 is the first param of {{left|($1)|($2)}}
This macro is a real macro for the macro-'language', it must never be evaluated!
when you use %user% in template he is replaced by the login
when you use {{left|string|count}} , he is replaced in the template by {{ cut| 0|$2|$1}}
and all expressions as $1 $2 are replaced by the value string , count
and the template take the following aspect {{ cut| 0|count|string}}
simple mais efficace et c'est pareil pour les 'alias', chaque macro est remplacée par son équivalent
tout comme quand on utilise {{load|file}}, hfs remplace la macro par le texte qui lui correspond; rien de plus.
-
Hold on guys.
(1)
At the moment the macros engine doesn't allow to macros to decide to execute the code LATER.
All macros are executed from inner to outer, and from left to right.
This is not good, but it's easier. I will work to see if i can get something better, but that's not trivial.
In the while the only method to get a text not executed is to quote it.
Till #161 quoting is done by {{quote yo! /quote}} and it was meant to be used rarely.
From next build i will change this into {{\ yo! /}}.
So, i'm the only way to get {{set}} to execute the body later is to do something like
{{set| shout at | {{\ HEY YOU, {{upper|$1}}! /}} }}
then use it via {{^shout at|rejetto}}
this would expand to HEY YOU, REJETTO!
this for sure delays the suffered decision about the name of 'set later'. ;)
we'll have just {{set}} and you'll decide execution by using the quoting markers.
(2)
Let me specify that you won't always need the quoting markers.
{{set| salute | Hi $1!}}
Since we don't use macros inside, we don't need extra markers.
And we'll call it as usual by {{^salute|rejetto}}
(3)
I want to keep it simple.
Not simple for the user, simple for me!
To create a FULL programming language is pointless. I could just invoke an external php, and at least php programmers wouldn't need to learn a new syntax.
This thing makes sense while we keep it low. That's one of the reason i'm not sure about point (1).
-
Since we don't use macros inside, we don't need extra markers.
when you use {{left|string|count}} , he is replaced in the template by {{ cut| 0|$2|$1}}
and all expressions as $1 $2 are replaced by the value string , count
and the template take the following aspect {{ cut| 0|count|string}}
we don't need extra markers to do this, simplement une zone de stockage pour l'échange des parametres
{{set macro|left| {{ cut| 0|$2|$1}} {{length|$1} {{load|taratata.txt}} }}
name='set macro'
pars[0]='left'
pars[1]='{{cut| 0|$2|$1}} {{length|$1} {{load|taratata.txt}}'
stockage de 'left' et '{{cut| 0|$2|$1}} {{length|$1} {{load|taratata.txt}}'
quand on trouve {{left| ....}} on remplace les $x par les paramètres de {{left}} et on transfère dans le template , c'est ca que j'appellerai le 'set later'
{{set| shout at | {{\ HEY YOU, {{upper|$1}}! /}} }}
why not we can use
]{{set| shout at | {{quote| HEY YOU, {{upper|$1}} !}} }}
{{command| parameters}} au moins ça se retient facillement, sinon on n'arrive plus à se souvenir quel caractère il faut mettre et quand ?, entre {{$name}} pour les sections, {{!name}} pour les {{set var|..}} se souvenir de {{\ en lieu et place de {{" ou de {{'
et que sais je encore ??? ??? ???
multiplier les noms de macros OUI , mais utiliser des symboles praticuliers, là on va flirter avec le linux
-
we don't need extra markers to do this, simplement une zone de stockage pour l'échange des parametres
you are not understanding the problem mars.
the current parser is not able to do what you are asking.
you have to use the extra markers.
is it clearer now?
-
Rejetto
I understand you want the macro thing be something simple, you are right.
So perhaps it would be a good idea to take some rest before implementing more and more things that will be difficult to use, as most 'set' 'alias' or 'define' have workarounds with sections. When the ideas are are more matured and depending on the needs of the users, perhaps the macromachine could be made more powerfull finding a better way to satisfy programmers and users need. Creating with to much hurry perhaps leads to macros and sintax that later must be changed to be usefull.
-
where is the real problem? I see how you make the code. problem is it to detect all $x and the last }}, je ne pense pas que la substitution de chaines soit un probleme.
le principe s'appuie sur
procedure applyMacro(macroname :string;len:integer);
const
var
PATTERN:STRING;
p: integer;
begin
idx:=0;
PATTERN:= '{{'+macroname;
repeat
p:=pos(PATTERN, result);
if p = 0 then exit;
delete(result, p, len));
move(macroname.tpl[1], result[p], length(macroname.tpl));
until false;
end; // applyMacro
si on respecte la notation
{{command | parametre1 | parametre2 | parametre3 | ...}}
il n'y a aucun probleme lors de l'utilisation de
{{substring|rejetto|mars|{{$comprehension}} }}
[comprehension]
{{quote rejetto n'est pas pret de convaincre mars sur ce sujet /quote}}
result is n'est pas pret de convaincre
-
where is the real problem? I see how you make the code. problem is it to detect all $x and the last }}
No, of course.
The problem is described the execution order.
http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros#Execution_order
-
from #162 this already works
{{set|x|5}}
{{^x}}
{{inc|x|-3}}
{{^x}}
it will print
5
2
-
filesize | A
tells you the size in bytes of the file A. At the moment URL are not supported, only local filenames.
this would be much handier we had %item-resource% that told the local file path, cause then all i have to do is add the sub folder previews_and_thumbnails/thumb-%item-name%.jpg and it will work perfectly :) i can probably be more specific and target the preview image with this feature previews_and_thumbnails/preview-%item-name%.jpg
-
ok TSG but if you want to see size of a file myfavico.ico to make an include you can't detect him with %item-...%
sample
{{if| {{filesize|myfav.ico}} | <link rel="shortcut icon" href="template/myfavico.ico" /> |<link rel="shortcut icon" href="favicon.ico" />}}
all %item-...% works only in section %list% that is a problem
but you can use {{filezise|%item-url%}} for your ask
-
I have spoken to rejetto about this, %item-resource% is the best method we have come up with, the filesize macro does not work with URL's atm, just local directory like C:\something\something\ which is why it is not working currently, %item-resource% will give more power to this macro. Until it can use URL
On another note, shouldn't {{if|{{get|can archive}}| work in place of %item-archive% ? atm i can only make a check using {{if|%item-archive%| with [item-archive] containing some text. I think that can archive should work in place of %item-archive% when it comes to the macro.
And maybe another macro {{if|{{get|can access}}| in place of %protected%?
-
i guess "can archive" at the moment works only on the folder itself, not on items of the folder.
-
Yes that is the case.
Is it possible to stop the line break after a {{$}} its very annoying and causes many bugs with js and some html related tasks...
-
I was testing out the set macro and couldn't figure out why it wasn't working for me and then realized set and call have to be in the same template section, shouldn't you be able to call a user macro from anywhere in the template otherwise it defeats the purpose because you have to place the code for the macro in each section anyway.
-
Is it possible to stop the line break after a {{$}} its very annoying and causes many bugs with js and some html related tasks...
i will remove the last line break from sections
I was testing out the set macro and couldn't figure out why it wasn't working for me and then realized set and call have to be in the same template section, shouldn't you be able to call a user macro from anywhere in the template otherwise it defeats the purpose because you have to place the code for the macro in each section anyway.
it's not a matter of sections.
SET must be before CALL in the way the final html is built.
if you place SET in [file], then it will be issued several times, not just one.
i guess that if you replace your SET and CALL with A and B you will see the B before the A.
-
a request
{{?urlvar}} return the last url value from ?urlvar=x
when we want test the value we use {{ {{?urlvar}} = x }} true(1) or false(0)
i know it will be easy to concatenate it to obtain {{?urlvar=x}} will return 0 if urlvar<>x, and '1' if true
{{?urlvar=}} can give same result as {{not|{{!urlvar}}}}
then by example
{{!sort=}} return true(1) if sort is not in url else we must use {{not|{{!sort}}}}
{{!sort=n}} return true(1) if sort is defined in url as ?sort=n , else false(0)
-
it's not a matter of sections.
SET must be before CALL in the way the final html is built.
Thats what I thought to start with, but I'm not getting anything returned when SET is in the main section or in [files] and CALL is in [folder] and [file].
-
It is always necessary to present a part of your template to obtain a maximum of help(assistant),otherwise our understanding of your problem remains too vague
-
Thats what I thought to start with, but I'm not getting anything returned when SET is in the main section or in [files] and CALL is in [folder] and [file].
ah, that's because the main section is parsed after the file list is built.
from next beta you can move your macros to the [special:begin] section.
this should solve your problem.
-
i know it will be easy to concatenate it to obtain {{?urlvar=x}} will return 0 if urlvar<>x, and '1' if true
it will work from next beta
-
ah, that's because the main section is parsed after the file list is built.
from next beta you can move your macros to the [special:begin] section.
this should solve your problem.
Thanks rejetto. Always presumed the main section was parsed first.
When CALL and SET are documented in the wiki, it would probably be a good idea to mention that SET should be placed in [special:begin].
-
??? or ;D on behalf of rejetto
is it POSSIBLE two create four macro
{{begin | {{onemacro}} }} before main
{{before | {{onemacro}} }} before %list%
{{after | {{onemacro}} }} after %list%
{{end | {{onemacro}} }} after main
BEGIN work as section [special:begin] : before main
BEFORE is evaluated at the begining of %list%
AFTER is evaluated at the end of %list%
END is evaluated when all macro and symbol above are evaluated
Application:
somewhere in template we want to set a variable
{{begin | {{set| items | 0 }} }}
we have section folder like
[folder]
{{inc|items|1}} ......
then to reproduce the last value at begining of main page, we must use some javascript
else we can use
{{after| {{^items}} }} and no more %list% {{^items}} in this order to have the correct result
-
you can do such job with just by using [special:begin]
try the attachment and you'll see it working
-
Already some hours ago that works
look at the attachment
-
Can we get a macro for %new% {{if| {{is new|NEW!}} }} or something, if anyone has a better idea... Cause other than [item-archive] and [protected], [newfile] is the only other section which only contains text for no real purpose. And also, the section name is incorrect cause %new% - [newfile] works on folders and links also...
-
To try and stay the same as the other macros, I suggest {{get|is new}}
Edit, also an option to highlight "|" in the template editor would help readability and split the macro's up into smaller segments.
Another thought, The macro engine performs the macro's from the inside outwards, so at some point it would have to pair the braces"{{}}", would it be possible to have the braces paired in the template editor, where as if you clicked on a brace it would highlight all of its contents. That would help debugging your macro's greatly.
-
A couple more macro suggestions :P
{{encodeURI}}
{{decodeURI}}
{{escape}}
{{unescape}}
These four would be useful to encode special characters and may help in language support.
and
{{round}}
Why have all the other math operators if you cant round your result's to X decimal places.
-
Pretty print is something i've wanted for a long time, but it is too hard apparently.
-
every decent text editor has customizable highlighting.
i know you use notepad++ (i use pspad).
start building your syntax definition for template macros, cause it won't take long till we have support for the external editor. ;)
-
Oh u mean the template will be read from the external file finally? If that is the case, I might make a user defined one for notepad++ and post it on the forum... one that shows sections, symbols, and macro's.
-
Oh u mean the template will be read from the external file finally?
something like that
If that is the case, I might make a user defined one for notepad++ and post it on the forum... one that shows sections, symbols, and macro's.
it would be great
-
Once we solidify the syntax i may make one for Edit++ too.
But, i'm gonna need the full syntax reference in a list.
-
Just look in the wiki, they should all be there.
-
Oh u mean the template will be read from the external file finally? If that is the case, I might make a user defined one for notepad++ and post it on the forum... one that shows sections, symbols, and macro's.
I would really enjoy this, Notepad++ is my editor of choice :)
-
The syntax is easy
macros: {{macroname|parameter|parameter}}
macro quoting: {{\ any macro /}}
and %symbols%
nothing else
-
The syntax is easy
macros: {{macroname|parameter|parameter}}
macro quoting: {{\ any macro /}}
and %symbols%
nothing else
and [section]
-
right! but only if [section] is at the very beginning of the line
-
I noticed that a FOR macro has been documented in the wiki, is this coming the the next build? And could an example for it please be posted because I don't understand how we include the condition for it to keep looping.
I think I figured the syntax out but it isnt working correctly, The variable defined in parameter A only returns the number of loops that are going to be executed.
eg, the following loop created the output in the screenshot.
{{for|A|1|8|<input name="poll" type="radio" value="{{^A}}" /><label>{{!Option {{^A}}}}</label><br />}}
I had a look in the whats new list for the beta's and didnt see the FOR macro mentioned, is it still being coded/bugs being fixed before announcing it?
-
it's in the what's new of #164.
it doesn't work because you are not using the macro quoting.
I put a reminder in the wiki.
-
oh ok, I'll try it with the quoting. I went and had another look and didn't see it mentioned in the whats new for build 164. ???
-
+ new template macro: <> != for time filename
-
lol, I misread it ;D
-
When you use append where does the file get saved when you only specify a name? eg {{append|file.txt|text}}
can you use server relative paths? eg {{append|/folder/file.txt|text}}
etc
-
the hfs.exe folder is used as default.
/folder is not very relative.... it's absolute in the same drive unit.
folder/ is relative, or ../folder/
-
the hfs.exe folder is used as default.
/folder is not very relative.... it's absolute in the same drive unit.
folder/ is relative, or ../folder/
Thankyou, it might be a good idea to add that the hfs.exe directory is used as default.
-
The new template by default is arrived,
Mode page by page is effective
Sorting by name and extension: novelties
-
Merci mars ! je vais essayer de transposer ton code dans une autre template, mais le process est bon : faire une recherche initiale puis un affichage du résultat en mode page/page ... excellent ! Million Thanks Mars !
TCube
-
The new template by default arrived,
Mode page by page is effective
Sorting by name and extension: novelties
Ajout à l'instant de ce "Marsellous" template (qui marche aussi bien sous FF qu' IE6) à une VF.
Mille bravos
SilentPliz
-
mars
You might want to make the following change to keep the text file out of the viewable file listing...
{{if| %user |{{\ {{append| %folder-resource%\hfs.comments.txt |{{filename|%item-resource%}}=uploaded by %user%
-
After correction of some bugs, here is a not definitive but functional version
Merci mars ! je vais essayer de transposer ton code dans une autre template, mais le process est bon : faire une recherche initiale puis un affichage du résultat en mode page/page ... excellent ! Million Thanks Mars !
la transcription risque d'etre ardue , mais je m'efforce de simplifier au max sans utiliser de java
dans cette nouvelle mouture j'utilise un max de {{set...}} dans la section [special:begin]
j'ai introduit des regroupements par extension et aussi par nom mais en mode page/page j'ai encore un petit travail à terminer, mais la présentation actuelle devrait plaire à quelques un . ;D
Note to rejetto:
You might want to make the following change to keep the text file out of the viewable file listing...
Corrected, but error is in default template build 165
-
1)
[special:begin] existe déjà
[special:end] en cours de fabrication
2) une nécessité pour moi
deux macros dans le même ordre d'idée
{{special begin| ........}} évaluée immediatement après la section [special:begin]
{{special end|.........}} évaluée juste avant ou après l'appel à la section [special:end] (de préférence juste avant)
3)
une macro qui retourne certaines valeurs d'options en "true or false" ou une valeur correspondante
{{get option| A}} retourne la valeur correspondante à A dans HFS.INI
et plus précisément
{{get | folders-before}} 1|0
{{get | links-before}} 1|0
{{get | default-sorting}} n|e|t|d|h
{{get | recursive-listing}} = {{get |can recur}}
c'est plus simple que de charger hfs.ini dans le template et de recupérer la valeur que l'on souhaite tester
Un petit bug : defaults-sorting =ext n'est pas correctement affiché dans le menu au redémarrage de hfs (name par défaut) déjà signalé dans un autre post si ma mémoire est bonne.
Manque une ligne dans main.pas
name1.Checked:= TRUE;
time1.Checked:= defSorting='time';
size1.checked:= defSorting='size';
hits1.Checked:= defSorting='hits';
Extension1.Checked:= defSorting='ext';
-
1)
[special:begin] existe déjà
[special:end] en cours de fabrication
i changed my mind, and decided to make no [special:end].
i found it's easy to make the nbcount you need.
see this example:
after [file] put {{comment| {{count|ext.%item-ext%}} }}
Then, after the list you can put something like I saw {{count|ext.mp3}} mp3 files
Or you can store the value using {{set}}, as you wish.
2) une nécessité pour moi
deux macros dans le même ordre d'idée
{{special begin| ........}} évaluée immediatement après la section [special:begin]
{{special end|.........}} évaluée juste avant ou après l'appel à la section [special:end] (de préférence juste avant)
no, it's not possible to make it.
3)
une macro qui retourne certaines valeurs d'options en "true or false" ou une valeur correspondante
{{get option| A}} retourne la valeur correspondante à A dans HFS.INI
ok
Manque une ligne dans main.pas
fixed thanks
-
Okay, I made some small correction. :) ;)
-
see this example:
after [file] put {{comment| {{count|ext.%item-ext%}} }}
Then, after the list you can put something like I saw {{count|ext.mp3}} mp3 files
Or you can store the value using {{set}}, as you wish.
after the list mon problème est ici, je dois pouvoir utiliser la valeur finale de chaque {{count|ext.%item-ext%}} n'importe où dans le template, et spécialement dans la liste à un endroit quelconque
-
I'm trying to append a SET macro to a file which will be called and executed later but it isn't working, I am using quote macros and it is being saved to the file but the quotes are being added too, so I can't then load the file into the template and execute the macro's in it.
eg
{{append|test.txt|{{\{{set|Title|Test Title}}/}}}}
{{\{{set|Title|Test Title}}/}}
I thought hfs stripped the quoting brace's and just left the text inside.
-
ok mars, now it is clear what you want to do.
I see no way to create the macro you want, but you can just change algorithm.
For every file
if lastFile has different first letter
^endsection
inc counter
add html to buffer
at the end of the list
^endsection
function endsection
output buffer
clear buffer
reset counter
you can do all these things with existing macros.
For now "add html to buffer" can be done this way {{set|buffer|{{^buffer}}your html here}}
But in next build i will add a new macro to speed up, and it will be {{set append|buffer|your html here}}
-
I thought hfs stripped the quoting brace's and just left the text inside.
there's no reason for HFS to strip such braces.
if it would be done everytime, it be like quoting never exists.
It is done in special cases.
Now, i could add {{append}} to such special cases, but maybe we can do in another way.
I will add a {{dequote}} macro, so when you want to execute your file, you can just
{{dequote|{{load|myfile.txt}} }}
Ok?
-
{{dequote|{{load|myfile.txt}} }}
Ok?
That would work great, ;)
-
I see no way to create the macro you want, but you can just change algorithm.
my solution: attached file
Il ne reste plus qu'à tester...
-
ok mars, your solution is good. i created a macro "after the list". you are supposed to quote the body, to avoid its premature execution.
i'm not sure this macro will solve your problem. try and see. if it doesn't, there's my other solution.
In the while i wrote this little macro to create the header for every letter.
it is supposed to be placed after [item start]
{{set|first|{{upper|{{cut||1|%item-name%}}/upper}}/set}}
{{if| {{ {{^first}} != {{^last}} }} |
{{\ {{set|last|{{^first}}}} <tr><td>{{^first}} /}}
/if}}
-
une autre idée me trotte dans la tête
can you update function inc() as this:
procedure inc(v:integer=+1);
begin
if not satisfied(md.cd) then exit;
try
if not(md.cd.params.indexOf(p) >= 0) then md.cd.vars.values[p]:='0';
result:='';
with md.cd.vars do values[p]:=intToStr(strToInt(values[p])+v*parI(1,1))
except end;
end; // inc
Ainsi on pourra définir une variable à 0 par défaut (sans connaitre son nom à l'avance) simplement par un appel à INC ou DEC comme par exemple {{inc|file.%item-ext%}}, car je ne peux prédire à l'avance quelles EXT seront utilisées dans %files%
et éviter d'utiliser la combinaison {{set|count|{{count|file.%item-ext%}} /set}} {{^count}}
mais plutôt {{inc|file.%item-ext%}} et {{^file.%item-ext%}}
tout comme avec %sequential% il n'y a pas %number-sequential%
ainsi avec {{count|....}} il manque l'équivalent de {{special end|{{^count|....}}}}
donc au lieu d'avoir
{{set |myvar|0}} ..... {{inc/dec|myvar|n}} ... {{^myvar}} = n
alors
{{inc|myvar|n}} ... {{^myvar}} = n
serait équivalent et suffisant.
-
DIV only works when dividing a number that has 9 or less digit's.
eg
{{div|999999999|1024}} returns 976562
but
{{div|9999999999|1024}} returns 0
-
limit is {{div|2147483647|1024}}
Min longint value = -2147483648
Max longint value = 2147483647
rejetto must change storage to
Min int64 value = -9223372036854775808
Max int64 value = 9223372036854775807
function parI(idx:int64; def:int64=0):int64;
begin result:=strToIntDef(par(idx), def) end;
and more if necessary
-
64bit integers supported
inc now works with non-numeric vars. they will be considered zero.
-
All macros, except quoted ones, are expanded. Even if you use the macro if|A|B|C, independently by the value of A, both B and C are expanded. If A is true, C is discarded, and vice versa. This is an important point, because if you was using append inside C, the file will be written anyway.
After reading this I thought, why not have the if macro automatically apply quotes and then unquote the correct parameter.
-
Because execution of macros is done when the parser already finished its work.
The parser have no knowledge of the macros, just handles parenthesis.
Another point is: you do {{append|file|{{another macro}} }}
How can HFS know that you want to execute another macro now or later ?
Think it works with url parameters. You may want to work with current parameters, or the parameters of the time you will load the file. Only you know.
And you will choose between behaviour 1 or 2 by quoting or not.
-
It is the same difference when you define
{{set|myvar|{{cut|1|8|It is the same difference}} /set}}
and
{{set|mymacro| {{\ {{cut|1|$1|$2}} /}} /set}}
if you use
{{append|file|{{another macro}} }}
{{another macro}} is immediatly evaluated and result is stored in file
but with
{{append|file| {{\ {{another macro}} /}} }}
it is {{another macro}} who is stored in file
and when you include this file in your template {{load|file}}, it is here that the macro {{another macro}} is evaluated.
-
{{append|file| {{\ {{another macro}} /}} }}
it is {{another macro}} who is stored in file
and when you include this file in your template {{load|file}}, it is here that the macro {{another macro}} is evaluated.
When I tested this the quotes were added to the file as well, so in this case it would be {{\{{another macro}}/}}.
-
foggy i make test with
{{set|myvar|{{\{{\{{another macro}}/}}/}}}}
{{append| c:\file.txt|{{^myvar}}}}
see result on your template ;D ;D ;D
-
Im about to goto bed so I'll test in the morning, but that looks like it will work :P
I'll use that in the mean time but I think It would be more simpler in the long run to just use dequote as rejetto suggested.
-
It works, but the problem is I'm trying to include a urlvar in the macro that is being written to file, so to create some dynamic content.
This is what I get in the file
{{set|Title|{{?title}}}}
I need to be able to evaluate the urlvar before it is written to file.
-
missing more code to evaluate where is your pb
by sample
{{set|myvar|{{\{{\{{another macro}}/}}/}}}}
{{append| c:\file.txt|{{^myvar}}}}
is full to work
-
where is your pb
pb ???
this is the code I tried, it works but the urlvar isn't evaluated before being written to file but I don't think there is a way around that.
{{set|data|{{\{{\{{set|Title|{{?title}}}}/}}/}}}}
{{append|{{?name}}.txt|{{^data}}}}
I think I'll have to go back to my first idea of creating a strings table and loading that instead.
-
does this work?
{{set|data|{{replace|$1|{{?title}}|{{\{{\{{set|Title|$1}}/}}/}}/replace}}}}
{{append|{{?name}}.txt|{{^data}}}}
-
note pour rejetto
{{\ ..... /}} ok
{{\{{\ ..... /}}/}} can be replaced by an alias as {{\\..... //}}
{{\{{\{{\ ..... /}}/}}/}} can be replaced by an alias as {{\\\..... ///}}
update to do this
function dequote(s:string):string;
begin
if ansiStartsStr(MARKER_QUOTE+'\', s) and ansiEndsStr('/'+MARKER_UNQUOTE, s) then
begin
delete(s,length(s)-length(MARKER_UNQUOTE),1);
delete(s,length(MARKER_QUOTE)+1,1);
result:=s;
end
else if ansiStartsStr(MARKER_QUOTE, s) and ansiEndsStr(MARKER_UNQUOTE, s) then
result:=copy(s, length(MARKER_QUOTE)+1, length(s)-length(MARKER_QUOTE)-length(MARKER_UNQUOTE) )
else
result:=s
end; // dequote
chaque {{\\\ ..... ///}} est remplacé par {{\\..... //}} qui est de nouveau remplacé par {{\ ..... /}} à chaque appel de dequote()
-
I think this won't happen often, and it will be max 2 nested quotings.
We'll see...
-
serious problem with macro order
un bien singulier template:
<head>
</head>
<body>
{{set |counter|hello}}
<p>
First: {{^counter}}
{{set |counter|Youpi}}
<p>
{{set|itemmax| -25}}
Macro After the list: {{^itemmax}} ** {{after the list| {{^counter}} ** {{^itemmax}} }}
%list%
<p>
End of list: {{^counter}} ** {{^itemmax}}
</body>
</html>
[file=folder=link]
{{set|counter| {{count}} }}
{{set|itemmax| {{^counter}} }}
<p>item {{^counter}}
Html result
<head>
</head>
<body>
<p>
First: hello
<p>
Macro After the list: -25 ** Youpi ** -25
<p>item 0
<p>item 1
<p>item 2
<p>item 3
<p>item 4
<p>item 5
<p>item 6
<p>item 7
<p>item 8
<p>
End of list: Youpi ** -25
</body>
</html>
quelque part, l'ordre d'évaluation n'est pas respecté
-
does this work?
{{set|data|{{replace|$1|{{?title}}|{{\{{\{{set|Title|$1}}/}}/}}/replace}}}}
{{append|{{?name}}.txt|{{^data}}}}
no :(
It was a good idea but the text file was empty, is it possible that the replace macro is dropping the quoted text?
edit:The way you suggested rejetto gave me an idea to try using set with parameters instead of replace, and it worked even better then I was hoping by outputing the macro with any quotes at all.
{{set|data|{{\{{\{{set|Title|$1}}/}}/}}}}
{{append|{{?name}}.txt|{{^data|{{?title}}}}}}
returned
{{set|Title|food}}
-
we have the append macro but to accompany it, is it possible to have a macro that could remove text from a file?
or have a macro to delete a file?
or one to overwrite the file, and then you could use replace to replace what you don't want with nothing.
-
serious problem with macro order
{{after the list}} needs macro quoting.
or one to overwrite the file, and then you could use replace to replace what you don't want with nothing.
ok, {{save}}
-
It was a good idea but the text file was empty, is it possible that the replace macro is dropping the quoted text?
to solve dramas such this, i created a log for the macros, so we'll be able to see how they are executed.
This option won't be saved. It is meant that you use it rarely and for a short time.
-
It was a good idea but the text file was empty, is it possible that the replace macro is dropping the quoted text?
to solve dramas such this, i created a log for the macros, so we'll be able to see how they are executed.
This option won't be saved. It is meant that you use it rarely and for a short time.
ok, that could be quite useful. The error message we get down the bottom of the main hfs window has also been very useful.
-
i don't know if it is possible to rejetto to create a lot of macros
{{length line|#line|source}} return the number of caracters (exept #10#13) of the line #line from source
{{count lines|source}} return number of begining of lines in source (NOT number of #10#13) if source is empty this macro return 0, if the last line is 'abcde' then it is a valid line.
{{trim lines|source}} works as {{trim|source}} but it remove empty lines at END and BEGIN of source
usage by example {{trim lines| {{section|mysection}} }}
sometime I use empty line to separate sections in my template.
{{cut lines|begin_line|end_line|source}}
begin_line and end_line can be negativ values
usage by example {{cut line|1|{{sub|{{length line|source.txt}}|x}}|source.txt}}
missing to macro {{for|}} a macro named {{exit for}}
usage by example
{{for|x|1|{{count lines|source}}|{{if|{{length line|{{^x}}|source}}>63|{{exit for}}|Line {{^x}} is <64 /if}} /for}}
modification to accept {{?urlvar|defaultvalue}}
application {{get|url|sort={{?sort|n}}|rev={{?rev|1}} }}
ceci n'est qu'un exemple non restrictif
<form name=frm>
Name <input id=login name=name value="{{?name|%user%}}">
<p>Text <input id=text name=text>
<p><input type=submit>
</form>
<script>document.frm.text.focus();</script>
<a href="{{get|url|text=}}">REFRESH</a>
-
{{append | path+file | texte }}
{{save | path+file | text }}
{{delete | path+file }}
{{rename | path+file | newname }}
can you create the two last macros, rejetto?
-
Ok for delete and rename.
i don't know if it is possible to rejetto to create a lot of macros
don't ask if it is possible.
ask if it is convenient/suitable.
{{length line|#line|source}} return the number of caracters (exept #10#13) of the line #line from source
what you will use it for?
{{count lines|source}} return number of begining of lines in source (NOT number of #10#13) if source is empty this macro return 0, if the last line is 'abcde' then it is a valid line.
in standard text files the number of lines IS the number of #13#10. I remember having read it on wikipedia (http://en.wikipedia.org/wiki/Newline).
indeed my Pspad editor does this way.
Microsoft Notepad does not ::)
Consider we shouldn't make macros for EVERY need. For some specific purposes you can use javascript. It works. Macros are meant for making common things with no javascript.
{{trim lines|source}} works as {{trim|source}} but it remove empty lines at END and BEGIN of source
trim already do remove empty lines. try before asking ;)
missing to macro {{for|}} a macro named {{exit for}}
at the moment it can't be done, because {{for}} was implemented as a sort of {{repeat}}.
modification to accept {{?urlvar|defaultvalue}}
application {{get|url|sort={{?sort|n}}|rev={{?rev|1}} }}
ceci n'est qu'un exemple non restrictif
use {{or|{{?sort}}|n}}
-
If we want to make a thing in the style
{{for|A|2|10|2|{{for|B|1|5|2|{{^A}}+{{^B}}={{ADD|{{^A}}|{{^B}} }}<p> /for}} /for}}<p>{{^A}}+{{^B}}
The result is not the one that we can hope
0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
+=0
10+5
You must correct it by insert some {{\ and /}} as
{{for|A|2|10|2|{{\ {{for|B|1|5|2|{{\{{^A}}+{{^B}}={{ADD|{{^A}}|{{^B}} }}<p>/}} /for}} /}} /for}}<p>{{^A}}+{{^B}}
and all will be correct after
2+1=3
2+3=5
2+5=7
4+1=5
4+3=7
4+5=9
6+1=7
6+3=9
6+5=11
8+1=9
8+3=11
8+5=13
10+1=11
10+3=13
10+5=15
10+5
-
{{length line|#line|source}}
{{count lines|source}}
{{cut lines|begin_line|end_line|source}}
Do not forget that source can be the contents of an external file
Consider we shouldn't make macros for EVERY need. For some specific purposes you can use javascript. It works. Macros are meant for making common things with no javascript.
I am not completely the same opinion, the macro are there to be executed at the level of the server, and so that certain actions which are possible with javascript, they are not seen by the user.
We can mask certain items in mode page as I made it, but by showing the code all the information is present.
With javascript I can simulate restrict account on directories but it is simpler when HFS makes it, and in more the quantity of information transfer is lesser.
-
{{length line|#line|source}}
{{count lines|source}}
{{cut lines|begin_line|end_line|source}}
Do not forget that source can be the contents of an external file
yes, i guessed so. Can you tell me what's your purpose with such macros?
I am not completely the same opinion,
i'm sorry, but i won't spend years building a complete language. It makes NO sense. I already said it before. When HFS will support CGI, people interested in a full language will install PHP, Perl, anything.
-
When HFS will support CGI, people interested in a full language will install PHP, Perl, anything.
;D I know, but it is not before 2010, and by waiting , what can we do?? To colour in our templates.... ;D ;D ;D
-
Hi
What about a macro that makes hfs execute an executable/bat?
I'm thinking of:
1. Upload ok => call external program generating and save MD5/SHA256 to file => get the MD5 from there and add it to file-comment to verify
2. Upload ok => call AntiVius and check file => if AV return = 0 => Add file to UL-folder if not inform User it's infected
Cheers,
ebola
-
they are some good ideas, I especially like the anti virus example. md5 I think can already be automatically generated, have a look inside the fingerprints menu.
-
to go with append, a macro to write at the beginning of a file could be quite useful. I know I would use such a macro so that I can load the file and execute and/or list the data in a certain order. I think the correct term for it is prepend.
-
instead of writing to file, prepend in a variable. {{set|x|here{{^x}}}}
at the end of it all, you'll save the variable in a file.
-
{{save | file.txt|YOUR MESSAGE <br>{{load | chat.txt}} /save}}
to add at beginning of file
{{if|{{filesize | file.txt}}>lengthmax}}|
{{save | file.txt|{{cut||maxfile|{{load | file.txt}} }} /save}}
to cut file if he is too long
it is what i use in chat.tpl
-
What about a macro that makes hfs execute an executable/bat?
i will think on it
-
This one is probably a big ask, but are arrays possible?
-
talk about your needs. how would you use it?
-
currently I am writing to a file a list, that is then parsed each time the page is loaded to get the most recent 25 entries and then 25 more in for each page.
problem is as you go further into the pages, the load on the server is greater because to find the items for that page I have to start start from the start of the list and loop through X times to eliminate the pages before the current one.
basically it would be eliminating this macro, because with an array I can just use a for loop directly on the values I am after. {{if|{{or|{{{{?p}}=1}}|{{not|{{?p}}}}}}||{{\{{for|B|1|{{sub|{{mul|{{^topic-limit}}|{{?p}}}}|25}}|{{\{{set|topic-order|{{cut|{{add|{{length|{{substring||;|{{^topic-order}}}}}}|2}}||{{^topic-order}}}}}}/}}/for}}/}}/if}}
the list is written like 1;2;3;4;5;... etc
on a side note I first tried that macro using if not but it had trouble with the quoting of the commands to execute.
I hope that made sense :P
-
Next beta will be able to correctly run
{{random{{for|x|1|10|{{\|{{^x}}/}}/for}}/random}}
that is: a nestd macro will be able to expand to multiple parameters for the outer macro.
currently you are limited to just 1.
-
I have 2 bugs.
1. Macro sections are giving me a line break again all of a sudden. Which breaks the code in places. (it happens on a sub page) the root is fine.
2. The load macro doesn't seem to work with a path... I need it to work with a path for my language files :)
-
1. i made a test and it works just as #171. can you provide a way to reproduce it?
2. i made a test and it worked with path\file with ..\path\file and with \path\file
double check
-
1. Yes, it happens on every sub directory for me... i've tested 172 and now 174. I go into sub directory and the macro gives a line break after the text.
2. I have this and it does nothing... {{load|..\template\rawr_default\languages\en_au.txt}}
-
1. i'm asking you to provide an example in form of template code. the smaller is the code, the better.
2. that is a relative path. relative paths are based on the HFS folder. is "template" folder right outside the folder you are running hfs.exe ?
-
The template folder is next to hfs.exe and {{load isnt even appearing in the macro.log.
[special:strings]
{{load|template/rawr_default/languages/en_au.txt}} < the macro doesnt even appear in the log, even when i put the load part into a section.
and for the first thing an example would be.
var theme="{{$theme}}"
In root directory:
var theme="rawr_blue";
In sub directories:
var theme="rawr_blue
";
The sections where working fine everywhere until today... i was using 172 till a few mins ago.
-
1. I just tested with #174
this was the test template
[theme]
hey
[]
"{{$theme}}"
then accessed / and it printed "hey"
then accessed /new%20folder/ and it printed "hey"
2. since load is never executed, it is not a bug in {{load}}
Indeed special:strings is considered simple text and macros are never executed.
I see 2 solutions, to be weighed:
a) to run macros in special:strings
b) to make HFS use variable {{^special:string}} (that you can load with the file), and if it's empty, use [special:strings]
-
I would leave special:strings how it is so you can use a strings table without an external file, but if using an external file I would use 'from table' instead.
-
{{!}} is a special case of {{from table}}
but for localization we need to use ! because it's much shorter.
with fro, table you have to specify the name of the table also. every time.
-
I figured it out! The break is coming from the Diff Template value of [theme], so sections in Diff Template have a break after them!
The {{load}} macro i am still working with... I think we need the ability to fire a macro in [special:strings], cause even if u wanted to import some strings from another section, you need to fire {{$section}}.
-
I figured it out! The break is coming from the Diff Template value of [theme], so sections in Diff Template have a break after them!
this means it is not a bug. Right?
The {{load}} macro i am still working with... I think we need the ability to fire a macro in [special:strings], cause even if u wanted to import some strings from another section, you need to fire {{$section}}.
from next beta, try using {{load|yourfile|special:string}}
this will load the file in {{^special:string}} that is a variable, not the section.
That's because {{!asd}} will search asd in several places, in this order:
in variable special:strings
in section special:strings
in the optional parameter
and if it is not found anyhwere, "asd" itself is returned
-
I figured it out! The break is coming from the Diff Template value of [theme], so sections in Diff Template have a break after them!
this means it is not a bug. Right?
No it means it IS a bug, the main template doesnt have breaks after sections, why should it be different for Diff template?
I will try this method when next build is released.
-
from next beta, try using {{load|yourfile|special:string}}
this will load the file in {{^special:string}} that is a variable, not the section.
one question
when using {{load|yourfirstfile|special:string}} before {{load|yoursecondfile|special:string}}
Is yoursecondfile append to {{!special:string}} or rewrite over {{!special:string}} ?
an option can be added
{{load|yourfile|special:string|sectionname}}
by example in yourfile are some sections
[special:strings]
mytext=english
[special:stings_fr]
mytext=français
[special:stings_it]
mytext=Italiano
using {{load|yourfile|special:strings|special:strings_fr}} load only content of section [special:strings_fr] from yourfile, or [special:strings] if par[3] is not specified
2e question
{{load|yourfile|special:string}} i think that only section [special:strings] into yourfile must be include, not all content of the file
It is to offers more possibility to load with same syntax others sections as [special:begin] included in variable {{!special:begin}}
{{load|yourfile|special:begin}}
That's because {{!asd}} will search asd in several places, in this order:
in section special:begin {{set|myvar|text}}
in variable special:begin {{set|myvar|Overloaded Text }} can replace text defined above for a specific usage
(dans cet ordre pour une possible possible surcharge des définitions de variables ou macros)
{{load|yourfile|special:begin|sectionname}}
it is possible with some restriction
-
{{FROM TABLE|...}
how to use it?? ??
désolé si je suis passé à coté de la réponse dans un autre post
-
{{FROM TABLE|...}
how to use it?? ??
{{from table|table/variable|string id}}
-
{from table|table/variable|string id}}
A concrete example would be welcome
-
{{set|example|
foo=this is an example
foo2=this is another example
/set}}
{{from table|example|foo}} will return "this is an example"
{{from table|example|foo2}} will return "this is another example"
-
when using {{load|yourfirstfile|special:string}} before {{load|yoursecondfile|special:string}}
Is yoursecondfile append to {{!special:string}} or rewrite over {{!special:string}} ?
it's overwritten
an option can be added
{{load|yourfile|special:string|sectionname}}
yes, but you can already do it using {{set|special:string|{{$sectionname|yourfile}}/set}}
We'll do it if we see any need of it.
2e question
{{load|yourfile|special:string}} i think that only section [special:strings] into yourfile must be include, not all content of the file
ditto. you can already do it.
-
No it means it IS a bug, the main template doesnt have breaks after sections, why should it be different for Diff template?
I will try this method when next build is released.
found the bug and fixed :)
the problem were not diff templates, but just "the last section of any template"
-
Quote from: mars on 20 January 2008, 23:14:54
when using {{load|yourfirstfile|special:string}} before {{load|yoursecondfile|special:string}}
Is yoursecondfile append to {{!special:string}} or rewrite over {{!special:string}} ?
it's overwritten
Quote
an option can be added
{{load|yourfile|special:string|sectionname}}
yes, but you can already do it using {{set|special:string|{{$sectionname|yourfile}}/set}}
We'll do it if we see any need of it.
Rejetto ,You forgot to clarify ;)
from next beta, try using {{load|yourfile|special:string}}
this will load the file in {{^special:string}} that is a variable, not the section.
That's because {{!asd}} will search asd in several places, in this order:
in variable special:strings
in section special:strings
in the optional parameter
and if it is not found anyhwere, "asd" itself is returned
{{set|special:string|{{$sectionname|yourfile}}/set}}
{{set append|special:string|{{$sectionname|yoursecondfile}}/set}}
It completes your two answers
-
for each | A | B1 | B2 | B3 | .....| Bn | C
repeats C by replacing variable {{^A}} with every value from B1 to Bn (n>=1)
i have create this macro by example to replace more than one substring in a string
{{for each| A | 5 | 2 | 3 | 8 | 6 | 1 | 0 | {{\ ({{^A}}) / /}} }}
result is (5) / (2) / (3) / (8) / (6) / (1) / (0) /
code source pour HFS
if pars.count < 3 then exit; // from here, only macros with at least 3 parameters
if name ='for each' then
foreach();
.........
procedure foreach();
var
j, n : integer;
theVar, code: string;
begin
try
j:=max(1,pars.count-2);
code:=par(pars.count-1);
if code=''then exit;
code:=dequote(code);
theVar:=format('{{^%s}}',[p]);
with TfastStringAppend.create do
try
for n:= 1 to j do
begin
append(xtpl(code, [theVar, par(n)]));
end;
result:=reset();
finally free end;
if assigned(md.cd) then
md.cd.vars.values[p]:=intToStr(j);
except end;
end; // foreach
-
replace | A1 | B1 | A2 | A2 | B2 | ....... | An | Bn | C
returns C with every Ax replaced with Bx
code source pour HFS
if name = 'replace' then
replace();
.....
procedure replace();
var
i: integer;
begin
p:=par(pars.Count -1);
i:=0;
while (i < pars.count-1) and not (i = pars.count-2) do
begin
p:=xtpl(p, [par(i), par(i+1)]);
inc(i,2);
end;
result:=p;
end; // replace
{{replace| 2|two | 3|three | 4|four | 7|seven | 9|nine | 0 1 2 3 4 5 6 7 8 9}}
{{replace| 2|two | 3|three | 4|four | 7|seven | 9|nine | 0| 0 1 2 3 4 5 6 7 8 9}}
result is 0 1 two three four 5 6 seven 8 nine
-
I'am still having problems with localization.
In the maintemplate i have
[special:begin]
{{load|bts_init.tpl}} {{comment|global vars, origin of request,force browserlang to availablelang(+selectedlang)->userlang}}
{{load|btslang_{{^userlang}}.tpl|special:string}}
[special:strings]
lfile=Languagefile in template
lfmodif=20080128
....
With build #177 this should work, but {{!lfile}} etc. return the values from [special:strings] and not from the vars loaded into 'special:string' from the file. ¿What am I doing wrong to get it working?
-
{{load|btslang_{{^userlang}}.tpl|special:string}}
modify to {{load|btslang_{{^userlang}}.tpl|special:strings}}
-
Might only be a bug in 178beta but i cant get the strings to go to all the other pages in the template. It only works for the main section of it.
This is my macro. The contents of the file works fine if i paste it in the tpl, but the load macro should work for localisation to be complete.
(i think in my version the load macro can use URI's for links so that isn't the bug)
[special:begin]
{{load|/template/rawr_default/languages/en.txt|special:strings}}
-
are the other pages user defined sections? if so, try placing {{$special:begin}} at the top of the section.
-
Thanks that works, but I think assigning the load to special:strings should also make it a global var.
-
ok, added
i hope you truly need these macros, because we must add only the macros we use
-
when I use {{?var}} is it possible that if there isn't a url variable with that name that it then checks for a postvar with that name.
-
i don't know if it would be a good idea.
for sure i can make a {{urlpostvar}} macro.
otherwise we can discuss having ? as urlpostvar, and not as alias of urlvar.
-
As there is not much again at the moment, it will be just small craftiness to put something itself under the tooth
when you find in your template
{{if|{{%bread-name%=}}|Home|%bread-name%}}
You can replace it by
{{or|%bread-name%|Home}}
Reminder: the macro {{OR|...}} sends back the first non-empty parameter
-
RAWR-Template already uses this and rejetto gave me that code :P guess he forgot to update his own.
The default template needs a fair bit of work, I could make it w3c web standard and better written within a nights work. It is quite bad at the moment. It uses xhtml yet doesn't follow many of the xhtml rules :P
{{breadcrumbs|{{\<a href="%bread-url%">{{or|%bread-name%|{{!lv_home}}}}/</a>/}}}}
Macro suggestion, {{encodeURI| }} {{decodeURI|}} {{escape|}} {{unescape|}}. I thought they were already suggested/implemented but they arent. Possible uses include encoding certain strings for use with flash applets, or just simply doing what the uses for these are in javascript/actionscript etc.
Lastly, is there a way to detect odd and even numbers, or a macro that could do such a job? I am interested to do this to implement alternate row colour into RAWR-Template.
-
by using {{or}} for such purpose, it will consider "empty" folders with name "0" and "false".
{{mod|%number%|2}} will tell you if a number is odd. even with a {{not}}
-
Macro suggestion, {{encodeURI| }} {{decodeURI|}} {{escape|}} {{unescape|}}.
could you please specify what they are supposed to do?
you can point me to an equivalent javascript function, if any.
-
ok,
http://www.w3schools.com/jsref/jsref_encodeURI.asp
http://www.w3schools.com/jsref/jsref_escape.asp
I use them alot but this explains it nicely.
And I do not know if it is possible... But it would be awesome to have one that converts special characters to their ascii or hex equivalent.
& etc. But i don't think there is a defined function for it.
-
by waiting
{{set|encodeURI| {{\ replace | < | %3C | >| %3E | { | %7B | [ | %5B | ] | %5D| } | %7D | ....|$1}} /}} }}
{{set|decodeURI| {{\ replace | %3C | < | %3E| > | %7B| { | %5B | [ | %5D| ] | %7D| } | ....|$1}} /}} }}
{{^encodeURI | text }}
-
Hi!
How it is possible with the aid of the macro to verify the presence of file in the folder?
For example about.html
And if file is present, then carry out one action, but if it does not exist, then carry out another action.
-
The below macro is from my templates. filesize only works with system directories, not with URL, so to do what you ask I am unsure. Unless it is a real folder of course. Then just put the name of the file in the if NAME.
{.if|{.filesize|%folder-resource%\NAME.}
|DO THIS
|DO THIS
.}
-
it will support URIs in next beta
-
The below macro is from my templates. filesize only works with system directories, not with URL, so to do what you ask I am unsure. Unless it is a real folder of course. Then just put the name of the file in the if NAME.
{.if|{.filesize|%folder-resource%\NAME.}
|DO THIS
|DO THIS
.}
Thanks! Now everything works! I'm so happy!!!
-
{.if|{.filesize|%folder-resource%\NAME.}
|DO THIS
|DO THIS
.}
it will support URIs in next beta
Useful idea, but you should not forget that to know the URL-file size it is necessary to load him, what can be long with some GBytes and only for detecter its existence,
A solution would be a macro {.file exist | URLNAME.} or {. get |can download| URLNAME.}
-
no.
local URIs are just converted to local file paths.
URLs instead are a way slower of course, but it doesn't depend on the size of the file, it's just a request for information to the server.
-
From a post of TSG
REQUIRES HFS BETA 183 or RECENT BUILD - http://www.rejetto.com/forum/index.php?board=33.0
I propose a macro short story whoever warned the administrator the used template requires a minimal version of hfs
{.min build|183.}
if (name ='min build') then
if addressmatch('127.0.0.1',md.cd.conn.address) then
msgdlg('This template requires at least the build version '+p+' of hfs to work completely')
else result:='';
-
Useful idea, but you should not forget that to know the URL-file size it is necessary to load him, what can be long with some GBytes and only for detecter its existence,
A solution would be a macro {.file exist | URLNAME.} or {. get |can download| URLNAME.}
No, it does not work. Nevertheless, the file, which is checked, must load
-
I propose a macro short story whoever warned the administrator the used template requires a minimal version of hfs
you can already solve the problem {.if|{.%build% < 183.}| warning .}
-
I propose a macro short story whoever warned the administrator the used template requires a minimal version of hfs
you can already solve the problem {.if|{.%build% < 183.}| warning .}
I do not include this on purpose, basically I want all users of my templates beta testing, therefore finding a lot more bugs and creating a better template engine. Look how far HFS has come in the last 12 months :D! I like to think I am somewhat helpful to HFS and its community.
-
sure you are, but i didn't understand the reason why you don't do that
-
Its another thing to update when releasing.
Its an extra thing for HFS to think about when generating the template.
If I'm gonna start making errors I may as well make errors for everything.
If the template is fucked it is obvious to upgrade HFS as...
I state it in the readme that they must upgrade their HFS.
I state it under the download links.
I think that's enough reasons :D.
-
all your templates have a minimum number for the required build.
if you forget to update that number (that you can keep in the configuration on top) that won't break anything.
if your tpl requires 183, but for an error you are checking for the 181, it won't be worst than it is now.
-
I was writting when rejetto post before me....
The utility of such an action is to prevent the recursive questions on the use of new macros, which would provoke inevitably some bugs on new template with old version of HFS
Of more the solution of rejetto imply a message on the utilisteur, while I propose an alert at the level of hfs, what adorned me more logical, instead of testing templates from every angle and allowing to pass an error
I have already tested the solution of rejetto but it did not seem to me sufficient(self-important), where from my proposition of macro with a message of alert at the level of the server
-
a macro to issue a warning message would be more flexible
-
I would prefer an alert from HFS as they import the template. Maybe something in [special:import].
[special:import]
{.if|{.BUILD_VAR=183.}|HFS ALERT INFORMATION.}
{.add folder|real|template.}
{.set item|/template|hide.}
{.set item|/template|no log.}
This way they are warned instantly. Instead of later, where they may just trust our builds to be stable and forget about testing it.
-
you could, with the macro i just told
-
my {.min build|183} or {.min build|183|alert-text.} is a shortcut of
{.if|{.and|{.match|127.0.0.1|%ip%.}|{.%build%<183.}.}|alert-text.}
if (name ='min build') then
begin
result:='';
if addressmatch('127.0.0.1',md.cd.conn.address) then
if par(1)>'' then result:=par(1)
else msgdlg('This template requires at least the build version '+p+' of hfs to work completely');
end;
-
this is a feature used only once and only in few templates.
i don't think we need a shortcut.
-
is there a new bug in the for loop from build 179 to 183? or changed sintax?
loopvar seems to have always final value!
with build #179:
{{for|ii|1|8|{{\[{{^ii}}]/}}}} works
output: [1][2][3][4][5][6][7][8]
with build #183:
{.for|ii|1|8|{:[{.^ii.}]:}.} does not work
output: [8][8][8][8][8][8][8][8]
hfs or my error ?
-
bug
fixed in next build
-
rejetto, thanks for that fast reply
-
Insert Quote
bug
fixed in next build
macro FOR EACH has the same bug
I am happy , i found where was the bug :D
theVar:=format('{{^%s}}',[p]); into functions: for_ () and foreach()
repaced by theVar:=format(MARKER_OPEN +'^%s'+MARKER_CLOSE,[p]);
-
yes, i fixed foreach as well
but i will wait to publish, to collect some more news
-
macros' syntax just doesn't allow spaces before the name of the macro.
this is always true except for infix operators like {. 3 > 2 .}
-
i didn't mean what the code does or not.
i meant what's the expected syntax, and what you can expect to be working correctly now and in the future.
the trim is there because spaces are allowed after the name.
anyway, at the moment there's no important reason for this rule, but i think we can ignore the problem of space^var.
-
I remove what I said, 'for i:=1 to -1 do msgdlg( inttostr(i));' is never executed in the delphi language
i am deleting all my post about this subject
-
Would it be possible to add a new simple macro {.hex|xx.} ?
This would be useful for me when working with plaintext files to detect or replace the linebreaks.
examples: (csv holds the whole text loaded}
{.count substring |{.hex|0d.}{.hex|0a.}|{.^csv.}.} to count lines
or:
{.replace|{.hex|0d.}{.hex|0a.}|<br />|{.^csv.}.} to insert line breaks
-
no sorry, that solution cannot be.
what i can do is to preserve spaces in {.replace.} and {.count substring.}
the problem is a feature: for the user's convenience macros ignore blanks.
some macros don't, because blanks can be useful, so i can just add these to the list.
i will if no one complains.
for readability you can
{.set|nl|{:
:}.}
and then use (in next build) {.replace|{.^nl.}|<br>|{.^csv.}.}
-
Is it possible on base HFS to make the guest book? So that the records in it would remain in the machine, in which was established HFS.
-
if they made a shoutbox, you can make a guestbook
-
Rejetto is correct, an extended version of my shoutbox would make a guestbook.
SilentPliz and Mars have put together a chat, I think using the methods in mine and javascript used in their chat would make a nice guestbook. I would have a play but I haven't got the time. I am focusing my attention to releasing RAWR-Player with FLV support, Terayon written on the base code of RAWR-Template and TPGen (we are up to making the interface).
Thanks rejetto for the macro. Will try it out with next release, most likely when RAWR-Player has FLV support I will release new builds of the templates.
-
if they made a shoutbox, you can make a guestbook
But shoutbox uses external server. My HFS is established in the local network without the output into the Internet; therefore I want so that the messages in the guest book would remain locally in the same machine, where was established HFS
-
the shoutbox embedded in the RAWR template (http://www.rejetto.com/forum/index.php?topic=5456.0) doesn't use external servers to provide the shoutbox.
-
the shoutbox embedded in the RAWR template doesn't use external servers to provide the shoutbox.
Yes it is , as this link https://silentplizssl.serveftp.net/chat/
login anonymous
pass anonymous
all is made with internal template
-
some posts have been moved to www.rejetto.com/forum/?topic=5839
-
I did not find normal that the use of the value true or quite other text is the opposite of 0 or an empty string
So, with these two functions modified in main.pas it is possible to restore the correctness of the values.
A negation will be represented well by an empty string, 0 or false.
I insist with Rejetto so that he made them appear constantly in the future versions of HFS ;)
function isFalse(s:string):boolean;
begin
s:=trim(s); ///mars
result:=(lowercase(s)='false') or stringExists(s, ['','0']); ///mars
end;
function isTrue(s:string):boolean; inline;
begin
result:=(lowercase(trim(s))='true') or not isFalse(s); ///mars
end;
With it you can use macro requiring a parameter true or false without asking you the question to know which syntax to use.
To test a template it will be more understandable to write
{.If|false|.... .}, {.If|FALSE|.... .}, {.If| false |.... .} at choice rather than {.if||.... .} or {.if|0|.... .}
-
it's widely accept in the technical world that special cases should be kept at a minimum. I fear having more special strings for false could create problems.
About the reason you report, use "if not" instead. It's very readable, isn't it?
If you have other reasons, we can discuss them.
in the while, i can suggest you that stringExists is case insensitive, so you can use
result:=stringExists(trim(s), ['','0','false'])
if you like...
-
in the while, i can suggest you that stringExists is case insensitive, so you can use
result:=stringExists(trim(s), ['','0','false'])
if you like...
The syntax is good and reacts as I wish it, it is accepted for my part and already in the French version of silentpliz
****************************
One the other macro is incorporated into it: {.add to log| your text.} ( ;) to Rejetto)
if name = 'add to log' then //Add by mars
begin
mainfrm.add2log(p);
result:='';
end;
this macro put 'your text' in the log box of hfs.
I use it rather often to test the templates, instead of the dialog macro.
-
and what about this
if name = 'add to log' then
begin
mainfrm.add2log(p, md.cd, StringToColor(parEx(1,'color')) );
result:='';
end;
-
and what about this
if name = 'add to log' then
begin
mainfrm.add2log(p, md.cd, StringToColor(parEx(1,'color')) );
result:='';
end;
I give the good macro syntax, but the macro code has a bug ;)
{.add to log| message blue |$F00000.} {.add to log| message blue |ClBlue.}
{.add to log| message green |$00F000.} {.add to log| message green |ClGreen.}
{.add to log| message red |$0000F0.} {.add to log| message red |ClRed.}
but the macro code has a bug, to correct it:
if name = 'add to log' then
begin
mainfrm.add2log(p, NIL , StringToColor(parEx(1,'color')) );
result:='';
end;
Otherwise the macro does not work when it is used in the hfs.events because there is no active connection during its call ;)
The ideal would be to have as possible syntax:
{.add to log| message blue |$F00000| message green |$00F000| message red |$0000F0.}
And to obtain in the log the result following on a line
00:13:11 message blue message green message red
It is just a little work in more for rejetto in the conception of the procedure add2log() ...
I count on him to take up the challenge, and to find us a solution which is as high as my waits. ;) ;D
-
i think that's not the right way to fix it.
in event scripts md.cd should just be NIL, and thus equivalent to your constant NIL.
what's missing is the clearing of md.
fixed in next build.
about colors: it's nice, but don't know if it's important enough to take all parameters of "add to log". We may need additional parameters in the future.
-
about colors: it's nice, but don't know if it's important enough to take all parameters of "add to log". We may need additional parameters in the future.
It would allow to put in evidence of the particular elements in the string shown by the log, for example certain variables as %user% and other , or to put in evidence in red of the specific alerts in the middle of a sentence and many other possibilities, if I make the demand it is that that will allow to see all this with a little more colour ;)
-
i didn't say i don't understand how it would be useful. re-read. ;)
-
Then you will want to use maybe rather this syntax ;D
{.add to log| [ color=blue] message blue [ /color] [ color=green] message green [ /color] [ color=red] message red [ /color] .}
-
Hi. How would I do this? :
<script type="text/javascript">
var path = document.location.pathname;
var dir = path.substring(path.indexOf('/', 1)+1, path.lastIndexOf('/'));
</script>
{.set|directory|dir.}
Where it sets 'directory' to equal the value of 'dir' in javascript...
I cant figure it out.
-
Are you trying to show breadcrumbs or what? I am slightly confused....
You cant talk to macro with JavaScript without using post or get form data. Or AHAH, for example. Macro is Server Side, JavaScript is Client Side.
-
<script type="text/javascript">
var path = document.location.pathname;
var dir = path.substring(path.indexOf('/', 1)+1, path.lastIndexOf('/'));
</script>
{.set|directory|dir.}
as TSG says, your macro will run BEFORE the javascript, because it runs on the server, while javascript on the client.
try using %folder% instead.
-
Dang.. %folder%. I knew about that. I dont know why I didn't think about it. haha
Thanks. And no this isnt for bread crums.
-
about breadcrumbs: rejetto, can you simply modify the code source with this line?
result:=result+xtpl(p, [ '%bread-url%', e, '%bread-name%', ad[ i],'%bread-idx%', inttostr(i)
]); //mod by mars 2009
He will add simply the variable %bread-idx% which allows to obtain the level of the sub-directory with as value 0 for the root.
I know that you will still ask me to justify the usefulness of such a variable ;D. to me it just seems obvious that there is a small hole to fill ;)
-
being a very little thing i don't need explanations about it. ;)
i would like to know if you or anyone would use it...
the point is not "hole to fill" or "easy to make".
more complex it is, more useful it should be to justify its existence.
i didn't invent this rule! http://fr.wikipedia.org/wiki/Principe_KISS ;)
i may also decide to include this thing without explanation, but this is not the general rule i try to apply to hfs development.
i'm sorry you see it as a caprice.
-
if they made a shoutbox, you can make a guestbook
But shoutbox uses external server. My HFS is established in the local network without the output into the Internet; therefore I want so that the messages in the guest book would remain locally in the same machine, where was established HFS
If you want to keep it simple, you can use an iframe in your template. Use php to create a simple and very costumizable shoutbox. You can use a text file instead of a database. You can use the usernames (%user%). Search the forum for 'Funboss Iframe' for more info about this. There is no need to use an external server, right?
Else { Forget my comment! ;) }