export to html gallery

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

export to html gallery

Stefano Stabellini

Hi all,
I have just bought my first digital camera so I started using digikam.
First I want to say that digikam is really impressive both as simplicity
and power, certainly one of the best kde desktop apps ever.
I really want to thank all the developers for this.
Since I have a little website I tried exporting my galleries to HTML,
and again digikam did the job very well.
Too bad that the second time I wanted to export a gallery I had to
export also the first one because if I didn't the index.html was
overwritten with only the new gallery.
Not a problem with 2-3 galleries but try to image what would happen with
50-60 galleries...
To overcome this problem I wrote a little python script that take the
main html galleries directory and a temporary directory with only the
last published gallery and merge them.
It took me only a couple of hours and I'm really new to python, so I
guess that for you would be really easy to add this feature.
Hoping to be a little helpful I attached my script to this mail.
Again thanks for the good job,

Stefano Stabellini

--

stefano[AT]stabellini.net - http://www.stabellini.net

“Success is not final, failure is not fatal:
it is the courage to continue that counts.”
          Winston Churchill

#!/usr/bin/python

import sys
import shutil
import os

if len(sys.argv) <= 2 :
    print """
        Usage: digikammerger.py <gallerydir> <newgallerydir>
    """
    sys.exit(1)

gallery = sys.argv[1]
newgallery = sys.argv[2]

#update gallery.xml
shutil.move(gallery + "/gallery.xml", gallery + "/gallery.old")
f3 = open (gallery + "/gallery.xml", 'w');
f2 = open(gallery + "/gallery.old", 'r')
for i in f2 :
    if i.find("</collections>") == -1:
        f3.write (i)
    else :
        break
f2.close()
f1 = open(newgallery + "/gallery.xml", 'r')
f1.readline()
f1.readline()
for i in f1 :
    f3.write (i)
f1.close()
f3.close()
os.remove (gallery + "/gallery.old")


#move the directory
filelist = os.listdir (newgallery)
for i in filelist :
    if os.path.isdir (newgallery+"/"+i) and i != "matrix" :
        shutil.move (newgallery+"/"+i, gallery+"/"+i)
        galleryname = i
        break

#create galleryname.html
f = open (newgallery + "/index.html", "r")
for i in f :
    if i.find("<h1>") != -1 :
        gallerytitle = i[4:-6]
    else :
        pos = i.find("<img")
        if pos != -1 :
            img = i[pos:i.find(">", pos)+1]
            break
f.close()
f1 = open (newgallery + "/index.html", "r")
f2 = open (gallery + "/" + galleryname.replace(", ", "_").lower() + ".html", "w")
for i in f1 :
    if i.find("<h1>") != -1 :
        f2.write("<h1><a href=\"index.html\">Collection List</a> » " + gallerytitle + "</h1>")
    else :
        f2.write(i)
f1.close()
f2.close()

#update index.html
shutil.move(gallery + "/index.html", gallery + "/index.old")
f1 = open (gallery + "/index.old", "r")
f2 = open (gallery + "/index.html", "w")
for i in f1 :
    if i.find("</ul></div>") != -1 :
        f2.write ("<li><a href=\"" + galleryname.replace(", ", "_").lower() + ".html\">" + img + "<br>" + gallerytitle + "</a></li>")
    else :
        f2.write (i)
f1.close()
f2.close()
os.remove (gallery + "/index.old")
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: export to html gallery

Gilles Caulier-2
On Thursday 14 December 2006 03:30, Stefano Stabellini wrote:
> Hi all,
> I have just bought my first digital camera so I started using digikam.
> First I want to say that digikam is really impressive both as simplicity
> and power, certainly one of the best kde desktop apps ever.
> I really want to thank all the developers for this.

Thanks. Witch version you use exactly ?

> Since I have a little website I tried exporting my galleries to HTML,
> and again digikam did the job very well.
> Too bad that the second time I wanted to export a gallery I had to
> export also the first one because if I didn't the index.html was
> overwritten with only the new gallery.
> Not a problem with 2-3 galleries but try to image what would happen with
> 50-60 galleries...
> To overcome this problem I wrote a little python script that take the
> main html galleries directory and a temporary directory with only the
> last published gallery and merge them.
> It took me only a couple of hours and I'm really new to python, so I
> guess that for you would be really easy to add this feature.
> Hoping to be a little helpful I attached my script to this mail.

Well, if you want to contact developpers, this is not the right way to post
this script or reporting a problem. I don't know exactly witch tool you have
used :

- Gallery Export
- HTML Export

... Both are kipi-plugins and are developped outside digiKam core
(http://www.kipi-plugins.org). Kipi developpers are in others mailling list :
[hidden email]

If your goal with this mail is to contact developpers, please post your
message in this ML. Thanks in advance.

Gilles
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: export to html gallery

Stefano Stabellini
Gilles Caulier wrote:
> On Thursday 14 December 2006 03:30, Stefano Stabellini wrote:
>> Hi all,
>> I have just bought my first digital camera so I started using digikam.
>> First I want to say that digikam is really impressive both as simplicity
>> and power, certainly one of the best kde desktop apps ever.
>> I really want to thank all the developers for this.
>
> Thanks. Witch version you use exactly ?

0.8.2 (kde 3.5.5) on kubuntu edgy

>> Since I have a little website I tried exporting my galleries to HTML,
>> and again digikam did the job very well.
>> Too bad that the second time I wanted to export a gallery I had to
>> export also the first one because if I didn't the index.html was
>> overwritten with only the new gallery.
>> Not a problem with 2-3 galleries but try to image what would happen with
>> 50-60 galleries...
>> To overcome this problem I wrote a little python script that take the
>> main html galleries directory and a temporary directory with only the
>> last published gallery and merge them.
>> It took me only a couple of hours and I'm really new to python, so I
>> guess that for you would be really easy to add this feature.
>> Hoping to be a little helpful I attached my script to this mail.
>
> Well, if you want to contact developpers, this is not the right way to post
> this script or reporting a problem. I don't know exactly witch tool you have
> used :
>
> - Gallery Export
> - HTML Export

I was talking about html export

> ... Both are kipi-plugins and are developped outside digiKam core
> (http://www.kipi-plugins.org). Kipi developpers are in others mailling list :
> [hidden email]
>
> If your goal with this mail is to contact developpers, please post your
> message in this ML. Thanks in advance.
>


thank you, I'll post another message on that mailing list
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users