rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: luca69 on January 29, 2009, 08:55:11 AM

Title: Comments: name of user that uploads the file
Post by: luca69 on January 29, 2009, 08:55:11 AM
The current template I'm using is generating a Multi-comment files hfs.comments.txt but this has some drawbacks:
- When a new file is uploaded, the hfs.comments.txt file is updated  ;D
- When a file is deleted, the hfs.comments.txt is not update  :(
  --> the hfs.comments.txt grows forever  :o
- Add again the same file, but without a user logged in
  --> the hfs.comments.txt contains already an entry for this file and the wrong information is shown  :'(

Possible solution: I changed the code in the [upload-success] section so that now a single-comment file is generated with the name of the user who uploaded the file.

Old code.
Code: [Select]
{.if| %user% |{: {.append| %folder-resource%\hfs.comments.txt |{.filename|%item-resource%.}=uploaded by %user% /append.} :}/if.}

New code:
Code: [Select]
{.if| %user% |{: {.append| %folder-resource%\{.filename|%item-resource%.}.comment |uploaded by %user% /append.} :}/if.}

This solves the first problem (hfs.comments.txt grows forever)

But now, to evaoid the second problem,  I should add a function that when a file is deleted, the "single-comment file" is deleted as well.

Any idea how I can do that?
Title: Re: Comments: name of user that uploads the file
Post by: rejetto on February 01, 2009, 12:49:46 PM
how is the file deleted?
Title: Re: Comments: name of user that uploads the file
Post by: Mars on February 01, 2009, 09:50:32 PM
We also have the same problem with files .md5, how to kill all the files which carry a defined name and its associated files?
Title: Re: Comments: name of user that uploads the file
Post by: luca69 on February 02, 2009, 07:32:35 AM
how is the file deleted?
Using the delete files function of the HFS Web interface  ;D

If a someone deletes the files directly on the server, he/she should also delete the comment file  ;)
Title: Re: Comments: name of user that uploads the file
Post by: luca69 on February 02, 2009, 07:33:16 AM
We also have the same problem with files .md5, how to kill all the files which carry a defined name and its associated files?
I noticed that looking for a solution of my problem  :o
Title: Re: Comments: name of user that uploads the file
Post by: rejetto on February 02, 2009, 03:16:37 PM
yes, it's a problem.
next build will delete F + F.md5 + F.comment
Title: Re: Comments: name of user that uploads the file
Post by: Mars on February 02, 2009, 06:04:06 PM
yes, it's a problem.
next build will delete F + F.md5 + F.comment

Do not forget to destroy also all the comments of the same file in hfs.comments

I recommend you for it, the systematic setting-up of the management reading writing of files .ini under Windows, it would facilitate the use of comments, and would in certain cases allow to read and to write  in the hfs.ini with data personalized by the administrator without that the change of version hfs give certain problems ;)
Title: Re: Comments: name of user that uploads the file
Post by: rejetto on February 03, 2009, 01:50:51 AM
I recommend you for it, the systematic setting-up of the management reading writing of files .ini under Windows,

i didn't understand this :-X
Title: Re: Comments: name of user that uploads the file
Post by: luca69 on February 03, 2009, 12:47:04 PM
yes, it's a problem.
next build will delete F + F.md5 + F.comment


GREAT!!!Thanks a lot rejetto  ;D ;D
Title: Re: Comments: name of user that uploads the file
Post by: rejetto on February 04, 2009, 12:58:19 AM
ok, it will also delete from hfs.comments.txt and descript.ion
it took an hour or two to make this -.-
Title: Re: Comments: name of user that uploads the file
Post by: luca69 on February 04, 2009, 07:38:37 AM
ok, it will also delete from hfs.comments.txt and descript.ion
it took an hour or two to make this -.-

 :o :o :o :o :o :o
Title: More on Comments
Post by: luca69 on February 04, 2009, 10:36:30 AM
I found a nice template from one of our France friends that enables the user to add a comment to each uploaded file.
I think it's a nice (now with build 221 comments are better supported by HFS).
But the code is not working  :(
It looks like he changed also the code of HFS and not only the template  :o :o :o :o

But let's have a look at the code (you can find the complete template as Attachment):

Code: [Select]
Original:
[upload-file]
<input name='fileupload%idx%' size='70' type='file'>
{.if |{.and|%user%|{.!=|%user%|anonymous.}.}|

New:
[upload-file]
<input name='%file-upload%' size='70' type='file'>
{.if |{.and|%user%|{.!=|%user%|anonymous.}.}|
{:
  {.repeat|2|&nbsp;.}
  <input name="%comment-upload%" size=40 type=text>
:}/if.}<br / </a>

......
[upload-success]
Original:
<li><a href='%item-url%'>%item-name%</a>: <b>{.!OK.}</b> --- %item-size%  ({.!Speed.} %speed% KB/s)
{.if| %user% |{: {.append| %folder-resource%\hfs.comments.txt | Uploaded by %user%
/append.} :}/if.}

New:
[upload-success]
<li><a href='%item-url%'>%item-name%</a>: <b>{.!OK.}</b> --- %item-size%  ({.!Speed.} %speed% KB/s)
{.if| %user% |{: {.append| %folder-resource%\hfs.comments.txt |{.filename|%item-resource%.}={.convert|utf-8|ansi|%item-comment%.} Uploaded by %user%
/append.} :}/if.}

....


But the vars %item-comment% and %file-upload& do not exist ?!?!?

Anyhow is there a way to do the same with build 221 ?!?
Title: Re: Comments: name of user that uploads the file
Post by: rejetto on February 07, 2009, 05:23:48 PM
maybe that template is using modifications made by mars.
in HFS you are supposed to not pass html inputs with such %names%, but with normal names, and read/use them by {.$name.}


what you want to get?
Title: Re: Comments: name of user that uploads the file
Post by: Mars on February 07, 2009, 10:11:55 PM
Quote
maybe that template is using modifications made by mars.

Thank you my friend to have a thought for me ;)

Quote
But the vars %item-comment% and %file-upload& do not exist ?!?!?

If it interests rejetto, I can supply all the elements necessary for their implementation in the next version of hfs

Title: Re: Comments: name of user that uploads the file
Post by: rejetto on February 08, 2009, 05:03:52 PM
what's the point in using that symbols instead of {.$name.} ?
Title: Re: Comments: name of user that uploads the file
Post by: luca69 on February 09, 2009, 08:18:54 AM
maybe that template is using modifications made by mars.
in HFS you are supposed to not pass html inputs with such %names%, but with normal names, and read/use them by {.$name.}


what you want to get?
I would like to add in the upload page an additional comment besides each upload field so that the user can enter a comment for each file uploaded.
But in the upload session I could get the file name (this is used to automatically generate the comment "Uploaded by %user%) but I don't know how to get the comment!
Title: Re: Comments: name of user that uploads the file
Post by: rejetto on February 12, 2009, 07:57:09 PM
it took a while.

Code: [Select]
[special:begin]
{.comment| {.count|upload.} .}

[upload-file]
<input name='fileupload%idx%' size='50' type='file'> comment <input name='filecomment%idx%' size='50'><br>

[upload-success]
<li><a href='%item-url%'>%item-name%</a>: <b>{.!OK.}</b> --- %item-size%  ({.!Speed.} %speed% KB/s)
{.set|t|{.postvar|filecomment{.count|upload.}.}.}
{.if| %user% | {: {.set|t| uploaded by %user%. {.^t.} .} :} /if.}
{.if| {.^t.} |{: {.append| %folder-resource%\hfs.comments.txt |{.filename|%item-resource%.}={.^t.}
/append.} :}/if.}

consider that you may already have a [special:begin] and in such case you should append the content, or otherwise it would overwrite your own.
Title: Re: Comments: name of user that uploads the file
Post by: luca69 on February 13, 2009, 08:11:03 AM
 -- EDIT: now it works !! But I have one questions:

I did not get the "special:begin" stuff ?!?!It looks like it is only a comment, but it has effects on the counter of uploads ?!?
Title: Re: Comments: name of user that uploads the file
Post by: rejetto on February 13, 2009, 10:09:37 AM
it is actually undocumented yet.

it's just executed before the rest.

we needed it because the main part of the template is built after the list. this may change in the future.
Title: Re: Comments: name of user that uploads the file
Post by: luca69 on February 13, 2009, 12:21:54 PM
it is actually undocumented yet.

it's just executed before the rest.

we needed it because the main part of the template is built after the list. this may change in the future.
:o :o :o :o
Please if you change it in future, remember this topic and manifest it in the release notes so that my template keep working with latest HFS version  ;)
Title: Re: Comments: name of user that uploads the file
Post by: rejetto on February 13, 2009, 07:10:33 PM
if i come to ever change it, [special:begin] will be supported for 1-2 years more ;)
Title: Re: Comments: name of user that uploads the file
Post by: SilentPliz on February 14, 2009, 01:15:32 AM
Do not forget the accented characters.

For poor little "Frenchies" ;) that we are, by eg.  :-\ ééé :'( ààà :D ùùù :o

It's better this way:

[special:begin]
{.comment| {.count|upload.} .}

[upload-file]
<input name='fileupload%idx%' size='50' type='file'> comment <input name='filecomment%idx%' size='50'><br>

[upload-success]
<li><a href='%item-url%'>%item-name%</a>: <b>{.!OK.}</b> --- %item-size%  ({.!Speed.} %speed% KB/s)
{.set|t|{.postvar|filecomment{.count|upload.}.}.}
{.if| %user% | {: {.set|t| uploaded by %user%. {.^t.} .} :} /if.}
{.if| {.^t.} |{: {.append| %folder-resource%\hfs.comments.txt |{.filename|%item-resource%.}={.convert|utf-8|ansi|{.^t.}.}
/append.} :}/if.}


Edit:
I remember, now, that there are also accented characters in Italian language.  ;)
Title: Re: Comments: name of user that uploads the file
Post by: rejetto on February 15, 2009, 01:25:13 PM
mmm...yes...hfs is actually considering comment files as ansi, always. It has actually no way to know a file is utf-8, because most files lack of the "flag" (a header, actually).

a workaround is to keep comment file as utf-8, and change the template around %item-comment% (and maybe also %folder-comment%) with a {.convert|utf-8|ansi|%...%.}

more: i think we should slowly stop using hfs.comments.txt file format. it was introduced before the descript.ion, that is a de-facto standard, and it has some limits.
limit of descript.ion is that AFAIK it is ansi and not utf-8.
(of course HFS may decide to write utf-8 comments in it, but i don't know how other softwares would behave)
anyone knows about it?
Title: Re: Comments: name of user that uploads the file
Post by: luca69 on February 16, 2009, 12:55:14 PM
Do not forget the accented characters.

For poor little "Frenchies" ;) that we are, by eg.  :-\ ééé :'( ààà :D ùùù :o

It's better this way:

[special:begin]
{.comment| {.count|upload.} .}

[upload-file]
<input name='fileupload%idx%' size='50' type='file'> comment <input name='filecomment%idx%' size='50'><br>

[upload-success]
<li><a href='%item-url%'>%item-name%</a>: <b>{.!OK.}</b> --- %item-size%  ({.!Speed.} %speed% KB/s)
{.set|t|{.postvar|filecomment{.count|upload.}.}.}
{.if| %user% | {: {.set|t| uploaded by %user%. {.^t.} .} :} /if.}
{.if| {.^t.} |{: {.append| %folder-resource%\hfs.comments.txt |{.filename|%item-resource%.}={.convert|utf-8|ansi|{.^t.}.}
/append.} :}/if.}


Edit:
I remember, now, that there are also accented characters in Italian language.  ;)

Thanks for the info! I updated my code.