HFS: Modelli

From rejetto wiki
Jump to navigation Jump to search

In HFS 2.1, alcune delle informazioni procedurali presenti in questa sezione sono obsolete e, sebbene la quasi totalità delle informazioni circa le sezioni, i simboli, ecc., siano ancora corrette, sarà necessario usare il nuovo HTML Template Editor.


Fruizione dei templates dal forum

Puoi ottenere vari templates da HFS templates forum come pure da HFS Template Gallery.
Per inserire un template in HFS, segui questi passi:

  1. Apri il ''"Menu"'' in HFS.
  2. Seleziona "Other options" e apri "Edit HTML template".
  3. Copia il template recuperato dalle fonti di cui sopra (aprilo con un semplice editor di testo) e incollalo sovrascrivendo quello già presente nella finestra dell'editor.
    Agisci sul pulsante "Apply" quindi ''OK'' e riapri la finestra del browser (''Open in browser'') per vedere i cambiamenti della pagina.

Costruisci il tuo template

1. Apri il "Menu" in HFS.

2. Seleziona "Other options" e apri "Edit HTML template".

3. Premi il pulsante "Help" per vedere la lista dei simboli disponibili.

Aiuto del Template (Template help)

HFS costruisce dinamicamente le pagine di HTML caricando pezzi di codice HTML da un template.
Un template è testo diviso in sezioni.
Ogni sezione descrive una parte della pagina HTML finale che sarà servita al browser che l'ha richiesta.
Il template deve fornire tutte le sezioni per far lavorare in modo corretto l'HTML generato ed è per questo che, solitamente, una sezione contiene codice HTML.
Poichè la pagina finale HTML è costruita dinamicamente, i simboli vengono utilizzati per generare un valido output.
I simboli sono racchiusi dal carattere % ('%percent%') e definiscono le corrispondenti sezioni.
Una sezione è contraddistinta da una coppia di parentesi quadre '[square brackets]' che la contengono.
I simboli vengono tradotti in valori attuali durante il tempo di esecuzione.
Alcuni simboli ritornano una sequenza per la variabile corrente, mentre altri sono attivati solamente se una certa condizione è soddisfatta.
Tra i simboli, alcuni specifici operatori di linea possono anche richiedere alle sezioni di generare codice HTML per l'output.

Nella sezione principale, che è senza etichetta, e in tutte le altre sezioni, i simboli e gli operatori di linea di comando possono essere usati per controllare la produzione di HTML.
Alcuni simboli sono limitati ad una specifica sezione, altri produrranno HTML dalle sezioni corrispondenti, mentre altri ancora ritorneranno il corrispondente valore o la stringa attuale.

Il metodo migliore per creare un nuovo template è quello di rieditare un template già esistente e di utilizzarlo, quindi, come modello.

Dov'è immagazzinato il template? (Where is the template stored)

Il template è sempre salvato "adiacente" alle opzioni.
Se le opzioni sono salvate su disco (il file hfs.ini) anche il template sarà salvato su questo (con il nome di hfs.tpl).Quindi, nella stessa cartella, saranno presenti questi due files e il file del programma (hfs.exe).
Più spesso, sia le opzioni che il template vengono salvati direttamente nel registro di Windows (opzione di default).

Il template viene caricato all'avvia di HFS.
Se nella cartella di HFS non è presente alcun template, verrà caricato quello predefinito.

Lista dei simboli - per sezione (Symbols list - by section)

Simboli disponibili in tutte le sezioni

%style%
inserisce HTML dalla sezione [style]
%login-link%
inserisce HTML dalla sezione [login-link] se nessun utente è loggato, valore nullo in tutti gli altri casi
%loggedin%
inserisce HTML dalla sezione [loggedin] se un utente è loggato, valore nullo in tutti gli altri casi
%user%
restituisce il nome degli utenti autenticati, valore nullo se nessun utente è loggato
%ip%
inserisce sulla pagina l'indirizzo IP del client
%version%
restituisce il numero di versione di HFS
%timestamp%
restituisce il valore della data e dell'ora sul server (il formato è definito dai valori impostati sul SO)
%uptime%
restituisce il valore, in termini di tempo, del funzionamento continuo di HFS senza spegnimenti
%connections%
restituisce il valore del numero corrente di connessioni verso HFS
%speed-out%
restituisce il valore della velocità corrente in uscita
%speed-in%
restituisce il valore della velocità corrente in entrata
%total-out%
restituisce il valore totale dei bytes inviati
%total-in%
restituisce il valore totale dei bytes ricevuti
%number-addresses%
restituisce il valore del numero corrente di clients connessi (indirizzi IP)
%number-addresses-downloading%
restituisce il valore del numero corrente di clients che effettuano il download (indirizzi IP)

Simboli disponibili nella sezione principale (Symbols available in the main section)

%up%
inserisce HTML dalla sezione [up] se la cartella corrente non è la radice del sito, valore nullo nel caso di root
%upload-link%
inserisce HTML dalla sezione [upload-link] se l'upload è disponibile per la cartella considerata, valore nullo in tutti gli altri casi
%host%
restituisce il campo Host http header, come inviato dal browser.
Es.: Server-URL(:porta) o Server-IP(:porta)
%number%
restituisce il valore del numero di elementi (cartelle + files) nella cartella corrente
%number-folders%
restituisce il valore del numero di cartelle contenute nella cartella corrente
%number-files%
restituisce il valore del numero di files contenuti nella cartella corrente
%total-size%
restituisce il valore totale sulla quantità di spazio occupato dagli elementi contenuti nella cartella corrente
%total-kbytes%
simile a %total-size%, ma espresso in kilobytes
%total-bytes%
simile a %total-size%, ma espresso in bytes
%build-time%
restituisce il valore del tempo impiegato per generare la pagina
%files%
inserisce HTML dalla sezione [files] se almeno un elemento è presente nella cartella corrente, inserisce HTML dalla sezione [nofiles] negli altri casi

Simboli disponibili nella sezione [file] (Symbols available in section [files])

%list%
la lista completa degli elementi presenti nella cartella corrente, the full list of items in the current folder, ricavata aggiungendo ogni elemento dopo la sezione pertinente dove è inserito [folder], [file] o [link].

Simboli disponibili nelle sezioni [file], [folder] e [link] (Symbols available in sections [file], [folder] and [link])

%new%
inserisce HTML dalla sezione [new] se il file è recente (Menù principale >>> Virtual File System >>> Flag files added recently ...), valore nullo negli altri casi
%comment%
inserisce HTML dalla sezione [comment] se un commento è disponibile per l'elemento, valore nullo negli altri casi
%item-url%
restituisce il valore del percorso per raggiungere l'elemento
%item-name%
restituisce il valore per il nome dell'elemento
%item-folder%
restituisce il valore del percorso verso l'elemento ma non nel formato URL.
Spesso, ha lo stesso valore di %folder%, ma differisce nel caso delle liste ricorsive (recursive listings)
%item-added%
restituisce il valore per la data e l'ora in cui l'elemento è stato aggiunto al VFS (la data e l'ora sono definite dalle impostazioni del OS)

Simboli disponibili nelle sezioni [file] e [folder] (Symbols available in sections [file] and [folder])

%item-dl-count%
restituisce il valore tthe value for the download counter (virtual folders totalize inner counters)
%item-modified%
restituisce il valore per la modifica dell'ora come riportato dal file o dalla cartella (data e ora sono definite dalle impostazioni del SO)

Simboli disponibili nella sezione [file] (Symbols available in section [file])

%item-size%
restituisce il valore per la quantità di spazio occupata dall'elemento
%item-size-b%
come %item-size%, ma espressa in bytes
%item-size-kb%
come %item-size%, ma espressa in kilobytes

Symbols available in sections [upload], [upload+progress], [upload-results] and main section

%diskfree%
returns the value for the total amount of available space minus the reserved space in the drive containing the current folder (makes sense only for real folders)
%folder%
returns the value for the path to the current folder
%encoded-folder%
returns the value for the encoded path to the current folder
%parent-folder%
returns the value for the encoded path to the parent folder
%folder-comment%
inserts the HTML from section [folder-comment] if a comment is available for the current folder, void otherwise

Symbols available in section [error-page]

%content%
inserts the HTML from sections [ban], [deny], [not found], [unauthorized] or [overload], depending on the error code

Symbols available in section [ban]

%reason%
returns value for the ban description from the hfs.ini

Symbols available in section [progress]

%progress-files%
inserts the HTML from section [progress-nofiles] if no file is transferred with the current client, otherwise the list of transferring files got by pasting each file after the pertinent section [progress-download-file] and/or [progress-upload-file] is inserted

Symbols available in sections [progress-download-file] and [progress-upload-file]

These sections are related to file transferring.

%perc%
returns the value for the percentage done
%filename%
returns the value for the name of the file
%done-bytes%
returns the value for the transferred bytes
%done%
same as %done-bytes%, but using dynamic measure units
%total-bytes%
returns the value for the number of bytes of the completed transfer
%total%
same as %total-bytes%, but using dynamic measure units
%speed-kb%
returns the value for the throughput speed


Symbols available in section [upload]

%uploaded-files%
input boxes for files to be uploaded got by pasting [upload-file] for each file
%host%
returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port) (since v2.1beta)
%up%
inserts HTML from section [up] if the current folder is not the root, void otherwise (since v2.1beta)

Symbols available in section [upload-file]

%idx%
ordinal index of the input box

Symbols available in section [upload-results]

%uploaded-files%
list of uploaded files got by pasting section[upload-success] and/or section [upload-failed] for each file
%host%
returns the Host http header field, as sent by the browser eg. Server-URL(:port) or Server-IP(:port) (since v2.1beta)
%up%
inserts HTML from section [up] if the current folder is not the root, void otherwise (since v2.1beta)

Symbols available in sections [upload-success] and [upload-failed]

%item-name%
name of the file
%item-url%
address of the file

Symbols available in section [upload-success]

%item-size%
returns the value for the size of the uploaded file
%speed%
returns the value for the average upload speed

Symbols available in section [upload-failed]

%reason%
returns the value for the error occurred while uploading

Address line operators list

Address line operators can be used in HTML eg. href="/~login" and in the address command line of the browser eg. www.yoursite.com/~login.

~nodefault
doesn't serve default file in a folder, but folder with files (since v2.1beta)
~login
calls for the login screen
~files.lst
inserts HTML from filelist.tpl if exists in hfs.exe folder, otherwise produces ASCII file list of the requested folder
~img
shows server graphic
~progress
calls the HTML from section [progress]
~upload
calls HTML from section [upload] for the requested folder
~upload-no-progress
calls HTML from section [upload-no-progress] for requested folder
~upload+progress
calls HTML from section [upload+progress] for the requested folder

Sections list

Sections available in the template:

[style]
HTML for the %style% symbol
[login-link]
HTML for the %login-link% symbol when no user is logged in
[loggedin]
HTML for the %loggedin% symbol when the user has logged in
[up]
HTML for the %up% symbol when there's a parent folder (not root)
[link]
HTML for the a link to an URL
[folder]
HTML for the link to a folder
[file]
HTML for the link to a file
[file.<EXT>]
used in place of [file] when the file has the specified extention
[files]
HTML for the %files% symbol when the current folder is not empty
[nofiles]
HTML for the %files% symbol when the current folder is empty
[comment]
HTML for the %comment% symbol for sections [file], [folder] and [link] if available in the VFS
[folder-comment]
HTML for the %folder-comment% symbol if available in the VFS
[newfile]
HTML for the %new% symbol if the item is marked as new
[upload-link]
HTML for the %upload-link% symbol when the user has upload rights
[upload]
HTML for the ~upload command
[upload-file]
HTML for the upload form
[upload-results]
HTML for the upload results page after upload has finished
[upload-success]
HTML for the successfully uploaded files
[upload-failed]
HTML for the unsuccessfully uploaded files
[progress]
HTML for the %progress% symbol
[progress-download-file]
HTML for ongoing download
[progress-upload-file]
HTML for ongoing upload
[progress-nofiles]
HTML when no file transfer is ongoing
[upload-no-progress]
HTML for the ~upload-no-progress command
[upload+progress]
HTML for the ~upload+progress command
[error-page]
HTML in case of an error
[overload]
HTML for the %content% symbol
[unauthorized]
HTML for the %content% symbol
[deny]
HTML for the %content% symbol
[ban]
HTML for the %content% symbol
[max contemp downloads]
HTML for the %content% symbol
[not-found]
HTML for the %content% symbol