rejetto forum
Software => HTML & templates => HFS ~ HTTP File Server => RAWR-Designs => Topic started by: TSG on December 08, 2007, 12:42:59 PM
-
Just thought I'd post about the new template I'm working on.
It's a hybrid between ToG and Terayon with a completely new CSS and HTML code set. This one follows the colour scheme of our homepage and will be avaliable in a few other colour sets too, will just be a simple change of the CSS sheet.
It is nowhere near completion, but you can take a look. :o
-
Alright i need help with some macro's here... rejetto, mars... time to use brains.
I am trying to make a check for an archive button on our new template.
{{if|{{get|%item-archive%}}|{{$archive-on}}|{{$archive-off}} /if}}
[item-archive]
true
[archive-on]
<div class="quickBtn1" onmouseover="onBtn(this)" onmouseout="offBtn(this)"><a href="%item-url%~folder.tar?recursive" title="Download the content of this folder as a .tar Archive"><img src="/template/images/Download.gif" alt="DL" align="middle"></a></div>
[archive-off]
<div class="quickBtn1 disabled" onmouseover="onBtn(this)" onmouseout="offBtn(this)"><img src="/template/images/Download.gif" alt="DL" align="middle"></div>
what am i doing wrong...
-
{{if|{{$%item-archive%}}| ...
-
It works! But its backwards :P...
{{if|{{$%item-archive%}}|{{$archive-off}}|{{$archive-on}}/if}}
that does it correctly. even tho the logic appears to be reversed...
-
Ok, i am trying use macro's throughout this template. Since i've heard that it is a faster system :)
I have compiled a list, if you don't already know, of the symbols/ sections that don't function as macro's as i've found them thus far.
%folder%
%host%
%number-files%
%number-folders%
%number%
%total-size%
{{$archive}} does not hide for disabled like %archive%
{{$upload-link}} does not hide for disabled like %upload-link%
{{$up}} does not hide for disabled like %up%
{{$login-link}} does not hide for disabled like %login-link%
{{$loggedin}} does not hide for disabled like %loggedin%
%uptime%
%timestamp%
%connections%
%speed-in%
%speed-out%
%total-in%
%total-out%
%total-downloads%
%total-uploads%
%total-hits%
%ip%
%build%
%version%
%user%
%list%
%item-url%
%item-name%
%item-size%
%item-dl-count%
%item-modified%
%sequential%
%item-comment%
%parent-folder%
{{$loggedin}} does not hide for not logged in like %login-link%
or am i doing it wrong >_> it is either {{symbol}} or {{$symbol}} {{type|symbolname}} none seem to work...
I think i get it, without %% those sections are shown as a constant, and without defined type the symbols wont show.... but whats type for say...
%list%
-
TO TSG
download rejetto template attached
desactivate 'archivable' to root and activate some sub-folder being archivable
and see what append at the place of filesize
-----------------------------------------------------
pour rejetto
activer 'archivable' sur la racine implique que la même option pour les sous-dossiers est activée par défaut, il faudrait envisager les deux cas 'full archivable' and 'recursive archivable'
'full archivable' : all subdirs are archivable by 'herited'
'recursive archivable' : only sub-folders wich are 'archivable' activated are achivable in folder.tar
tu comprends la différence?? un peu à la manière des droits sur les dossiers
-
I took a look at the default template, it still shows the old symbols as %symbol% so i guess i'll just leave them :D
-
It is the last one template by defaut which I used, I was only interested in the case
{{if|{{get|%item-archive%}}|{{$archive-on}}|{{$archive-off}} /if}}
[item-archive]
true
[archive-on]
<div class="quickBtn1" onmouseover="onBtn(this)" onmouseout="offBtn(this)"><a href="%item-url%~folder.tar?recursive" title="Download the content of this folder as a .tar Archive"><img src="/template/images/Download.gif" alt="DL" align="middle"></a></div>
[archive-off]
<div class="quickBtn1 disabled" onmouseover="onBtn(this)" onmouseout="offBtn(this)"><img src="/template/images/Download.gif" alt="DL" align="middle"></div>
On the other hand if the couple [mysection] and {{section|mysection}} works, he goes away differently for sections previous to the macro as [login-link] and [loggedin]
{{if not| %user% |{{section|login-link}} }}...{{if| %user% | {{section|login-link}} }}
same result than %login-link% ...%loggedin%
you can change %list% to {{section|list}}, it is a special usage to hfs, as for %user%
At the moment your action is limited to the former(ancient) call of section
[sym-section] %sym-section% ----> [mysection] {{section|mysection}}
I think that %symbol% has to keep(guard) his structure of origin not to be confused with the macro, certain manners are in connection with data appropriate for the functioning of hfs and would require a radical modification of the code.
-
Yes i have included something like this and many more. All i need is the ability to say, if this or this or this... somehow, then i can create my filelist with just [file] ... then, i would like the ability to find the indexOf within the header or any string, i posted in the macro one.
All good. is substring ;)
-
Yes i have included something like this and many more. All i need is the ability to say, if this or this or this... somehow, then i can create my filelist with just [file] ... then, i would like the ability to find the indexOf within the header or any string, i posted in the macro one.
All good. is substring ;)
Check out Rejetto's switch macro: http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros
-
Ye i managed to get it working with that, thanks anyway :D
I now have all my 'files' coming out of one section with macros :) makes it very easy to edit now.
Here is what i had to do.
[file]
<tr>
<td class="iconCol">
{{switch|%item-ext%|,|jpg|{{$thumbs}}|png|{{$thumbs}}|bmp|{{$thumbs}}|<div style="background:url('/~img_file') center center no-repeat"></div>}}
</td>
<td class="fileCol%protected%" {{if|%protected%|{{$row-js-p}}|{{$row-js}}/if}}>
<span class="fileInfo">
<a href="%item-url%" {{$target}}>%item-name%</a><br/>
%comment%
<span><b>Size:</b> %item-size%</span>
<span><b>Hits:</b> %item-dl-count%</span>
<span class="age"><b>Age:</b> %item-modified%</span>
</span>
</td>
<td class="quickCol">{{switch|%item-ext%|,|jpg|{{$preview-btn}}|png|{{$preview-btn}}|bmp|{{$preview-btn}}|mp3|{{$preview-btn}}|swf|{{$preview-btn}}|divx|{{$preview-btn}}|avi|{{$preview-btn}}|<div class="disabled hide"></div>}}
<noscript><div class="disabled"></div></noscript>
<div class="quickBtn1" {{$btn-js}}><a href="%item-url%" {{$target}} title="Download this file."><img src="/template/images/Download.gif" alt="DL"></a></div>
</td>
</tr>
[thumbs]
<div style="background:url('/template/images/Default-Thumb.gif') center center no-repeat">
<noscript><div style="background:url('previews_and_thumbnails/thumb-%item-name%.jpg') center center no-repeat"></div></noscript>
<img class="hide" src="previews_and_thumbnails/thumb-%item-name%.jpg" onerror="imgError(%sequential%,this)" align="middle"/>
</div>
[preview-btn]
<div {{$btn-js}} id="s%sequential%" class="hide" {{if|{{%item-ext%=mp3}}|name="mp3File"}}><a href="javascript:void(0)" onclick="initPreviewBox('Box-'+(%sequential%+1),'%item-ext%',this.name)" name="{{if|{{%item-ext%=mp3}}|http://%host%%encoded-folder%}}%item-url%" title="Launch preview box."><img src="/template/images/Preview.gif" alt="P" align="middle"/></a></div><span id="Box-%sequential%"></span>
[target]
{{switch|%item-ext%|,
|gif|target="_blank"
|pdf|target="_blank"
|htm|target="_blank"
|html|target="_blank"
|txt|target="_blank"
|css|target="_blank"
|jpg|target="_blank"
|png|target="_blank"
|}}
-
this is better {{switch|%item-ext%|,|jpg,png,bmp|{{$thumbs}}|<div ....... }}
in such case you can also use
{{if| {{match|jpg;png;bmp|%item-ext%}} | {{$thumbs}} | <div .... }}
{{$archive}} does not hide for disabled like %archive%
indeed, that's what it's meant to do.
it's not like %archive%.
%archive% is sometimes empty.
{{$archive}} is always the section.
if you want to put a condition, you can use {{if}} like the default tpl does
-
I was wondering if i could stack up some parameters :) I will try these now.
I found the 'can archive' after some time ;)
EDIT: Cool it works, and the code is much less redundant. Am i right to say that switch is the faster method?
-
Ok, i am trying use macro's throughout this template. Since i've heard that it is a faster system :)
you won't get a faster template using macros in place of symbols.
the full story is rather complex, but the point is that HFS is slowed down by the making of symbols table. macros are calculated upon request, while symbols must be pre-calculated and eventually applied. symbols are calculated even if you don't use them.
some symbols will be deprecated, then discarded, over time.
-
Are macro's faster or slower than php execution times? I mean, if you place alot of macro's in a template, would that significally reduce the speed on slower computers? (E.g. my 500mhz server).. Or is it barely noticeable
Minimizing or even remove the use of jacascript really sounds good
-
It is as for a RUBIK'S CUBE, the speed with which you find the solution, depend on the used method.
Certain macro are faster than variables %symbol%, and conversely.
Everything depends in which context they are used.
If we have a symbol and a macro which make the same spot, they appeal to the same function in the language delphi.
The php, it is as of the javascript, but executed by the highly-rated of the server.
if you place alot of macro's in a template, would that significally reduce the speed on slower computers?
It is always the same problem, any depend of the way you order your code
if x=a then a();
if x=b then b();
if x=c then c();
....
if x=z then z();
it is faster to do
if x=a then a()
else if x=b then b()
else if x=c then c()
....
else if x=z then z();
the next
if x= b then test is closed and continue to 'the next'
-
Can we make this one quicker... I'm not too happy with it being in 4 lines...
{{if|{{is substring|127.0.0.|%ip%}}|{{$update-mod}}}}
{{if|{{is substring|10.0.0.|%ip%}}|{{$update-mod}}}}
{{if|{{is substring|10.1.1.|%ip%}}|{{$update-mod}}}}
{{if|{{is substring|192.168|%ip%}}|{{$update-mod}}}}
-
{{if|{{is substring|127.0.0.|%ip%}}|{{$update-mod}}}}
{{if|{{is substring|10.0.0.|%ip%}}|{{$update-mod}}}}
{{if|{{is substring|10.1.1.|%ip%}}|{{$update-mod}}}}
{{if|{{is substring|192.168|%ip%}}|{{$update-mod}}}}
replace it by
{{if |{{match address|%ip%|127.0.0.;10.0.0.;10.1.1.;192.168.}}| {{\ $update-mod /}} /if}}
'127.0.0.;10.0.0.;10.1.1.;192.168.' is passed to hfs as one parameter (as a mask).
new usage : '{{\ ' macro ' /}}' at the place of {{macro}} when you use macros into a if even you get some error ( look at wiki about this) http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros#Problem
-
Doesn't work. Copying what you have directly shows as a broken macro, and editing it to work properly, it doesn't work... I'm not trying to match whole address's just parts of address's.
-
I mean, if you place alot of macro's in a template, would that significally reduce the speed on slower computers? (E.g. my 500mhz server).. Or is it barely noticeable
test and let us know. ;)
{{if |{{match address|%ip%|127.0.0.;10.0.0.;10.1.1.;192.168.}}| {{\ $update-mod /}} /if}}
you must add {{\ ... /}}
not just \ ... /
so, it's
{{if| {{match|127.*;10.*;192.168.*|%ip%}}| {{\ {{$update-mod}} /}} /if}}
-
I mean, if you place alot of macro's in a template, would that significally reduce the speed on slower computers? (E.g. my 500mhz server).. Or is it barely noticeable
test and let us know. ;)
Out of curiosity last night I tested the ToG and TSG's new template on the same vfs consisting of 10.8k items.
The results were, ToG 54 seconds build time
and the new template 66 seconds build time
even though the tog was faster I think that the macro's are faster in general because you have to take into consideration how many macro's TSG has used for each file, and someone would be crazy to recursively list a vfs of 10.8k items let alone a have single folder of 10.8k items.
-
Foggy,
Are you sure about the results - 54 seconds and 66 seconds? Those build times are just less than a minute on the first test and just over a minute for the second test. Those are very slow results to build a page. Maybe you meant 0.540 seconds and 0.660 seconds.
-
Yes, I am sure. Like I said above there was about 10,800 items being listed. I also used two instances of HFS to avoid any possible caching.
-
Local testing is a lot slower than external, i have noticed this by testing over the network, cause the browser will use 20-30% of the cpu loading the page, and hfs about 10%... and if ur listening to music thats another 5%ish :P might want to run the test again over the internet with only hfs and the browser running on the host and client pc's
Those results are correct for the test. if you do the math, its about 0.004 - 0.005 sec / row.
Even so, the results are impressive considering the amount of characters/row and like foggy stated, the amount of macro's in use in the new template. The macro system is considerably faster.
-
I don't think we need the macros to be faster.
It is more powerful (because some things can be done only on the server and not in javascript).
It is more compatible (because you know the compatibility problems of javascript).
It is a choice (because you can always keep using javascript if you want to).
So, even if it is 10% slower, it would be a normal price to pay.
p.s. take in account disk caching over different tries
-
Last night I was able to remove 2 more javascript page load functions with macro, you can expect these updates in ToG and Terayon once this new one is out in the public.
What else... I've hopefully fixed the foriegn character bug with 'encodeURI' in place of 'escape' and decodeURI' in place of 'unescape'. I was going to respond to the topic but i couldn't find it, might be in the 'other language' board.
Also this template is w3c standard as xhtml, there is just 'name' errors caused by encoded characters in the name field, which i can't do anything about.
Few bugs to iron out with the preview box but it's getting there :)
-
Consideration about speed of templates:
1. Parsing macros and replacing them by code or values will last some dozens of nanoseconds. Optimizing macros you can perhaps save some microseconds on the whole template!
2. What may be time consuming is access to disk, when not all data is already in the cache of the disk. Disk access to directories or to images or to files to be included may each be at about 10 miliseconds, this will especialy be noticed when you do things recursive or you are searching.
3. The most slow part is shuffeling out the generated page to the net. With an uploadbandwith of about 300 kbps, a 50 files page(about 25 kB) will last about 1 second, a 300 files page (100 kB) will last 3 seconds(you have to add the filesizes for images,backgrounds etc. that are not already cached on client-side).
Conclusion:
A) Using macros will create faster individual pages than java script, because decisions are taken and data manipulated on serverside, what allows to reduce the size of de code to be sent.
B) Try to hold code in recursively used sections like file,folder and link short, as this may increase the size of the generated page.
C) You can save time using external stylesheet and javascript files, as they can be cached on client side, so the generated pages are shorter.
D) Optimizing the code of macros for speed will result in about the same difference as your bodys weight after or before shaving.
-
I'm not too concerned about speed anymore, it is all relative. But that is a detailed explanation ;)
-
First beta is coming,
I have decided that I will release a first beta in the default blue theme to get the template out there. I have been rather busy traveling and doing other things lately. So far it is bug free from what i and my bug tester foggy can see, i just need to implement searching and it will be ready for the first beta release. Hopefully sometime tonight or tomorrow...
-
lol 2 days later, i'm close, search is implemented, bugs are fixed, i just need to figure out how to detect values in the url with macro and i can finish it off. For those that feel helpful, what i need to do is detect for example ?search= in the url to create no search results error page, i did it with javascript previously but i want to do it with macro. Values that i need to detect include, ?search=, ?filter=, ?files-filter=, ?folders-filter=, this will then change items on the page. I also need to grab the urlvar and show it in the default search field, that shouldn't be difficult i think there is a macro to do it already.
-
TSG
put this in your template
{{?recursive=}}&{{?rev=}}&{{?search=}}&{{?filter=}}&{{?files-filter=}}&{{?folders-filter=}}
if you put nothing in your url you obtain 1&1&1&1&1&1
this work in URL with all symbol you use
-
i'm not sure what you mean by detecting "?search="
what's wrong with "{{?search}}" ?
-
For an error page, I need to detect if a search returned no results so i can change 'No Files or Folders' to 'Search returned no results...' for example. I also need to grab the searched query and show it in the search field so the user knows what they searched for last.
Also i have no idea what ur talking about mars.
EDIT: dw we figured it out, now to make it work for filters.
-
{{if|{{?search}}{{?filter}}{{?files-filter}}{{?folders-filter}}| Search returned no results | No files or folders }}
-
WOAH u made the same as me!
{{if|{{?search}}{{?filter}}{{?files-filter}}{{?folders-filter}}|Your search for <i>{{?search}}{{?filter}}{{?files-filter}}{{?folders-filter}}</i> returned no results.|No Files or Folders}}
only problem is showing the value for the files and folder filters cause of the extra data and i'll have to cut the string.
-
remember you can do
{{set|x|{{?search}}{{?filter}}{{?files-filter}}{{?folders-filter}}}}
{{if|{{^x}}|Your search for <i>{{^x}}</i> returned no results.|No Files or Folders}}
Anyway, make an example of your string problem and i will help you.
-
my solution,
value="{{$search-data}}"
[search-data]
{{?search}}
{{cut|2|-1|
{{?filter}}
{{if not|{{ {{?files-filter}}=\ }}| {{?files-filter}} }}
{{if not|{{ {{?folders-filter}}=\ }}| {{?folders-filter}} }}
}}
-
try {{?files-filter = \ }}
instead of {{ {{?files-filter}}=\ }}
it should work.
if you use {{set}} instead of sections, you can take things nearby.
-
Ye, the simple search form is a long way from the [files] section so i used a section.
Ye it works rejetto, i think this template is ready for a public beta... once i read through it again lol.
http://61.68.214.92:5252/That%20Stevens%20Guy's%20Template%20Resources/Test%20Area/
test away while my dyn ip holds up lol.
RELEASED
This topic has been moved to:
http://www.rejetto.com/forum/index.php?topic=5456.0