Преглед на файлове

Merge pull request #485 from DirkR/remove_textbundle_plugin

Remove textbundle plugin
Justin Mayer преди 9 години
родител
ревизия
83e4e76aad
променени са 5 файла, в които са добавени 6 реда и са изтрити 265 реда
  1. 6 8
      Readme.rst
  2. 0 99
      textbundle/Readme.md
  3. 0 1
      textbundle/__init__.py
  4. 0 81
      textbundle/migrate.sh
  5. 0 76
      textbundle/textbundle.py

+ 6 - 8
Readme.rst

@@ -3,8 +3,8 @@ Pelican Plugins
 
 Beginning with version 3.0, Pelican supports plugins. Plugins are a way to add
 features to Pelican without having to directly modify the Pelican core. Starting
-with 3.2, all plugins (including the ones previously in the core) are 
-moved here, so this is the central place for all plugins. 
+with 3.2, all plugins (including the ones previously in the core) are
+moved here, so this is the central place for all plugins.
 
 How to use plugins
 ==================
@@ -39,11 +39,11 @@ Plugin                    Description
 AsciiDoc reader           Use AsciiDoc to write your posts.
 
 Asset management          Use the Webassets module to manage assets such as CSS and JS files.
-                    
+
 Auto Pages                Generate custom content for generated Author, Category, and Tag pages (e.g. author biography)
 
 Better code samples       Wraps all `table` blocks with a class attribute `.codehilitetable` in an additional `div` of class `.hilitewrapper`. It thus permits to style codeblocks better, especially to make them scrollable.
-                    
+
 Better figures/samples    Adds a `style="width: ???px; height: auto;"` attribute to any `<img>` tags in the content
 
 bootstrapify              Automatically add bootstraps default classes to your content, usefull for md generated tables
@@ -54,7 +54,7 @@ Clean summary             Cleans your summary of excess images
 
 Code include              Includes Pygments highlighted code in reStructuredText
 
-Collate content           Makes categories of content available to the template as lists through a `collations` attribute 
+Collate content           Makes categories of content available to the template as lists through a `collations` attribute
 
 Creole reader             Allows you to write your posts using the wikicreole syntax
 
@@ -124,8 +124,6 @@ Pelican Page Order        Adds a ``page_order`` attribute to all pages if one is
 
 Pelican comment system    Allows you to add static comments to your articles
 
-Pelican TextBundle        Create posts from TextBundles
-
 Pelican Vimeo             Enables you to embed Vimeo videos in your pages and articles
 
 Pelican YouTube           Enables you to embed YouTube videos in your pages and articles
@@ -180,7 +178,7 @@ W3C validate              Submits generated HTML content to the W3C Markup Valid
 ========================  ===========================================================
 
 
-Please refer to the ``Readme`` file in a plugin's folder for detailed information about 
+Please refer to the ``Readme`` file in a plugin's folder for detailed information about
 that plugin.
 
 Contributing a plugin

+ 0 - 99
textbundle/Readme.md

@@ -1,99 +0,0 @@
-# Textbundle Reader
-
-This plugin helps you creating posts from Textbundles
-(<http://textbundle.org/spec/>).
-
-In a nutshell a textbundle is a folder with a `.textbundle` name suffix and
-a predefined folder hierarchy. The Markdown text is always in a file `text.md`,
-all referenced assets (images, videos, etc.) are located in a subfolder named
-`assets/` and a file `info.json` (obviously in JSON format) provides some meta
-data.
-
-## Dependency
-
-This plugin needs [Markdown](https://pypi.python.org/pypi/Markdown) to work.
-Install it with:
-
-```
-pip install Markdown
-```
-
-## Installation and configuration
-
-Install the textbundle plugin and add it to the `PLUGINS` setting in
-`pelicanconf.py`:
-
-```
-PLUGINS = [
-    'textbundle',
-     ...
-    ]
-```
-
-Furthermore the content of the `ARTICLE_PATHS` setting has to be appended to the
-`STATIC_PATHS` list.
-
-```
-ARTICLE_PATHS = ['posts']
-...
-STATIC_PATHS = [
-    'posts',
-     ...
-    ]
-```
-
-The output content pages has to be generated into files `index.html` inside the
-folder named after the page slug or article slug. This way the assets can be
-placed next to the content file and do not interfere with asset files of other
-textbundles.
-
-A working example of article/page slugs and output URLs are:
-
-```
-ARTICLE_URL = 'post/{slug}/'
-ARTICLE_SAVE_AS = 'post/{slug}/index.html'
-
-PAGE_URL = '{slug}/'
-PAGE_SAVE_AS = '{slug}/index.html'
-```
-
-## Usage
-
-Inside a Markdown file (the file `text.md` in a textbundle) the files from the
-`assets/` folder are referenced using relative pathnames and the `{attach}`
-suffix, as described in the [pelican documentation][pelican-docs], section
-"Linking to static files".
-
-An article with the slug "my-blog-post" and an image named `screenshot.png` in
-the `assets/` folder contains a link like this:
-
-```
-![alt text]({attach}assets/screenshot.png "title text")
-```
-
-Assuming the above mentioned settings in `pelicanconf.py` the following files
-are generated in the output folder:
-
-* posts/my-blog-post/index.html
-* posts/my-blog-post/assets/screenshot.png
-
-Further examples can be found in my personal blog ([GitHub][niebegegnet-gh],
-[Link][niebegegnet-blog]).
-
-### Generating the boilerplate
-
-To create a new post I have a shell function `new_post` defined in `~/.bashrc` or
-`~/.zshrc`. Running
-
-```
-new_post "My next blogpost"
-```
-
-at the shell prompt creates the file structure of a textbundle in the posts dir
-of my blog project. The code can be found in my [new_post
-gist](https://gist.github.com/DirkR/aabb1b6fa97ff92ed86a).  The path names
-are hardcoded as it's quite easy to adopt the script to one's personal needs.
-
-[pelican-docs]: http://docs.getpelican.com/en/latest/content.html#linking-to-static-files
-[niebegegnet-gh]: https://github.com/DirkR/niebegeg.net
-[niebegegnet-blog]: https://niebegeg.net

+ 0 - 1
textbundle/__init__.py

@@ -1 +0,0 @@
-from .textbundle import *

+ 0 - 81
textbundle/migrate.sh

@@ -1,81 +0,0 @@
-#!/bin/sh
-
-PAGE_PATH="content/pages"
-ARTICLE_PATH="content/posts"
-IMAGE_PATH="content/images"
-FILE_PATH="content/files"
-
-IMAGE_URL="/images/"
-FILE_URL="/files/"
-
-# Set to "1" if all files should be converted.
-# Otherwise only files containing image links are converted.
-CONVERT_ALL_FILES=0
-
-MKDIR="mkdir -p"
-MV="git mv"
-SED="sed"
-## All modifying commands can be switched to DRY-mode by uncommenting te following lines
-#MKDIR="echo mkdir -p"
-#MV="echo git mv"
-#SED="echo sed"
-
-rename_markdown_files() {
-  for md_file in $PAGE_PATH/*.md $ARTICLE_PATH/*.md
-  do
-    [ -e "$md_file" ] || continue
-    tb_file="${md_file/.md/.textbundle}"
-    grep -qE '\!\[.*\]\([^ \)]*' "$md_file" /dev/null
-    if [ $? == 0 -o $CONVERT_ALL_FILES ]
-    then
-      echo "Convert '$md_file'"
-      $MKDIR "$tb_file/assets"
-      $MV "$md_file" "$tb_file/text.md"
-    else
-      echo "Skip '$md_file', because it doesn't contain image links."
-    fi
-  done
-}
-
-create_metadata() {
-  for tb_file in $PAGE_PATH/*.textbundle $ARTICLE_PATH/*.textbundle
-  do
-    test -e "$tb_file/info.json" || cat > "$tb_file/info.json" <<INFOJSON
-{
-  "version":              1,
-  "transient":            false,
-  "creatorURL":           "http://getpelican.com/",
-  "creatorIdentifier":    "https://github.com/DirkR/pelican-textbundle"
-}
-INFOJSON
-  done
-}
-
-move_assets() {
-  echo '# Apache Rewrite rules for moved assets' > assets_htaccess_fragment.txt
-  for tb_file in $PAGE_PATH/*.textbundle $ARTICLE_PATH/*.textbundle
-  do
-    md_file="$tb_file/text.md"
-    [ -e "$md_file" ] || continue
-    for asset in $(perl -n -e '/\[.*\]\((\/[^ \)]*)/ && print "$1\n"' "$md_file")
-    do
-      if [ -z "${asset##*$IMAGE_URL*}" -o -z "${asset##*$FILE_URL*}" ]
-      then
-        rel_path=$(echo $asset | $SED -e "s!^($IMAGE_URL|$FILE_URL)!!")
-        asset_name=$(basename $asset)
-        [ -d "$tb_file/assets" ] || MKDIR "$tb_file/assets"
-        $MV "content$asset" "$tb_file/assets/$asset_name"
-        slug=$(perl -n -e '/slug\s*:\s*(.+)/ && print $1' "$tb_file/text.md")
-        if [ ! -z "$slug" ]
-        then
-          echo "RewriteRule ^$asset /post/$slug/assets/$asset_name [R=301,L]" >> assets_htaccess_fragment.txt
-        fi
-        $SED -i.bak -e "s|$asset|assets/$asset_name|g" "$md_file"
-      fi
-    done
-  done
-}
-
-rename_markdown_files
-create_metadata
-move_assets

+ 0 - 76
textbundle/textbundle.py

@@ -1,76 +0,0 @@
-#-*- conding: utf-8 -*-
-
-import os
-import logging
-import shutil
-from glob import glob
-
-from pelican import readers
-from pelican import signals
-from markdown import Markdown
-
-logger = logging.getLogger(__name__)
-
-
-class TextbundleReader(readers.MarkdownReader):
-    enabled = Markdown
-    path_mappings = {}
-    file_extensions = ['textbundle']
-
-    # You need to have a read method, which takes a filename and returns
-    # some content and the associated metadata.
-    def read(self, filename):
-        md_filename = "{}/text.md".format(filename)
-        logger.debug('Found textbundle {}'.format(filename))
-        return super(TextbundleReader, self).read(md_filename)
-
-
-def add_reader(readers):
-    readers.reader_classes['textbundle'] = TextbundleReader
-
-
-def copy_article_assets(generator):
-    logging.debug('Copy Article textbundle assets')
-    inspect_content_items(generator.articles, generator.output_path)
-
-
-def copy_page_assets(generator):
-    logging.debug('Copy Page textbundle assets')
-    inspect_content_items(generator.pages, generator.output_path)
-
-
-def inspect_content_items(content_items, output_path):
-    """
-    Check if there are files in the assets/ foldr of a textbundle have to be
-    copied to the output folder.
-    """
-    for item in content_items:
-        foldername = os.path.join(
-            output_path,
-            os.path.dirname(item.save_as),
-            'assets'
-        )
-        assets = glob("{}/assets/*.*".format(os.path.dirname(item.source_path)))
-        if len(assets) > 0:
-            copy_assets_to_outputfolder(assets, foldername)
-
-
-def copy_assets_to_outputfolder(assets, foldername):
-    """
-    Copy all files from the assets/ folder of a textbundle to the output folder.
-    """
-    if not os.path.exists(foldername):
-        os.makedirs(foldername)
-    for asset in assets:
-        asset_path = os.path.join(foldername, os.path.basename(asset))
-        if not os.path.exists(asset_path):
-            logger.debug('copying asset {} to {}'.format(asset, foldername))
-            shutil.copy2(asset, asset_path)
-        else:
-            logger.debug('skipping existing asset {}'.format(foldername))
-
-
-def register():
-    signals.readers_init.connect(add_reader)
-    signals.article_generator_finalized.connect(copy_article_assets)
-    signals.page_generator_finalized.connect(copy_page_assets)