Giter Site home page Giter Site logo

imap_importer's Introduction

Pelican Imap Importer

Automatically copies content from text e-mails to your pelican content directory.

This allows you to send articles, pages, comments1, ... to a specific e-mail address and on the next site rebuild they will be automatically imported.

Author Website Github
Bernhard Scheirle http://bernhard.scheirle.de https://github.com/Scheirle

Requirements (Python packages)

  • keyring

Setup

Settings

Name Type Default Description
FOLDERS list [] List containing all imap folders the plugin should watch
HOST string '' E-Mail provider
USER string '' login credentials
TYPES dict (see code) Specifies where to copy the content
FILE_FORMAT string md File extension (currently only used by the FILENAME function)

The TYPES dict

The TYPES-dict contains different content types (articles, pages, comments, ...). Each content type (is a dict) has a PATH and FILENAME member.

Name | Type | Description ------------|------------|---------|------- PATH | string | Path to the folder in which the content should be copied. Relative to the Pelican PATH variable. Placeholders ({my-metadata}) will get replaced for each email. FILENAME | function | Optional. Function which returns the filename for the current email. The number function generates ongoing filenames.

E-Mail

In order to detect the content correctly the e-mail has to be in a specific form:

<Anything above this line will be ignored>
-----BEGIN IMPORT BLOCK-----
type: <the type of the content; as specified by TYPES >
<arbitrary other metadata; will be used to replace placeholders in PATH>
-----BEGIN CONTENT BLOCK-----
<Content; Will not be validated; Simply copied into a file>
-----END CONTENT/IMPORT BLOCK-----
<Anything below this line will be ignored>

Example

pelicanconf.py:

def myFilenameFunc(path, metadata, content, settings):
	"""
	Returns the filename which should be used to store the content.

	path: absolute path to the parent folder
	metadata: email metadata 
	content: content of the file
	settings: pelican settings
	"""

IMAP_IMPORTER = {
	'FOLDERS' : ['INBOX.PelicanImport', 'INBOX.Folder2']
	'HOST' : "example.org"
	'USER' : "[email protected]"
	'TYPES' : {
		'my-content-type' : {
			'PATH' : os.path.join('my-folder', '{my-metadata}'),
			'FILENAME' : myFilenameFunc,
		},
		'article' : {
			'PATH' : os.path.join('articles', '{category}'),
		},
		'comment' : {
			'PATH' : os.path.join('comments', '{slug}'),
			'FILENAME' : number,
		},
	}
}

Let's say there is following e-mail in INBOX.PelicanImport:

Hey Reader,
below is my awesome article.
-----BEGIN IMPORT BLOCK-----
type: article
category: demo
filename: my-demo-article.md
-----BEGIN CONTENT BLOCK-----
title: My Demo Article

[...]
-----END CONTENT/IMPORT BLOCK-----

Greetings Writer

Imap_importer will now copy the “My Demo Article” article (CONTENT BLOCK) to articles/demo/my-demo-article.md

TODO

  • Clean up
  • Optionally delete imported e-mails
  • Setup helper (list imap folders)
  • Fix some inconsistencies with FILE_FORMAT
  • Improve Doc

Footnotes

  1. In conjunction with the Pelican Comment System.

imap_importer's People

Contributors

scheirle avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.