mirror of
https://github.com/jlengrand/IvolutionWebsite.git
synced 2026-03-10 08:31:18 +00:00
Adds a sitemap to the website.
This commit is contained in:
BIN
Website/Ivolution_doc.zip
Normal file
BIN
Website/Ivolution_doc.zip
Normal file
Binary file not shown.
@@ -4,7 +4,7 @@ Slug: About
|
|||||||
|
|
||||||
### Other informations
|
### Other informations
|
||||||
|
|
||||||
__Ivolution__ was created as a pet project, to help a friend currently [travelling around the world](http://ungrandtour.blogspot.nl/) (French inside).
|
__Ivolution__ was created as a pet project, to help a friend currently [travelling around the world](http://ungrandtour.blogspot.nl/) (Warning, french inside).
|
||||||
It is still in early development, but pretty much already achieves what it was created for !
|
It is still in early development, but pretty much already achieves what it was created for !
|
||||||
|
|
||||||
### License
|
### License
|
||||||
@@ -48,13 +48,13 @@ I never experienced any problem using Ivolution (nor all my users), but you are
|
|||||||
|
|
||||||
To create this project, I used a lot of different tools that are going to be listed here.
|
To create this project, I used a lot of different tools that are going to be listed here.
|
||||||
|
|
||||||
- The whole project is written in Python (2.7). It allows rapid prototyping, has a, Python and huge amount of libraries available and also has the advantage to be portable (Windows, Linux, Web development, . . . ). I know I won´t be limited in the future by using Python.
|
- The whole project is written in [Python](http://www.google.nl/url?sa=t&rct=j&q=python&source=web&cd=1&cad=rja&ved=0CCUQFjAA&url=http%3A%2F%2Fwww.python.org%2F&ei=g61TUJeiJ4nK0QXjwYCgBw&usg=AFQjCNG7frXlIQC6rpM3VV6f5i7nq5VeIg) (2.7). It allows rapid prototyping, has a, Python and huge amount of libraries available and also has the advantage to be portable (Windows, Linux, Web development, . . . ). I know I won´t be limited in the future by using Python.
|
||||||
- All the image processing is performed using the excellent OpenCV library, through its Python bindings. If you have to develop image processing algorithms quickly and efficiently, Python and OpenCV are the tools you want. I used the OpenCV 2.4 version, to be compatible with the current package of Ubuntu.
|
- All the image processing is performed using the excellent [OpenCV](http://www.google.nl/url?sa=t&rct=j&q=opencv&source=web&cd=8&cad=rja&ved=0CEkQFjAH&url=http%3A%2F%2Fopencv.org%2F&ei=ja1TUMzYFaX80QX964HYCQ&usg=AFQjCNGUr-UTYvy3hRjaFyy2oCg43JU9Vw) library, through its Python bindings. If you have to develop image processing algorithms quickly and efficiently, Python and OpenCV are the tools you want. I used the OpenCV 2.4 version, to be compatible with the current package of Ubuntu.
|
||||||
- I started developing the GUI in GTK+ ([here is a picture of what it looked like](https://dl.dropbox.com/u/4286043/ivolution_gtk.png)), but finally switched to WxPython. GTK+ is nice for Linux environments but made my software OS dependant, which I didn´t want.
|
- I started developing the GUI in [GTK+](http://www.google.nl/url?sa=t&rct=j&q=pygtk&source=web&cd=1&cad=rja&ved=0CCMQFjAA&url=http%3A%2F%2Fpygtk.org%2F&ei=k61TUJGQFKik0AXpv4GABg&usg=AFQjCNECVx76WbL-0AoZB9sMwXU5lYNQuQ) ([here is a picture of what it looked like](https://dl.dropbox.com/u/4286043/ivolution_gtk.png)), but finally switched to [WxPython](http://www.google.nl/url?sa=t&rct=j&q=wxpython&source=web&cd=1&cad=rja&ved=0CCMQFjAA&url=http%3A%2F%2Fwxpython.org%2F&ei=mq1TUP29EaLA0QWY64C4Bw&usg=AFQjCNE8M7EcUd4oQf5NyzG9qiWL15zPhQ). GTK+ is nice for Linux environments but made my software OS dependant, which I didn´t want.
|
||||||
- I used py2exe combined to NSIS in order to create proper Windows executables. Both are simple to use, even though you may something have to dig into 3 years old forum posts to find the solution to your problems. I´d definitely use them again if needed in future projects.
|
- I used [py2exe](http://www.py2exe.org/) combined to [NSIS](http://nsis.sourceforge.net/Main_Page) in order to create proper Windows executables. Both are simple to use, even though you may something have to dig into 3 years old forum posts to find the solution to your problems. I´d definitely use them again if needed in future projects.
|
||||||
- In order to automate everything I used ant. I love ant because you can do pretty much everything you want with it, from compiling to move folder back and forth or even prepare coffee.
|
- In order to automate everything I used [ant](http://ant.apache.org/). I love ant because you can do pretty much everything you want with it, from compiling to move folder back and forth or even prepare coffee.
|
||||||
Coming from the linux world, ant is a must if you want to save time.
|
Coming from the linux world, ant is a must if you want to save time.
|
||||||
- Finally, this whole website was created using Pelican. I was searching for an Octopress equivalent, but written in Python.
|
- Finally, this whole website was created using [Pelican](http://docs.getpelican.com/en/latest/index.html). I was searching for an Octopress equivalent, but written in Python.
|
||||||
I found Pelican and stick with it since them. The documentation is really complete and you can start working in minutes. Plus it was created by a french man!
|
I found Pelican and stick with it since them. The documentation is really complete and you can start working in minutes. Plus it was created by a french man!
|
||||||
|
|
||||||
That´s all for now folks. If you have other questions, just ask ;)
|
That´s all for now folks. If you have other questions, just ask ;)
|
||||||
|
|||||||
@@ -6,21 +6,19 @@ Slug: Downloads
|
|||||||
|
|
||||||
Here is what you need to install Ivolution :
|
Here is what you need to install Ivolution :
|
||||||
|
|
||||||
- For __Windows__ users, the last executable
|
- For __Windows__ users, [the last executable](http://sourceforge.net/projects/ivolutioner/files/current/Ivolution_0.6.1.exe/download)
|
||||||
- For __Linux and Mac__ users, the source package
|
- For __Linux and Mac__ users, [the source package](http://sourceforge.net/projects/ivolutioner/files/current/Ivolution-0.6.zip/download)
|
||||||
|
|
||||||
- Complete source code of the last version (updated each time I commit)
|
- [Complete source code of the last version](https://github.com/jlengrand/Ivolution/zipball/master) (updated each time I commit)
|
||||||
|
|
||||||
Older versions are also available here:
|
Older versions are also available [here](https://sourceforge.net/projects/ivolutioner/files/older%20versions/).
|
||||||
|
|
||||||
- Windows
|
|
||||||
- Other
|
|
||||||
|
|
||||||
If you want to always have the last version available, you can also choose to directly clone the git repository of the project
|
If you want to always have the last version available, you can also choose to directly clone the git repository of the project
|
||||||
(and I'll gladly accept your pull requests ! ;))
|
(and I'll gladly accept your pull requests ! ;))
|
||||||
|
|
||||||
:::python
|
:::python
|
||||||
$ git clone .. .
|
$ git clone https://github.com/jlengrand/Ivolution.git
|
||||||
|
|
||||||
|
|
||||||
Simply enter the project and run __./Ivolutioner__ in command line should get you started :).
|
Simply enter the project and run __./Ivolutioner__ in command line should get you started :).
|
||||||
@@ -29,10 +27,8 @@ Simply enter the project and run __./Ivolutioner__ in command line should get yo
|
|||||||
|
|
||||||
Several other ressources are available to download :
|
Several other ressources are available to download :
|
||||||
|
|
||||||
- Current documentation (html)
|
- [Current documentation (html)](http://sourceforge.net/projects/ivolutioner/files/other%20downloads/Ivolution_doc.zip/download)
|
||||||
- Current documentation (pdf)
|
- [pack of samples](http://sourceforge.net/projects/ivolutioner/files/other%20downloads/Ivolution_samples.zip/download), to test the application
|
||||||
|
|
||||||
- pack of samples, to test the application.
|
|
||||||
|
|
||||||
|
|
||||||
If you think something is missing, just let me know by dropping a message to __[ivolution-app@gmail.com](mailto:ivolution-app@gmail.com)__ or [file a request here](https://github.com/jlengrand/Ivolution/issues)
|
If you think something is missing, just let me know by dropping a message to __[ivolution-app@gmail.com](mailto:ivolution-app@gmail.com)__ or [file a request here](https://github.com/jlengrand/Ivolution/issues)
|
||||||
@@ -30,5 +30,5 @@ Here is what the current interface looks like :
|
|||||||
Ivolution currently supports Windows and Linux and was successfully tested on Windows XP, 7 and Ubuntu 12.04.
|
Ivolution currently supports Windows and Linux and was successfully tested on Windows XP, 7 and Ubuntu 12.04.
|
||||||
|
|
||||||
|
|
||||||
Ivolution is currently still in early development, and you may face bugs or feel like critical features are missing.
|
__Ivolution is currently still in early development, and you may face bugs or feel like critical features are missing.__
|
||||||
In this case, just let me know by [sending me a mail](ivolution_app@gmail.com) or by [filing a bug here](https://github.com/jlengrand/FaceMovie/issues?state=open). I'll be glad to help you !
|
__In this case, just let me know by [sending me a mail](ivolution_app@gmail.com) or by [filing a bug here](https://github.com/jlengrand/FaceMovie/issues?state=open). I'll be glad to help you !__
|
||||||
|
|||||||
@@ -30,4 +30,4 @@ This should be changed soon
|
|||||||
|
|
||||||
I have new ideas every day, and there's not enough space here to list them all !
|
I have new ideas every day, and there's not enough space here to list them all !
|
||||||
|
|
||||||
__If you also have ideas, just drop me a mail at ivolution-app@gmail.com and I'll be glad to take your advice in consideration !__
|
__If you also have ideas, just drop me a mail at [ivolution-app@gmail.com](mailto:ivolution-app@gmail.com) and I'll be glad to take your advice in consideration !__
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Please choose below the chapter corresponding to your operating system
|
|||||||
## Windows (XP, Vista, Seven)
|
## Windows (XP, Vista, Seven)
|
||||||
|
|
||||||
|
|
||||||
[Simply download and run the executable](link to installer)(x86).
|
[Simply download and run the executable](http://sourceforge.net/projects/ivolutioner/files/current/Ivolution_0.6.1.exe/download)(x86).
|
||||||
|
|
||||||
Once installed, you should be able to run Ivolution through the icon on the Desktop.
|
Once installed, you should be able to run Ivolution through the icon on the Desktop.
|
||||||
Everything should work out of the box without issue.
|
Everything should work out of the box without issue.
|
||||||
@@ -25,13 +25,13 @@ Ivolution is available for Ubuntu in only a few simple steps.
|
|||||||
First of all, install Ivolution's dependencies. You can simply do this by running the following line in a terminal :
|
First of all, install Ivolution's dependencies. You can simply do this by running the following line in a terminal :
|
||||||
|
|
||||||
:::python
|
:::python
|
||||||
$ apt-get install my super packages TODO
|
$ apt-get install python-opencv python-gi python-numpy python-wxgtk2.8 python-wxtools python-wxversion
|
||||||
|
|
||||||
|
|
||||||
*__Note__ : You'll need administrator's rights to install the packages (usually means using __sudo__).*
|
*__Note__ : You'll need administrator's rights to install the packages (usually means using __sudo__).*
|
||||||
|
|
||||||
|
|
||||||
Then, __[download the last stable packages](../pages/Downloads.html)__ and extract here where you want.
|
Then, __[download the last stable package](http://sourceforge.net/projects/ivolutioner/files/current/Ivolution-0.6.zip/download)__ and extract here where you want.
|
||||||
|
|
||||||
Finally, move to the extracted folder in command line and install the package
|
Finally, move to the extracted folder in command line and install the package
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ Finally, move to the extracted folder in command line and install the package
|
|||||||
__Done !__ You can now start using Ivolution by running the following command in a terminal :
|
__Done !__ You can now start using Ivolution by running the following command in a terminal :
|
||||||
|
|
||||||
:::python
|
:::python
|
||||||
Ivolutioner
|
$ Ivolutioner
|
||||||
|
|
||||||
### Uninstalling the software
|
### Uninstalling the software
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ __Done !__ You can now start using Ivolution by running the following command in
|
|||||||
You can do this by running the following command in a terminal, where *ivolution_file* is your record file.
|
You can do this by running the following command in a terminal, where *ivolution_file* is your record file.
|
||||||
|
|
||||||
:::python
|
:::python
|
||||||
[proper command line to uninstall]
|
$ cat files.txt | xargs rm -rf
|
||||||
|
|
||||||
**WARNING: This command, if not run correctly, may cause damages! Check the record file first.**
|
**WARNING: This command, if not run correctly, may cause damages! Check the record file first.**
|
||||||
|
|
||||||
@@ -66,11 +66,11 @@ For most of all the other Linux distributions, the installation process is simil
|
|||||||
You will have to find the name of the packages for your own distribution, or compile them from source if they don't exist.
|
You will have to find the name of the packages for your own distribution, or compile them from source if they don't exist.
|
||||||
Here is a list of all the elements you'll need in your system to run Ivolution:
|
Here is a list of all the elements you'll need in your system to run Ivolution:
|
||||||
|
|
||||||
- python 2.7 or more
|
- [python 2.7](http://www.python.org/getit/releases/2.7/) or more (2.xx)
|
||||||
- opencv 2.4 or more, and all of its dependencies
|
- [opencv 2.4](http://opencv.org/) (or more), and all of its dependencies
|
||||||
- wxpython and wxwidgets
|
- [wxpython](http://wxpython.org/) and the related [wxwidgets](http://www.wxwidgets.org/)
|
||||||
|
|
||||||
Once all the dependencies are satisfied, you can simply [download](link to Linux package) and install the package using the directions __from the Ubuntu chapter__.
|
Once all the dependencies are satisfied, you can simply [download](http://sourceforge.net/projects/ivolutioner/files/current/Ivolution-0.6.zip/download) and install the package using the directions __from the Ubuntu chapter__.
|
||||||
|
|
||||||
## Mac OS
|
## Mac OS
|
||||||
|
|
||||||
@@ -78,4 +78,4 @@ Up to now, I was not able to create application installer as for Windows.
|
|||||||
__Mac users should for now follow the Linux guide to install Ivolution.__
|
__Mac users should for now follow the Linux guide to install Ivolution.__
|
||||||
|
|
||||||
An installer may be provided in the future.
|
An installer may be provided in the future.
|
||||||
You can also try to create it by yourself, using [py2app](link to py2app) (__and in this case, let me know !__)
|
You can also try to create it by yourself, using [py2app](http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html) (__and in this case, let me know !__)
|
||||||
@@ -18,8 +18,6 @@ The main frame is composed of three different parts :
|
|||||||
- The __Toolbar__, containing all the elements you can use to create your timelapse, such as the start or the stop buttons
|
- The __Toolbar__, containing all the elements you can use to create your timelapse, such as the start or the stop buttons
|
||||||
- The __Main Frame__, aiming at presenting all the information and status of the application in real time.
|
- The __Main Frame__, aiming at presenting all the information and status of the application in real time.
|
||||||
|
|
||||||
[Insert numbered list here]
|
|
||||||
|
|
||||||
### MenuBar
|
### MenuBar
|
||||||
|
|
||||||
I am quite sure everyone having a computer is used to it, but let's present it anyway !
|
I am quite sure everyone having a computer is used to it, but let's present it anyway !
|
||||||
@@ -35,7 +33,7 @@ The elements of the menubar are quite straight speaking :
|
|||||||
The toolbar contains several icons, each of them having a precise purpose:
|
The toolbar contains several icons, each of them having a precise purpose:
|
||||||
|
|
||||||
- The first folder button shall be used to define the input folder that will be searched for images. All the images of the folder (and its subfolders) will be used in the timlapse generation
|
- The first folder button shall be used to define the input folder that will be searched for images. All the images of the folder (and its subfolders) will be used in the timlapse generation
|
||||||
- The second icon opens the settings window. You can learn more about it in (OTHER CHAPTER). For a basic usage, you can just let the default options.
|
- The second icon opens the settings window. You can learn more about it in the next chapter. For a basic usage, you can just let the default options.
|
||||||
- Then come the start and stop buttons. Once you input folder is chosen, you can start the application by pressing the green button. Pressing the red button wile processing will stop it.
|
- Then come the start and stop buttons. Once you input folder is chosen, you can start the application by pressing the green button. Pressing the red button wile processing will stop it.
|
||||||
- Finally, a quick link to the online help is here in case you need it.
|
- Finally, a quick link to the online help is here in case you need it.
|
||||||
|
|
||||||
@@ -71,7 +69,7 @@ The folder you have selected will be walked __recursively__, including all its s
|
|||||||
All the images will be then listed, while non image files will automatically discarded.
|
All the images will be then listed, while non image files will automatically discarded.
|
||||||
|
|
||||||
When this step is finished, the algorithm will __start searching for faces__ in your pictures, in __chronological order__.
|
When this step is finished, the algorithm will __start searching for faces__ in your pictures, in __chronological order__.
|
||||||
A [green color](color in green) on a file means that the image was successfully processed, while a [red color](color in red) indicates that no face has been found.
|
A <font color="green">green color</font> on a file means that the image was successfully processed, while a <font color="red">red color</font> indicates that no face has been found.
|
||||||
When all the files are given a color, the face detection step is terminated and the movie will be generated.
|
When all the files are given a color, the face detection step is terminated and the movie will be generated.
|
||||||
|
|
||||||
Below are presented 2 examples of processing list. In the first case, the face detection is being performed and everything seems to work fine.
|
Below are presented 2 examples of processing list. In the first case, the face detection is being performed and everything seems to work fine.
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ Slug: OneMinuteTutorial
|
|||||||
|
|
||||||
This page aims at putting you on rails __as fast as possible__, so that you can see what Ivolution is capable of by yourself __in less than 5 minutes__.
|
This page aims at putting you on rails __as fast as possible__, so that you can see what Ivolution is capable of by yourself __in less than 5 minutes__.
|
||||||
|
|
||||||
First of all, __[download](link to Download page)__ the version of Ivolution corresponding to your operating system here.
|
First of all, __[download](https://sourceforge.net/projects/ivolutioner/files/current/)__ the version of Ivolution corresponding to your operating system here.
|
||||||
Then, __[download the set of samples](link to samples directly)__ that you are going to use here, and extract the archive where you want.
|
Then, __[download the set of samples](http://sourceforge.net/projects/ivolutioner/files/other%20downloads/Ivolution_samples.zip/download)__ that you are going to use here, and extract the archive where you want.
|
||||||
|
|
||||||
Install the Ivolution and run it.
|
Install the Ivolution and run it.
|
||||||
You should now see the main frame of the application.
|
You should now see the main frame of the application.
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ Each image is also moved so that __the faces always stays in the same place__, e
|
|||||||
You can easily understand this concept by looking at the difference between each mode in this video :
|
You can easily understand this concept by looking at the difference between each mode in this video :
|
||||||
|
|
||||||
<center>
|
<center>
|
||||||
<iframe width="640" height="360" src="http://www.youtube.com/embed/9ZpKnSjvmXo?feature=player_detailpage" frameborder="0" allowfullscreen></iframe>
|
<iframe width="420" height="315" src="http://www.youtube.com/embed/dXuGMZk9_U8" frameborder="0" allowfullscreen></iframe>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ LINKS = (('Python.org', 'http://python.org'),
|
|||||||
('WxPython', 'http://wxpython.org/'),)
|
('WxPython', 'http://wxpython.org/'),)
|
||||||
|
|
||||||
PAGELINKS = (('Ivolution Project', 'Ivolution.html'),
|
PAGELINKS = (('Ivolution Project', 'Ivolution.html'),
|
||||||
('1 minute kick-off', 'OneMinuteTutorial.html'),
|
('One minute tutorial', 'OneMinuteTutorial.html'),
|
||||||
('Downloads', 'Downloads.html'),
|
('Downloads', 'Downloads.html'),
|
||||||
('Installation', 'Installation.html'),
|
('Installation', 'Installation.html'),
|
||||||
('Main Interface', 'MainInterface.html'),
|
('Main Interface', 'MainInterface.html'),
|
||||||
@@ -34,6 +34,21 @@ SOCIAL = (('My website', 'http://lengrand.fr'),
|
|||||||
DEFAULT_PAGINATION = False
|
DEFAULT_PAGINATION = False
|
||||||
NEWEST_FIRST_ARCHIVES = False
|
NEWEST_FIRST_ARCHIVES = False
|
||||||
|
|
||||||
|
#theme folder = /home/test/.virtualenvs/pelican/local/lib/python2.7/site-packages/pelican/themes/
|
||||||
THEME = "ivolution"
|
THEME = "ivolution"
|
||||||
|
|
||||||
#theme folder = /home/test/.virtualenvs/pelican/local/lib/python2.7/site-packages/pelican/themes/svbtle' ...
|
PLUGINS=['pelican.plugins.sitemap',]
|
||||||
|
|
||||||
|
SITEMAP = {
|
||||||
|
'format': 'xml',
|
||||||
|
'priorities': {
|
||||||
|
'articles': 0.5,
|
||||||
|
'indexes': 0.5,
|
||||||
|
'pages': 0.8
|
||||||
|
},
|
||||||
|
'changefreqs': {
|
||||||
|
'articles': 'monthly',
|
||||||
|
'indexes': 'daily',
|
||||||
|
'pages': 'daily'
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Website/pelicanconf.pyc
Normal file
BIN
Website/pelicanconf.pyc
Normal file
Binary file not shown.
208
Website/plugins/sitemap.py
Executable file
208
Website/plugins/sitemap.py
Executable file
@@ -0,0 +1,208 @@
|
|||||||
|
import os.path
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
from logging import debug, warning, error, info
|
||||||
|
from codecs import open
|
||||||
|
|
||||||
|
from pelican import signals, contents
|
||||||
|
|
||||||
|
TXT_HEADER = u"""{0}/index.html
|
||||||
|
{0}/archives.html
|
||||||
|
{0}/tags.html
|
||||||
|
{0}/categories.html
|
||||||
|
"""
|
||||||
|
|
||||||
|
XML_HEADER = u"""<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
|
||||||
|
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>{0}/index.html</loc>
|
||||||
|
<lastmod>{1}</lastmod>
|
||||||
|
<changefreq>{2}</changefreq>
|
||||||
|
<priority>{3}</priority>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>{0}/archives.html</loc>
|
||||||
|
<lastmod>{1}</lastmod>
|
||||||
|
<changefreq>{2}</changefreq>
|
||||||
|
<priority>{3}</priority>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>{0}/tags.html</loc>
|
||||||
|
<lastmod>{1}</lastmod>
|
||||||
|
<changefreq>{2}</changefreq>
|
||||||
|
<priority>{3}</priority>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>{0}/categories.html</loc>
|
||||||
|
<lastmod>{1}</lastmod>
|
||||||
|
<changefreq>{2}</changefreq>
|
||||||
|
<priority>{3}</priority>
|
||||||
|
</url>
|
||||||
|
"""
|
||||||
|
|
||||||
|
XML_URL = u"""
|
||||||
|
<url>
|
||||||
|
<loc>{0}/{1}</loc>
|
||||||
|
<lastmod>{2}</lastmod>
|
||||||
|
<changefreq>{3}</changefreq>
|
||||||
|
<priority>{4}</priority>
|
||||||
|
</url>
|
||||||
|
"""
|
||||||
|
|
||||||
|
XML_FOOTER = u"""
|
||||||
|
</urlset>
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def format_date(date):
|
||||||
|
if date.tzinfo:
|
||||||
|
tz = date.strftime('%s')
|
||||||
|
tz = tz[:-2] + ':' + tz[-2:]
|
||||||
|
else:
|
||||||
|
tz = "-00:00"
|
||||||
|
return date.strftime("%Y-%m-%dT%H:%M:%S") + tz
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class SitemapGenerator(object):
|
||||||
|
|
||||||
|
def __init__(self, context, settings, path, theme, output_path, *null):
|
||||||
|
|
||||||
|
self.output_path = output_path
|
||||||
|
self.context = context
|
||||||
|
self.now = datetime.now()
|
||||||
|
self.siteurl = settings.get('SITEURL')
|
||||||
|
|
||||||
|
self.format = 'xml'
|
||||||
|
|
||||||
|
self.changefreqs = {
|
||||||
|
'articles': 'monthly',
|
||||||
|
'indexes': 'daily',
|
||||||
|
'pages': 'monthly'
|
||||||
|
}
|
||||||
|
|
||||||
|
self.priorities = {
|
||||||
|
'articles': 0.5,
|
||||||
|
'indexes': 0.5,
|
||||||
|
'pages': 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
config = settings.get('SITEMAP', {})
|
||||||
|
|
||||||
|
if not isinstance(config, dict):
|
||||||
|
warning("sitemap plugin: the SITEMAP setting must be a dict")
|
||||||
|
else:
|
||||||
|
fmt = config.get('format')
|
||||||
|
pris = config.get('priorities')
|
||||||
|
chfreqs = config.get('changefreqs')
|
||||||
|
|
||||||
|
if fmt not in ('xml', 'txt'):
|
||||||
|
warning("sitemap plugin: SITEMAP['format'] must be `txt' or `xml'")
|
||||||
|
warning("sitemap plugin: Setting SITEMAP['format'] on `xml'")
|
||||||
|
elif fmt == 'txt':
|
||||||
|
self.format = fmt
|
||||||
|
return
|
||||||
|
|
||||||
|
valid_keys = ('articles', 'indexes', 'pages')
|
||||||
|
valid_chfreqs = ('always', 'hourly', 'daily', 'weekly', 'monthly',
|
||||||
|
'yearly', 'never')
|
||||||
|
|
||||||
|
if isinstance(pris, dict):
|
||||||
|
for k, v in pris.iteritems():
|
||||||
|
if k in valid_keys and not isinstance(v, (int, float)):
|
||||||
|
default = self.priorities[k]
|
||||||
|
warning("sitemap plugin: priorities must be numbers")
|
||||||
|
warning("sitemap plugin: setting SITEMAP['priorities']"
|
||||||
|
"['{0}'] on {1}".format(k, default))
|
||||||
|
pris[k] = default
|
||||||
|
self.priorities.update(pris)
|
||||||
|
elif pris is not None:
|
||||||
|
warning("sitemap plugin: SITEMAP['priorities'] must be a dict")
|
||||||
|
warning("sitemap plugin: using the default values")
|
||||||
|
|
||||||
|
if isinstance(chfreqs, dict):
|
||||||
|
for k, v in chfreqs.iteritems():
|
||||||
|
if k in valid_keys and v not in valid_chfreqs:
|
||||||
|
default = self.changefreqs[k]
|
||||||
|
warning("sitemap plugin: invalid changefreq `{0}'".format(v))
|
||||||
|
warning("sitemap plugin: setting SITEMAP['changefreqs']"
|
||||||
|
"['{0}'] on '{1}'".format(k, default))
|
||||||
|
chfreqs[k] = default
|
||||||
|
self.changefreqs.update(chfreqs)
|
||||||
|
elif chfreqs is not None:
|
||||||
|
warning("sitemap plugin: SITEMAP['changefreqs'] must be a dict")
|
||||||
|
warning("sitemap plugin: using the default values")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def write_url(self, page, fd):
|
||||||
|
|
||||||
|
if getattr(page, 'status', 'published') != 'published':
|
||||||
|
return
|
||||||
|
|
||||||
|
lastmod = format_date(getattr(page, 'date', self.now))
|
||||||
|
|
||||||
|
if isinstance(page, contents.Article):
|
||||||
|
pri = self.priorities['articles']
|
||||||
|
chfreq = self.changefreqs['articles']
|
||||||
|
elif isinstance(page, contents.Page):
|
||||||
|
pri = self.priorities['pages']
|
||||||
|
chfreq = self.changefreqs['pages']
|
||||||
|
else:
|
||||||
|
pri = self.priorities['indexes']
|
||||||
|
chfreq = self.changefreqs['indexes']
|
||||||
|
|
||||||
|
|
||||||
|
if self.format == 'xml':
|
||||||
|
fd.write(XML_URL.format(self.siteurl, page.url, lastmod, chfreq, pri))
|
||||||
|
else:
|
||||||
|
fd.write(self.siteurl + '/' + loc + '\n')
|
||||||
|
|
||||||
|
|
||||||
|
def generate_output(self, writer):
|
||||||
|
path = os.path.join(self.output_path, 'sitemap.{0}'.format(self.format))
|
||||||
|
|
||||||
|
pages = self.context['pages'] + self.context['articles'] \
|
||||||
|
+ [ c for (c, a) in self.context['categories']] \
|
||||||
|
+ [ t for (t, a) in self.context['tags']] \
|
||||||
|
+ [ a for (a, b) in self.context['authors']]
|
||||||
|
|
||||||
|
for article in self.context['articles']:
|
||||||
|
pages += article.translations
|
||||||
|
|
||||||
|
|
||||||
|
info('writing {0}'.format(path))
|
||||||
|
|
||||||
|
with open(path, 'w', encoding='utf-8') as fd:
|
||||||
|
|
||||||
|
if self.format == 'xml':
|
||||||
|
fd.write(XML_HEADER.format(
|
||||||
|
self.siteurl,
|
||||||
|
format_date(self.now),
|
||||||
|
self.changefreqs['indexes'],
|
||||||
|
self.priorities['indexes']
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
fd.write(TXT_HEADER.format(self.siteurl))
|
||||||
|
|
||||||
|
for page in pages:
|
||||||
|
self.write_url(page, fd)
|
||||||
|
|
||||||
|
if self.format == 'xml':
|
||||||
|
fd.write(XML_FOOTER)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def get_generators(generators):
|
||||||
|
return SitemapGenerator
|
||||||
|
|
||||||
|
|
||||||
|
def register():
|
||||||
|
signals.get_generators.connect(get_generators)
|
||||||
Reference in New Issue
Block a user