Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Extract text to html href (a bit long)

Reply
Thread Tools

Extract text to html href (a bit long)

 
 
text news
Guest
Posts: n/a
 
      08-22-2003
Sorry if this is a bit off base but I figured that this is about the only
place where I might find someone with the programing skills to help me out.

I am trying to marry together two pieces of software so that I end up with a
cheap and functional shopping cart.
(Don't laugh..... no abuse necessary!!)

My problem..... I have 500 photos to sell via the internet.

One piece of software "Easy Thumbnail Creator" generates the necessary pages
of photographs and some custom html to create an effective and simple
database of photographs that I can post to the internet.
The second piece of software "Mals E-Commerce" gives me the ability to add a
shopping cart facility to those pages of photographs.

Easy Thumbnail Creator uses a variable "#etcShortTitle" to turn the filename
of each photo into a unique descriptive name to identify each of the
photographs, so that variable could be "photo1", "photo2", "photo3" etc.,
matching their filenames "photo1.jpg" etc.

If there are, for example, 5 photographs to upload to the internet. Easy
Thumbnail Creator will automatically create an index sheet of thumbnails of
those photographs with hypertext links to "photo1.htm", "photo2.htm" .....
"photo5.htm". So far so good, it really works well.

Now to link to Mals E-Commerce also needs a bit of html.
A typical link is:

href="http://www.aitsafe.com/cf/add.cfm?userid=6226543&product=photo1&price=
4.95"

The tricky bit is where it says "product=photo1" as that is the identifier
that I need to include.

In an ideal world I would be able to use the variable "#etcShortTitle"
(which represents the "product") used in Easy Thumbnail Creator to directly
insert the appropriate product identifier in the href line needed for Mals
E-Commerce, but that is not possible, although if it was it would look a bit
like:

href="http://www.aitsafe.com/cf/add.cfm?userid=6226543&product="#etcShortTit
le"&price=4.95"


One solution that might work (this is where you roll around the floor
laughing!!!!) is a sort of search and replace.

I could use Easy Thumbnail Creator to generate all the html pages and
include the same line in each page:

href="http://www.aitsafe.com/cf/add.cfm?userid=6226543&product=xxxxx&price=4
..95"

Note "product=xxxxx", I could do a simple text search and replace on "xxxxx"
but my problem is that the replace text would be different for every page of
html. I need to somehow "read" the piece of text from the top of the page.

Within Easy Thumbnail Creator I could write the html so that in a fixed
position, say the very first word of the page, it puts the unique product
name, say "photo1" for example.
I could then run a piece of software (this is where you guys come in) that
would open the first page of html, copy the first word "photo1" search for
"xxxxx" and replace it with "photo1". Then open the next page of html and
repeat in loop until all pages have been modified. A simple text based
search and replace but one that reads the "replace" word from a fixed
position on the page.

Did this make any sense?
Can anyone help?
There is quite a bit of software that can do multi file search and replace
but I have not found anything that can use a string of characters that it
reads from the start of a text file as the replace string. Oh and the
numbers may not be consecutive, they may jump "photo1", "photo3",
"photo127", hence the need to read the string from the text.

Oh to be 20 years younger and have a brain........

Thanks for reading this far

Best wishes from Les


 
Reply With Quote
 
 
 
 
Toddy Marx
Guest
Posts: n/a
 
      08-23-2003
text news wrote:
> Sorry if this is a bit off base


Yeah - my ideas for your problem would probably fit more into
news://comp.unix.shell.

> ...
> Within Easy Thumbnail Creator I could write the html so that in a fixed
> position, say the very first word of the page, it puts the unique product
> name, say "photo1" for example.
> I could then run a piece of software (this is where you guys come in) that
> would open the first page of html, copy the first word "photo1" search for
> "xxxxx" and replace it with "photo1". Then open the next page of html and
> repeat in loop until all pages have been modified. A simple text based
> search and replace but one that reads the "replace" word from a fixed
> position on the page.


If you have the chance to work on a Unix system the following script
might do the task. You would need to replace "./srcdir" with the path
of the directory where you placed the "Easy Thumbnail Creator" files.
The files produced by "Easy Thumbnail Creator" should have no
extension.


#!/bin/sh
#
# Loop over all files in $DIR and
# get 1st line of file,
# replace $PATTERN with content of 1st line,
# save file with new extension.
#

# directory with files
DIR=./srcdir

# pattern that is to be replaced
PATTERN=\#etcShortTitle

# extension of new files
EXTENSION=html

for src in $DIR/*; do
image=`less $src | head -1`
sed s/$PATTERN/$image/ $src > temp
mv temp $src.$EXTENSION
done



Hope this hepls!

~Toddy

--
Toddy Marx (email contains no z)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the point of having 16 bit colour if a computer monitor can only display 8 bit colour? How do you edit 16 bit colour when you can only see 8 bit? Scotius Digital Photography 6 07-13-2010 03:33 AM
setAttribute("href) - linkObj.href= returning text node in IE David Javascript 1 12-06-2006 02:39 AM
href="javascript:func()" vs href="#" onclick="javascript:func()" CRON HTML 24 06-20-2006 08:05 PM
64 bit - Windows Liberty 64bit, Windows Limited Edition 64 Bit, Microsoft SQL Server 2000 Developer Edition 64 Bit, IBM DB2 64 bit - new ! vvcd Computer Support 0 09-17-2004 08:15 PM
64 bit - Windows Liberty 64bit, Windows Limited Edition 64 Bit,Microsoft SQL Server 2000 Developer Edition 64 Bit, IBM DB2 64 bit - new! Ionizer Computer Support 1 01-01-2004 07:27 PM



Advertisments