Extract text to html href (a bit long)

Discussion in 'Java' started by text news, Aug 22, 2003.

  1. text news

    text news Guest

    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
    text news, Aug 22, 2003
    #1
    1. Advertising

  2. text news

    Toddy Marx Guest

    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)
    Toddy Marx, Aug 23, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    674
    Eric Sosman
    Jul 8, 2003
  2. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,186
    Peter Shaggy Haywood
    Sep 20, 2005
  3. Mathieu Dutour

    long long and long

    Mathieu Dutour, Jul 17, 2007, in forum: C Programming
    Replies:
    4
    Views:
    473
    santosh
    Jul 24, 2007
  4. Bart C

    Use of Long and Long Long

    Bart C, Jan 9, 2008, in forum: C Programming
    Replies:
    27
    Views:
    796
    Peter Nilsson
    Jan 15, 2008
  5. David
    Replies:
    1
    Views:
    311
    David
    Dec 6, 2006
Loading...

Share This Page