|
Prev: FAQ 8.14 How do I modify the shadow password file on a Unix system?
Next: TieRegistry with IPConfig
From: Rich Grise on 1 Apr 2008 21:05 Apologies to Perl purists - comp.infosystems.www.authoring.cgi doesn't work on my newsreader, and this is a CGI question: What I want to do is, I've got a large collection of image files: $ wc gallery-pix 37448 62619 3218967 gallery-pix and what I'd like to do is look at each of the 37488 image files on some kind of page, with buttons like "Keep", "Skip", and "Quit", so I can page through all of these images, which are strewn all over the Samba server, and decide which ones might look good on the website. So, is it possible to do something like (in pseudocode): for each $line in <file> { show webpage with <img> tag, and the three buttons; get button response, decide what to do with file; if button == "Quit", save place in source file; next; or so? Thanks, Rich
From: David Filmer on 1 Apr 2008 21:41 Rich Grise wrote: > for each $line in <file> { This is gonna be your problem. CGI is stateless. Each time you hit one of the submit buttons you will re-invoke the program, and the new invocation knows nothing about the state of the previous invocation. If you attempted something like you wrote then you would keep showing the first item over and over again, because it would start at the beginning of the file each time you invoked the program. There are several things you can do to get around this issue. My preference is to use a database instead of a file, and run my CGI under a mod_perl webserver which is smart enough to cache the database handle. But maybe that's overkill for what you want to do. If you are willing to pay the price of opening up your flatfile each time you invoke the program, you could pass the current (or next) line number as a hidden() parameter. Thus the program knows which line of the file to process next (I would recommend tying the file to an array so the line number simply becomes the array subscript).
From: xhoster on 2 Apr 2008 00:07 Rich Grise <rich(a)example.net> wrote: > Apologies to Perl purists - comp.infosystems.www.authoring.cgi doesn't > work on my newsreader, and this is a CGI question: > > What I want to do is, I've got a large collection of image files: > $ wc gallery-pix > 37448 62619 3218967 gallery-pix > > and what I'd like to do is look at each of the 37488 image files on > some kind of page, with buttons like "Keep", "Skip", and "Quit", > so I can page through all of these images, which are strewn all > over the Samba server, and decide which ones might look good on > the website. > > So, is it possible to do something like (in pseudocode): > > for each $line in <file> { In CGI, your program won't survive for the loop to iterate. Unless you are making one page with all 37448 files on it. > show webpage with <img> tag, and the three buttons; > get button response, decide what to do with file; What would you do with the file in each case? > if button == "Quit", save place in source file; > next; Make one directory with all the files (or with a symbolic links for each file). Each time the program is invoked, take the first entry in the directory and display it. Based on the response, either move it to the accept directory or the reject directory (or move it to accept vs delete it, whatever.) Since the file is no longer there, place is inherently saved. Quit doesn't have to do anything, nor even have to exist--closing the browser without responding is a form of quiting. Or use a database. Xho -- -------------------- http://NewsReader.Com/ -------------------- The costs of publication of this article were defrayed in part by the payment of page charges. This article must therefore be hereby marked advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate this fact.
From: RedGrittyBrick on 2 Apr 2008 05:59 Rich Grise wrote: > Apologies to Perl purists - comp.infosystems.www.authoring.cgi doesn't > work on my newsreader, and this is a CGI question: > > What I want to do is, I've got a large collection of image files: > $ wc gallery-pix > 37448 62619 3218967 gallery-pix > > and what I'd like to do is look at each of the 37488 image files on > some kind of page, with buttons like "Keep", "Skip", and "Quit", > so I can page through all of these images, which are strewn all > over the Samba server, and decide which ones might look good on > the website. > > So, is it possible to do something like (in pseudocode): > > for each $line in <file> { > show webpage with <img> tag, and the three buttons; > get button response, decide what to do with file; > if button == "Quit", save place in source file; > next; > > or so? > Surely, looking at 37448 separate images one by one and making subjective judgements about them is going to take a human a long long time. If you can make a judgement in a second then it would take over ten hours without a break to view all of them. This kind of monotonous task would drive me crazy after a few hundred images. I'd expect there are lots of similar images and that they may not be naturally grouped together - which makes selecting the best of a kind impossible, you're bound to later encounter a "better" image than one you'd selected to "keep" yesterday or a week ago. Which means more passes through the "keep" collection. If I had to do it, I'd first categorise the images, then display thumbnails for each category and pick ones to keep from each category. Better to pay a graphics artist to produce a new consistent set for a website? -- RGB
From: Rich Grise on 2 Apr 2008 15:53 On Wed, 02 Apr 2008 04:07:42 +0000, xhoster wrote: > Rich Grise <rich(a)example.net> wrote: >> Apologies to Perl purists - comp.infosystems.www.authoring.cgi doesn't >> work on my newsreader, and this is a CGI question: >> >> What I want to do is, I've got a large collection of image files: >> $ wc gallery-pix >> 37448 62619 3218967 gallery-pix >> >> and what I'd like to do is look at each of the 37488 image files on >> some kind of page, with buttons like "Keep", "Skip", and "Quit", >> so I can page through all of these images, which are strewn all >> over the Samba server, and decide which ones might look good on >> the website. >> >> So, is it possible to do something like (in pseudocode): >> >> for each $line in <file> { > > In CGI, your program won't survive for the loop to iterate. Unless > you are making one page with all 37448 files on it. > >> show webpage with <img> tag, and the three buttons; >> get button response, decide what to do with file; > > What would you do with the file in each case? > >> if button == "Quit", save place in source file; >> next; > > Make one directory with all the files (or with a symbolic links for each > file). Each time the program is invoked, take the first entry in the > directory and display it. Based on the response, either move it to the > accept directory or the reject directory (or move it to accept vs delete > it, whatever.) Since the file is no longer there, place is inherently > saved. Quit doesn't have to do anything, nor even have to exist--closing > the browser without responding is a form of quiting. Thanks - I really like this answer - I hadn't even consider loading up a directory with symlinks. I'm going to try this next, as a way to avoid slurping the whole file. So, anybody got a quick and dirty script that will make 38,000 symlinks? ;-) I'm not too worried about how long it will take - I'm doing this in my "spare" time, and the boss doesn't bother me much as long as I look busy. :-) Thanks! Rich
|
Next
|
Last
Pages: 1 2 3 4 Prev: FAQ 8.14 How do I modify the shadow password file on a Unix system? Next: TieRegistry with IPConfig |