From e9dcb1280f822f3a02e9c4a4e582af53587dd3fb Mon Sep 17 00:00:00 2001 From: Martin McCallion Date: Tue, 8 Jun 2021 13:26:08 +0100 Subject: [PATCH 1/5] Fix continuous_import plugin to skip old posts. --- v7/continuous_import/continuous_import.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/v7/continuous_import/continuous_import.py b/v7/continuous_import/continuous_import.py index 3d57c780..145a0f1f 100755 --- a/v7/continuous_import/continuous_import.py +++ b/v7/continuous_import/continuous_import.py @@ -29,6 +29,8 @@ from __future__ import print_function, unicode_literals import os +from datetime import date +from datetime import datetime import dateutil import feedparser @@ -79,7 +81,13 @@ def generate(self, item, feed): output_name = os.path.join(feed['output_folder'], slugify(title, feed['lang'])) + source_ext start_at = feed.get('start_at', '1970-1-1') - start_at = dateutil.parser.parse(start_at, ignoretz=True) + if start_at == 'now': + start_at = datetime.today().now() + else: + start_at = dateutil.parser.parse(start_at, ignoretz=True) + + LOGGER.info('start_at is {}'.format(start_at)) + content = self.site.render_template( feed['template'], None, @@ -98,6 +106,8 @@ def generate(self, item, feed): if dateutil.parser.parse(metadata['date'], ignoretz=True) < start_at: # skip old post + LOGGER.info('Skipping old post ({} is before {}' + .format(metadata['date'], start_at)) return compiler.create_post( From 1579e81611f2ceda519aea7d624da46ecf989f92 Mon Sep 17 00:00:00 2001 From: Chris Warrick Date: Thu, 3 Sep 2020 01:50:47 +0200 Subject: [PATCH 2/5] contentful: update README and requirements Fix getnikola/nikola#3452 --- v8/contentful/README.md | 18 +++++++++++------- v8/contentful/contentful_plugin.py | 16 ++++++++-------- v8/contentful/requirements.txt | 3 ++- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/v8/contentful/README.md b/v8/contentful/README.md index cac3d6c2..061b24a9 100644 --- a/v8/contentful/README.md +++ b/v8/contentful/README.md @@ -7,18 +7,22 @@ a web UI to create and edit posts and pages. How to Use it ------------- -0. Setup your Contentful site using the [Nikola template](----) -1. Install the plugin using ``nikola plugin -i contentful`` +1. Setup your Contentful site: + * In the *Content model*, set up *Post* and *Page* as content types (API identifier must be `post` and `page` respectively) + * Both content types must have `title`, `slug`, `date`, `content` fields. + * Create the `content` field as “text” (NOT “rich text”) with Markdown appearance. + * Any other fields will be part of the post metadata (you might want `tags` there, for example) +2. Install the plugin using ``nikola plugin -i contentful`` 3. Obtain a access token and space ID from your Contentful space and put them in a contentful.json like this: ``` { - "SPACE_ID": 't2gxqu19qu62', - "ACCESS_TOKEN": 'dd167cf8b111d9e17a46059d' + "SPACE_ID": "t2gxqu19qu62", + "ACCESS_TOKEN": "dd167cf8b111d9e17a46059d" } ``` -4. In your conf.py add ``contenful/posts`` to ``POSTS`` and ``contentful/pages`` to ``PAGES``. -5. Run ``nikola contentful`` +4. In your conf.py, add `contentful/posts/*.md` to `POSTS` and `contentful/pages/*.md` to `PAGES`. See `conf.py.sample` for an example. +5. Run `nikola contentful`. -At that point your pages and posts created in Contentful should be ready for you to use. Have fun! \ No newline at end of file +At that point your pages and posts created in Contentful should be ready for you to use. Have fun! diff --git a/v8/contentful/contentful_plugin.py b/v8/contentful/contentful_plugin.py index 0f5db2e3..d9535050 100644 --- a/v8/contentful/contentful_plugin.py +++ b/v8/contentful/contentful_plugin.py @@ -30,7 +30,7 @@ import os import contentful -import yaml +import ruamel.yaml from nikola import utils from nikola.plugin_categories import Command @@ -38,16 +38,16 @@ LOGGER = utils.get_logger('contentful') -class CommandContenful(Command): - """Import the contenful dump.""" +class CommandContentful(Command): + """Import the contentful dump.""" - name = "contenful" + name = "contentful" needs_config = True doc_usage = "" - doc_purpose = "import the contenful dump" + doc_purpose = "import the contentful dump" def _execute(self, options, args): - """Import posts and pages from contenful.""" + """Import posts and pages from contentful.""" if not os.path.exists('contentful.json'): LOGGER.error( 'Please put your credentials in contentful.json as described in the README.') @@ -66,7 +66,7 @@ def _execute(self, options, args): metadata['date'] = metadata['date'].isoformat() with open(fname, 'w+') as outf: outf.write('---\n') - outf.write(yaml.dump(metadata, default_flow_style=False)) + outf.write(ruamel.yaml.dump(metadata, default_flow_style=False)) outf.write('---\n\n') outf.write(post.content) @@ -78,6 +78,6 @@ def _execute(self, options, args): fname = os.path.join(page_dir, page.slug + '.md') with open(fname, 'w+') as outf: outf.write('---\n') - outf.write(yaml.dump(metadata, default_flow_style=False)) + outf.write(ruamel.yaml.dump(metadata, default_flow_style=False)) outf.write('---\n\n') outf.write(page.content) diff --git a/v8/contentful/requirements.txt b/v8/contentful/requirements.txt index 3fbc51b5..c2fd75b4 100644 --- a/v8/contentful/requirements.txt +++ b/v8/contentful/requirements.txt @@ -1 +1,2 @@ -contentful \ No newline at end of file +contentful +ruamel.yaml>=0.15 From 3d0c21adb5eaece1340b7207b7087fdfac9bc78a Mon Sep 17 00:00:00 2001 From: Daniel Shapero Date: Mon, 14 Sep 2020 09:47:53 -0700 Subject: [PATCH 3/5] Warn about new_page to hierarchical pages readme --- v8/hierarchical_pages/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/v8/hierarchical_pages/README.md b/v8/hierarchical_pages/README.md index ec929894..642b39a1 100644 --- a/v8/hierarchical_pages/README.md +++ b/v8/hierarchical_pages/README.md @@ -48,3 +48,5 @@ If you use plain Nikola instead, the URLs would be: * `https://example.com/de/about/team/roberto-alsina/` Note that this plugin requires Nikola 8 or newer. +Additionally, since the `PAGES` variable in your `conf.py` is now empty, the command `nikola new_page` will no longer work. +You can instead create new pages by manually entering the correct metadata. From 9d4a8cff56919aa0adfb9309bc82bfd89677ffde Mon Sep 17 00:00:00 2001 From: Martin McCallion Date: Tue, 8 Jun 2021 14:07:19 +0100 Subject: [PATCH 4/5] Remove unused import. --- v7/continuous_import/continuous_import.py | 1 - 1 file changed, 1 deletion(-) diff --git a/v7/continuous_import/continuous_import.py b/v7/continuous_import/continuous_import.py index 145a0f1f..d02906de 100755 --- a/v7/continuous_import/continuous_import.py +++ b/v7/continuous_import/continuous_import.py @@ -29,7 +29,6 @@ from __future__ import print_function, unicode_literals import os -from datetime import date from datetime import datetime import dateutil import feedparser From 056fab6e29628feaeff4320fece68bde0990f438 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Tue, 8 Jun 2021 17:17:27 -0300 Subject: [PATCH 5/5] Bump continuous_import version --- v7/continuous_import/continuous_import.plugin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v7/continuous_import/continuous_import.plugin b/v7/continuous_import/continuous_import.plugin index bbf4682b..f98ce5e4 100755 --- a/v7/continuous_import/continuous_import.plugin +++ b/v7/continuous_import/continuous_import.plugin @@ -4,7 +4,7 @@ module = continuous_import [Documentation] author = Roberto Alsina -version = 0.4 +version = 0.4.1 website = https://plugins.getnikola.com/continuous_import description = Seamlessly merge other feeds into your blog