Browse Source

Merge branch 'master' of https://github.com/getpelican/pelican-plugins

Peter Bittner 9 years ago
parent
commit
1bdc236128

+ 6 - 0
.gitmodules

@@ -100,3 +100,9 @@
 [submodule "backreftranslate"]
 [submodule "backreftranslate"]
 	path = backreftranslate
 	path = backreftranslate
 	url = https://github.com/daltonmatos/pelican-plugin-backref-translate
 	url = https://github.com/daltonmatos/pelican-plugin-backref-translate
+[submodule "category_order"]
+	path = category_order
+	url = https://github.com/jhshi/pelican.plugins.category_order.git
+[submodule "ga_page_view"]
+	path = ga_page_view
+	url = https://github.com/jhshi/pelican.plugins.ga_page_view.git

+ 8 - 0
Readme.rst

@@ -52,6 +52,8 @@ Better figures/samples    Adds a `style="width: ???px; height: auto;"` attribute
 
 
 bootstrapify              Automatically add bootstraps default classes to your content, usefull for md generated tables
 bootstrapify              Automatically add bootstraps default classes to your content, usefull for md generated tables
 
 
+Category Order            Order categories (and tags) by the number of articles in that category (or tag).
+
 CJK auto spacing          Inserts spaces between Chinese/Japanese/Korean characters and English words
 CJK auto spacing          Inserts spaces between Chinese/Japanese/Korean characters and English words
 
 
 Clean summary             Cleans your summary of excess images
 Clean summary             Cleans your summary of excess images
@@ -122,6 +124,8 @@ Open graph                Generates Open Graph tags for your articles
 
 
 Optimize images           Applies lossless compression on JPEG and PNG images
 Optimize images           Applies lossless compression on JPEG and PNG images
 
 
+Page View                 Pull page view count from Google Analytics.
+
 PDF generator             Automatically exports RST articles and pages as PDF files
 PDF generator             Automatically exports RST articles and pages as PDF files
 
 
 PDF Images                If an img tag contains a PDF, EPS or PS file as a source, this plugin generates a PNG preview which will then act as a link to the original file.
 PDF Images                If an img tag contains a PDF, EPS or PS file as a source, this plugin generates a PNG preview which will then act as a link to the original file.
@@ -146,6 +150,8 @@ Pelican YouTube           Enables you to embed YouTube videos in your pages and
 
 
 pelicanfly                Lets you type things like `i ♥ :fa-coffee:` in your Markdown documents and have it come out as little Font Awesome icons in the browser
 pelicanfly                Lets you type things like `i ♥ :fa-coffee:` in your Markdown documents and have it come out as little Font Awesome icons in the browser
 
 
+Photos                    Add a photo or a gallery of photos to an article, or include photos in the body text. Resize photos as needed.
+
 Pin to top                Pin Pelican's article(s) to top "Sticky article"
 Pin to top                Pin Pelican's article(s) to top "Sticky article"
 
 
 PlantUML                  Allows you to define UML diagrams directly into rst documents using the great PlantUML tool
 PlantUML                  Allows you to define UML diagrams directly into rst documents using the great PlantUML tool
@@ -182,6 +188,8 @@ Static comments           Allows you to add static comments to an article
 
 
 Subcategory               Adds support for subcategories
 Subcategory               Adds support for subcategories
 
 
+Sub parts                 Break a very long article in parts, without polluting the timeline with lots of small articles.
+
 Summary                   Allows easy, variable length summaries directly embedded into the body of your articles
 Summary                   Allows easy, variable length summaries directly embedded into the body of your articles
 
 
 tag_cloud                 Provides a tag_cloud
 tag_cloud                 Provides a tag_cloud

+ 14 - 4
better_figures_and_images/better_figures_and_images.py

@@ -15,6 +15,7 @@ TODO: Need to add a test.py for this plugin.
 
 
 from __future__ import unicode_literals
 from __future__ import unicode_literals
 from os import path, access, R_OK
 from os import path, access, R_OK
+import os
 
 
 from pelican import signals
 from pelican import signals
 
 
@@ -51,12 +52,21 @@ def content_object_init(instance):
                 else:
                 else:
                     logger.warning('Better Fig. Error: img_path should start with either {filename}, |filename| or /static')
                     logger.warning('Better Fig. Error: img_path should start with either {filename}, |filename| or /static')
 
 
-                # Build the source image filename
-                src = instance.settings['PATH'] + img_path + '/' + img_filename
+                # search src path list
+                # 1. Build the source image filename from PATH
+                # 2. Build the source image filename from STATIC_PATHS
+                src = os.path.join(instance.settings['PATH'], img_path, img_filename)
+                src_candidates = [src]
+                src_candidates += [os.path.join(instance.settings['PATH'], static_path, img_path, img_filename) for static_path in instance.settings['STATIC_PATHS']]
+                src_candidates = [f for f in src_candidates if path.isfile(f) and access(f, R_OK)]
 
 
-                logger.debug('Better Fig. src: %s', src)
-                if not (path.isfile(src) and access(src, R_OK)):
+                if not src_candidates:
                     logger.error('Better Fig. Error: image not found: %s', src)
                     logger.error('Better Fig. Error: image not found: %s', src)
+                    logger.debug('Better Fig. Skip src: %s', img_path + '/' + img_filename)
+                    continue
+
+                src = src_candidates[0]
+                logger.debug('Better Fig. src: %s', src)
 
 
                 # Open the source image and query dimensions; build style string
                 # Open the source image and query dimensions; build style string
                 im = Image.open(src)
                 im = Image.open(src)

+ 1 - 0
category_order

@@ -0,0 +1 @@
+Subproject commit 0f1a86e566cc38b2137ca66a107a08d4fa56a981

+ 1 - 0
ga_page_view

@@ -0,0 +1 @@
+Subproject commit f09eaaefd666f6cfd6e2c271778d5a25e3b9ab28

+ 2 - 2
photos/README.md

@@ -144,9 +144,9 @@ Add the following to the template `base.html`, before the closing HTML `</body>`
 
 
 ## Known use cases
 ## Known use cases
 
 
-<pxquim.pt> uses Photos and the plug-in Sub-parts to publish 600 photo galleries with 40,000 photos. Photos keeps the high-resolution photos separate from the site articles.
+[pxquim.pt](http://pxquim.pt/) uses Photos and the plug-in Sub-parts to publish 600 photo galleries with 40,000 photos. Photos keeps the high-resolution photos separate from the site articles.
 
 
-<pxquim.com> uses sub-parts to cover conferences, where it makes sense to have a sub-part for each speaker.
+[pxquim.com](http://pxquim.com/) uses sub-parts to cover conferences, where it makes sense to have a sub-part for each speaker.
 
 
 ## Alternatives
 ## Alternatives
 
 

+ 18 - 6
photos/photos.py

@@ -98,7 +98,9 @@ def detect_content(content):
         if what == 'photo':
         if what == 'photo':
             if value.startswith('/'):
             if value.startswith('/'):
                 value = value[1:]
                 value = value[1:]
-            path = os.path.join(settings['PHOTO_LIBRARY'], value)
+            path = os.path.join(
+                        os.path.expanduser(settings['PHOTO_LIBRARY']),
+                        value)
             if not os.path.isfile(path):
             if not os.path.isfile(path):
                 logger.error('photos: No photo %s', path)
                 logger.error('photos: No photo %s', path)
             else:
             else:
@@ -130,7 +132,9 @@ def detect_content(content):
 def process_gallery_photo(generator, article, gallery):
 def process_gallery_photo(generator, article, gallery):
     if gallery.startswith('/'):
     if gallery.startswith('/'):
         gallery = gallery[1:]
         gallery = gallery[1:]
-    dir_gallery = os.path.join(generator.settings['PHOTO_LIBRARY'], gallery)
+    dir_gallery = os.path.join(
+                    os.path.expanduser(generator.settings['PHOTO_LIBRARY']),
+                    gallery)
     if os.path.isdir(dir_gallery):
     if os.path.isdir(dir_gallery):
         logger.info('photos: Gallery detected: %s', gallery)
         logger.info('photos: Gallery detected: %s', gallery)
         dir_photo = os.path.join('photos', gallery.lower())
         dir_photo = os.path.join('photos', gallery.lower())
@@ -139,7 +143,7 @@ def process_gallery_photo(generator, article, gallery):
                            msg='photos: No EXIF for gallery %s')
                            msg='photos: No EXIF for gallery %s')
         captions = read_notes(os.path.join(dir_gallery, 'captions.txt'))
         captions = read_notes(os.path.join(dir_gallery, 'captions.txt'))
         article.photo_gallery = []
         article.photo_gallery = []
-        for pic in os.listdir(dir_gallery):
+        for pic in sorted(os.listdir(dir_gallery)):
             if pic.startswith('.'): continue
             if pic.startswith('.'): continue
             if pic.endswith('.txt'): continue
             if pic.endswith('.txt'): continue
             photo = os.path.splitext(pic)[0].lower() + '.jpg'
             photo = os.path.splitext(pic)[0].lower() + '.jpg'
@@ -158,6 +162,8 @@ def process_gallery_photo(generator, article, gallery):
                 os.path.join(dir_gallery, pic),
                 os.path.join(dir_gallery, pic),
                 os.path.join(dir_thumb, thumb),
                 os.path.join(dir_thumb, thumb),
                 generator.settings['PHOTO_THUMB'])
                 generator.settings['PHOTO_THUMB'])
+    else:
+        logger.error('photos: Gallery does not exist: %s at %s', gallery, dir_gallery)
 
 
 
 
 def process_gallery_filename(generator, article, gallery):
 def process_gallery_filename(generator, article, gallery):
@@ -165,7 +171,9 @@ def process_gallery_filename(generator, article, gallery):
         gallery = gallery[1:]
         gallery = gallery[1:]
     else:
     else:
         gallery = os.path.join(article.relative_dir, gallery)
         gallery = os.path.join(article.relative_dir, gallery)
-    dir_gallery = os.path.join(generator.settings['PHOTO_LIBRARY'], gallery)
+    dir_gallery = os.path.join(
+                    os.path.expanduser(generator.settings['PHOTO_LIBRARY']),
+                    gallery)
     if os.path.isdir(dir_gallery):
     if os.path.isdir(dir_gallery):
         logger.info('photos: Gallery detected: %s', gallery)
         logger.info('photos: Gallery detected: %s', gallery)
         dir_photo = gallery.lower()
         dir_photo = gallery.lower()
@@ -174,7 +182,7 @@ def process_gallery_filename(generator, article, gallery):
                            msg='photos: No EXIF for gallery %s')
                            msg='photos: No EXIF for gallery %s')
         captions = read_notes(os.path.join(dir_gallery, 'captions.txt'))
         captions = read_notes(os.path.join(dir_gallery, 'captions.txt'))
         article.photo_gallery = []
         article.photo_gallery = []
-        for pic in os.listdir(dir_gallery):
+        for pic in sorted(os.listdir(dir_gallery)):
             if pic.startswith('.'): continue
             if pic.startswith('.'): continue
             if pic.endswith('.txt'): continue
             if pic.endswith('.txt'): continue
             photo = pic.lower()
             photo = pic.lower()
@@ -189,6 +197,8 @@ def process_gallery_filename(generator, article, gallery):
                 os.path.join(dir_gallery, pic),
                 os.path.join(dir_gallery, pic),
                 os.path.join(dir_thumb, thumb),
                 os.path.join(dir_thumb, thumb),
                 generator.settings['PHOTO_THUMB'])
                 generator.settings['PHOTO_THUMB'])
+    else:
+        logger.error('photos: Gallery does not exist: %s at %s', gallery, dir_gallery)
 
 
 
 
 def detect_gallery(generator):
 def detect_gallery(generator):
@@ -206,7 +216,9 @@ def detect_gallery(generator):
 def process_image_photo(generator, article, image):
 def process_image_photo(generator, article, image):
     if image.startswith('/'):
     if image.startswith('/'):
         image = image[1:]
         image = image[1:]
-    path = os.path.join(generator.settings['PHOTO_LIBRARY'], image)
+    path = os.path.join(
+                os.path.expanduser(generator.settings['PHOTO_LIBRARY']),
+                image)
     if os.path.isfile(path):
     if os.path.isfile(path):
         photo = os.path.splitext(image)[0].lower() + 'a.jpg'
         photo = os.path.splitext(image)[0].lower() + 'a.jpg'
         thumb = os.path.splitext(image)[0].lower() + 't.jpg'
         thumb = os.path.splitext(image)[0].lower() + 't.jpg'

+ 2 - 2
sub_parts/README.md

@@ -56,9 +56,9 @@ For example, add the following to the template `article.html`:
 
 
 ## Known use cases
 ## Known use cases
 
 
-<pxquim.pt> uses sub-parts and the plug-in Pictures to publish photo galleries with thousands of photos. Sub-parts break the photo galleries into manageable chunks, possibly with different tags and authors.
+[pxquim.pt](http://pxquim.pt/) uses sub-parts and the plug-in Pictures to publish photo galleries with thousands of photos. Sub-parts break the photo galleries into manageable chunks, possibly with different tags and authors.
 
 
-<pxquim.com> uses sub-parts to cover conferences, where it makes sense to have a sub-part for each speaker.
+[pxquim.com](http://pxquim.com/) uses sub-parts to cover conferences, where it makes sense to have a sub-part for each speaker.
 
 
 ## What is the difference between Sub-part and Series?
 ## What is the difference between Sub-part and Series?
 
 

+ 27 - 0
tag_cloud/README.rst

@@ -3,6 +3,33 @@ tag_cloud
 
 
 This plugin generates a tag-cloud.
 This plugin generates a tag-cloud.
 
 
+Installation
+------------
+
+In order to use to use this plugin, you have to edit(*) or create(+) the following files::
+
+      blog/
+        ├── pelicanconf.py *
+        ├── content
+        ├── plugins +
+        │     └── tag_cloud.py +
+        └── themes
+              └── mytheme
+                    ├── templates
+                    │      └── base.html *
+                    └── static
+                          └── css
+                               └── style.css *
+
+In **pelicanconf.py** you have to activate the plugin::
+
+    PLUGIN_PATHS = ["plugins"]
+    PLUGINS = ["tag_cloud"]
+
+Into your **plugins** folder, you should add tag_cloud.py (from this repository).
+
+In your theme files, you should change **base.html** to apply formats (and sizes) defined in **style.css**, as specified in "Settings", below.
+
 Settings
 Settings
 --------
 --------