rejetto forum

New flag

Kremlin · 15 · 5191

0 Members and 1 Guest are viewing this topic.

Offline Kremlin

  • Tireless poster
  • ****
    • Posts: 137
    • View Profile
It's not really a bug, at least that's what i think, but shouldn't the new flag reach from the file till the root? For example let's say i place a new file, example.mp3, in ../Music/album/a/example.mp3, the new flag only affects the file "example.mp3" and the folder "a" when it would make more sense to reach the folder "Music" since that's the folder you see when you open http://localhost/. Can you please clarify if what i've just said makes sense or am i missing something?


Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
I'm sure you have your reason thinking the new flag should go upwards to the folders on higher level.

But..  this will in most cases be useless, as normally all, except lowest-level folders,  would be flagged as new!

So mi suggestion, if you need to announce the new files to your users, add with a macro date and filename to special file and show his contents in some way to the users when they connect. You can clear older entries with an editor, or you can do it with a macro in hfs.events.
your computer has no brain - use your own !


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13310
    • View Profile
there's no quick way for HFS to know that "at any depth" a file has changed.
so, it's like it cannot be done. sorry.


Offline adi4ascu

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
I have the same problem and I need this feature. Can it be done?
I have to flag the file and all the folders up to root.
I have too many folders and I need to know that something new has been uploaded.
The users have to know what files are new.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13310
    • View Profile
read my last reply.
i don't know a real solution.
the easy one can take minutes, every time you open the page. not feasible.
would anyone be able to suggest...


Offline r][m

  • Tireless poster
  • ****
    • Posts: 347
    • View Profile
Could it be a solution if there was a file list, or even better
a folder/page that only lists files flagged as "new".
Might be a problem with listing the new files the user
does not have access to?
Its something I'd like to have, but have had no luck creating it.


Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
for those who need to show NEW UPLOADS to their users, i propose a workaround that allows to show a list of  files uploaded in the last xx days. For this you need only two short pieces of macros.

The first macro must go in the section upload-success:
Quote
[upload-success]
....
{.if| %user% |{:
{.append| %folder-resource%\{.filename|%item-resource%.}.comment |uploaded by %user% /append.}
{.set|fnam|newuploads{.cut|1|5|%now%.}.lst.}
{.append|{.^fnam.}|<tr><td><a href ="%encoded-folder%\{.filename|%item-resource%.}"> %item-name% </a></td><td>%user%</td><td>%timestamp%</td></tr>.}

:}/if.}
this creates a a daily file named: newuploads(numberof the day).lst

Te second macro is a piece of code for which you can create a section to include in your template, which you could reach with a link. You may even elaborate it to allow the user to input for how many days befor he wants to see the news (1..10 days). I have set it fixed to 4 days in the example. You can modify this table with style or css elements to show the list accordingly to your preferences.
Quote
[newuploads]
{.set|day|{.cut|1|5|%now%.}.}
{.set|start|{.sub|{.^day.}|4.}.}
<table>
<th><td>filename</td><td>uploaded by</td><td>upload date</td></th>
{.for|ii|{.^start.}|{.^day.}|{:
   {.load|newuploads{.^ii.}.lst.}:}
   .}
</table>

The users can download directly form this table the files, also it is not possible to create a archive.tar. Another limit is that this list will only show files added with uploads, not what you add on your system directly by copying or moving to a folder.

Hope this solution can help someone :)
« Last Edit: February 25, 2009, 12:48:11 AM by bacter »
your computer has no brain - use your own !


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13310
    • View Profile
Could it be a solution if there was a file list, or even better a folder/page that only lists files flagged as "new".

"if there was" ;)
it isn't there, so HFS must go through the whole file system searching for them, and it can take 5-10 minutes.


I suggest you this experimental (UNTESTED) solution

1. make the template so that, when a certain parameter is specified, it will show only the new files

in the default template this would be like
Code: [Select]
[file]
{.if|{.?onlynew.}{.get|is new.}|   ...all the rest...  /if.}
[folder]
{.if|{.?onlynew.}{.get|is new.}|   ...all the rest...  /if.}

2. schedule a call to:
wget -O C:\hfs\news.html http://localhost/?recursive&onlynew



...not that hard ;)
if you are not able to do any of these steps, just ask.
and when the scheduling feature of hfs will be ready it will be even easier.
« Last Edit: February 24, 2009, 11:38:59 AM by rejetto »


Offline Kremlin

  • Tireless poster
  • ****
    • Posts: 137
    • View Profile
Happy to see such activity from the forum  :D, meanwhile i'll try and think of someway too approach the problem also.

ps. rejetto what are the main difficulties that you encounter to make this feauture possible?

EDIT. As my server has as primary function to host TV Shows, Movies, etc.. I end up with tons of folders and files (3TB), and the solution i found to state that new files have been added was to create a news section in which I post an entry every time I upload. Complementary to that would be this 'new flag' system, but as it seems, it only issues a new flag to the file and the folder in which it's placed. What i'm getting at is asking if the problem with HFS is finding a way to flag the file path till the root? If so can't it be possible to break apart the url itself and sort that way what folders should indeed be flagged?
« Last Edit: February 24, 2009, 03:23:50 PM by Kremlin »


Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
1. To Kremlin:

with the macros in my above post, you just create the list you typed till now in your news section: simply paste the code from [newuploads] section in your news section.

2. Every attempt to search the tree downwards to find new files every time a page is created with the goal to flag the upper folders with new, will be a heavy load to the server.

3. Another solution that is faster works as follows:

    - use a hidden file (like the actually uses comment.files) with each folder. I give it here in the example the ending .folderstat. His content should be the value %now% ahen written.
    - in the [upload-success]- section, use the %encoded-folder% value. Cut as many times as needed the last element of the path (.set|tpath| .....}, and use the rest to update the hidden file with {.save|{.^tpath.}.folderstat|%now%.}
    - in the [folder] section add a macro {.set|lastadded|{.load|%item-url%.folderstat.}.} and use the lastadded value and %now% to decide if you want to show the new-flag: {.if|>|{.sub|{.^lastadded.}|%now%.}|4.}|{:%new%:.}.} (for flagging 4 days).

   This is not tested, but will be much faster than any recursive procedure with every page-build.
your computer has no brain - use your own !


Offline adi4ascu

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
hi bacter,

i'v tried your solution for showing the new uploads with macros, but i'm not shure what i shoud do to list the [newuploads] section on the first page of my server. Can you please help me

p.s. when i upload a new file the server creates a file named: newuploads39869.lst

Thanks


Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
to adi4ascu:

it depends a lot of the template you use how and where you place the code.

I use a welcomepage with some info and login. Once the user is logged in, this same page can show different info and has no files listed, there is only a link to enter into the fileserver. I can add there the content of the section [newuploads] (without the header) to display the list, that will show the content of the daily files as you already have one created.

If you use a template that shows files on the first page like the default template, you can add there where the login and upload options are, a new button with a link <a href="~newuploads"> <img src="/~img10"> New files</a>. Then you have to complete the section [newuploads] with the normal html header stuff:
<html>
<head>
<meta....>
<link...>
</head>
<body>
and so on, as you can see it in other sections (see [error-page],[upload]) that are directly invoked. and at the end of your page you must close with </body></html>

See how is your template to decide which way to start.
your computer has no brain - use your own !


Offline adi4ascu

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
thanks, solved.
great job
« Last Edit: February 26, 2009, 05:10:59 PM by adi4ascu »


Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
The above solution works ok if you do not have different usergroups, as everybody who logs in can see ALL uploads done.

This can be avoided saving the list without html tags as a .csv file (Coma Separated Values) adding the usergroup the uploader belongs to. In the presentation part of the list you have to load the files in a variable, in this variable then you remove the lines whose usergroup does not belong to the user that is currently logged in, after that you create the table you want to show. This way users do not see uploads to which they don't have access and there will be no errors if they would try to download such a file to which they do not have access.
your computer has no brain - use your own !


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13310
    • View Profile
no one is interested in my solution :(


less time spent on the forum ;D