Skip to content
Permalink
Browse files
change all instances of 'story' to 'page' (fix #2518)
* change all instances of 'story' to 'page'

This commit replaces all instances of 'story' or 'stories' with 'page' or 'pages'.

The settings STORY_INDEX and COMMENTS_IN_STORIES are now PAGE_INDEX and COMMENTS_IN_PAGES
  • Loading branch information
christianp authored and Kwpolska committed Oct 9, 2016
1 parent 30ec729 commit 398a7242ea2684bfb83994d6108ecb791e51e206
Showing with 91 additions and 77 deletions.
  1. +1 −0 AUTHORS.txt
  2. +2 −0 CHANGES.txt
  3. +5 −5 docs/creating-a-site.txt
  4. +1 −1 docs/extending.txt
  5. +5 −5 docs/internals.txt
  6. +8 −8 docs/manual.txt
  7. +1 −1 docs/path_handlers.txt
  8. +1 −0 docs/theming.txt
  9. +5 −5 nikola/conf.py.in
  10. 0 nikola/data/samplesite/{stories → pages}/1.rst
  11. 0 nikola/data/samplesite/{stories → pages}/bootstrap-demo.rst
  12. 0 nikola/data/samplesite/{stories → pages}/charts.txt
  13. 0 nikola/data/samplesite/{stories → pages}/creating-a-theme.rst
  14. 0 nikola/data/samplesite/{stories → pages}/dr-nikolas-vendetta.rst
  15. 0 nikola/data/samplesite/{stories → pages}/extending.txt
  16. 0 nikola/data/samplesite/{stories → pages}/internals.txt
  17. 0 nikola/data/samplesite/{stories → pages}/listings-demo.rst
  18. 0 nikola/data/samplesite/{stories → pages}/manual.rst
  19. 0 nikola/data/samplesite/{stories → pages}/path_handlers.txt
  20. 0 nikola/data/samplesite/{stories → pages}/quickref.rst
  21. 0 nikola/data/samplesite/{stories → pages}/quickstart.rst
  22. 0 nikola/data/samplesite/{stories → pages}/slides-demo.rst
  23. 0 nikola/data/samplesite/{stories → pages}/social_buttons.txt
  24. 0 nikola/data/samplesite/{stories → pages}/theming.rst
  25. +7 −7 nikola/data/symlinked.txt
  26. +17 −7 nikola/nikola.py
  27. +1 −1 nikola/plugin_categories.py
  28. +2 −2 nikola/plugins/command/import_wordpress.py
  29. +4 −4 nikola/plugins/command/init.py
  30. +2 −2 nikola/plugins/task/indexes.py
  31. +1 −1 nikola/plugins/task/pages.py
  32. +1 −1 nikola/post.py
  33. +4 −4 nikola/utils.py
  34. +1 −1 scripts/baseline.sh
  35. +6 −6 tests/data/translated_titles/conf.py
  36. 0 tests/data/translated_titles/{stories → pages}/1.pl.txt
  37. 0 tests/data/translated_titles/{stories → pages}/1.txt
  38. +3 −3 tests/test_command_import_wordpress.py
  39. +13 −13 tests/test_integration.py
@@ -17,6 +17,7 @@
* `Casey M. Bessette <https://github.com/caseybessette>`_
* `Chris Lee <https://github.com/clee>`_
* `Chris Warrick <https://github.com/Kwpolska>`_
* `Christian Lawson-Perfect <https://github.com/christianp>`_
* `Christopher Arndt <https:/github.com/SpotlightKid>`_
* `Claudio Canepa <https://github.com/ccanepa>`_
* `Damien Tournoud <https://github.com/damz>`_
@@ -4,6 +4,8 @@ New in master
Bugfixes
--------

* Rename ``stories`` to ``pages`` in most of the codebase (Issue
#1891)
* Report missing/unknown dates in posts with filenames
(Issues #2505, #2506)
* Report filename of post that raised exception when scanning
@@ -51,9 +51,9 @@ configuration file:
POSTS = ()
# you can also keep the current content of POSTS if you want a blog with your site
PAGES = (
("stories/*.rst", "", "story.tmpl"),
("stories/*.txt", "", "story.tmpl"),
("stories/*.html", "", "story.tmpl"),
("pages/*.rst", "", "story.tmpl"),
("pages/*.txt", "", "story.tmpl"),
("pages/*.html", "", "story.tmpl"),
)

# And to avoid a conflict because blogs try to generate /index.html
@@ -70,7 +70,7 @@ And now we are ready to create our first page:

Title: index
Scanning posts....done!
[1970-01-01T00:00:00Z] INFO: new_page: Your page's text is at: stories/index.rst
[1970-01-01T00:00:00Z] INFO: new_page: Your page's text is at: pages/index.rst

We can now build and preview our site:

@@ -104,7 +104,7 @@ So, what’s in that ``pages/index.txt`` file?

``title`` is the page title, ``slug`` is the name of the generated HTML file
(in this case it would be ``index.html``). ``date``, ``tags`` and ``link``
doesn’t matter at all in stories. ``description`` is useful for SEO purposes
doesn’t matter at all in pages. ``description`` is useful for SEO purposes
if you care for that.

And below, the content. By default Nikola uses
@@ -470,7 +470,7 @@ from ``super()``. Example plugin: `navstories <https://github.com/getnikola/plu
PostScanner Plugins
-------------------

Get posts and stories from "somewhere" to be added to the timeline.
Get posts and pages from "somewhere" to be added to the timeline.
The only currently existing plugin of this kind reads them from disk.


@@ -88,14 +88,14 @@ one of the existing ones.
You can do doctests, you can do unit tests, you can do integration tests. There is support
for all of them.

Posts and Stories
-----------------
Posts and Pages
---------------

Nikola has a concept of posts and stories. Both are more or less the same thing, except
posts are added into RSS feeds and stories are not. All of them are in a list called
Nikola has a concept of posts and pages. Both are more or less the same thing, except
posts are added into RSS feeds and pages are not. All of them are in a list called
"the timeline" formed by objects of class ``Post``.

When you are creating a task that needs the list of posts and/or stories (for example,
When you are creating a task that needs the list of posts and/or pages (for example,
the RSS creation plugin) on task execution time, your plugin should call ``self.site.scan_posts()``
in ``gen_tasks`` to ensure the timeline is created and available in
``self.site.timeline``. You should not modify the timeline, because it will cause consistency issues.
@@ -508,15 +508,15 @@ options. The exact mechanism is explained above the config options in the
("posts/*.html", "posts", "post.tmpl"),
)
PAGES = (
("stories/*.rst", "stories", "story.tmpl"),
("stories/*.txt", "stories", "story.tmpl"),
("stories/*.html", "stories", "story.tmpl"),
("pages/*.rst", "pages", "story.tmpl"),
("pages/*.txt", "pages", "story.tmpl"),
("pages/*.html", "pages", "story.tmpl"),
)

.. note:: POSTS and PAGES are not flat!

Even if the syntax may suggest you can't, you can create any directory structure you want
inside ``posts/`` or ``stories/`` and it will be reflected in the output. For example,
inside ``posts/`` or ``pages/`` and it will be reflected in the output. For example,
``posts/foo/bar.txt`` would produce ``output/posts/foo/bar.html``, assuming the slug is also ``bar``.

If you have ``PRETTY_URLS`` enabled, that would be ``output/posts/foo/bar/index.html``.
@@ -815,8 +815,8 @@ There are multiple configuration variables dedicated to each of the three taxono
* ``HIDDEN_TAGS``. ``HIDDEN_CATEGORIES`` to make some tags/categories invisible in lists
* ``POSTS_SECTION_FROM_META`` to use ``.. section:`` in posts instead of inferring paths from paths

Creating a Page (Story)
-----------------------
Creating a Page
---------------

Pages are the same as posts, except that:

@@ -825,7 +825,7 @@ Pages are the same as posts, except that:
* They use the ``story.tmpl`` template instead of ``post.tmpl`` by default

The default configuration expects the page's metadata and text files to be on the
``stories`` folder, but that can be changed (see ``PAGES`` option above).
``pages`` folder, but that can be changed (see ``PAGES`` option above).

You can create the page's files manually or use the ``new_post`` command
with the ``-p`` option, which will place the files in the folder that
@@ -2342,7 +2342,7 @@ the template file in Nikola's base theme for an example of how this works.
The list may fail to update in some cases, please run ``nikola build -a`` with
the appropriate path if this happens.

We recommend using stories with dates in the past (1970-01-01) to avoid
We recommend using pages with dates in the past (1970-01-01) to avoid
dependency issues.

If you are using this as a shortcode, flags (``reverse``, ``all``) are meant to be used
@@ -88,7 +88,7 @@ category_rss


filename
Link to post or story by source filename.
Link to post or page by source filename.

Example:

@@ -287,6 +287,7 @@ List of page kinds provided by default plugins:
* list, tag_page
* list, tags_page
* post_page
* page_page
* story_page
* listing
* generic_page
@@ -820,13 +820,13 @@ COMMENT_SYSTEM_ID = ${COMMENT_SYSTEM_ID}
# the "noannotations" metadata.
# ANNOTATIONS = False

# Create index.html for page (story) folders?
# Create index.html for page folders?
# WARNING: if a page would conflict with the index file (usually
# caused by setting slug to `index`), the STORY_INDEX
# caused by setting slug to `index`), the PAGE_INDEX
# will not be generated for that directory.
# STORY_INDEX = False
# Enable comments on story pages?
# COMMENTS_IN_STORIES = False
# PAGE_INDEX = False
# Enable comments on pages (i.e. not posts)?
# COMMENTS_IN_PAGES = False
# Enable comments on picture gallery pages?
# COMMENTS_IN_GALLERIES = False

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -6,13 +6,13 @@ docs/sphinx/manual.txt
docs/sphinx/path_handlers.txt
docs/sphinx/social_buttons.txt
docs/sphinx/theming.txt
nikola/data/samplesite/stories/creating-a-theme.rst
nikola/data/samplesite/stories/extending.txt
nikola/data/samplesite/stories/internals.txt
nikola/data/samplesite/stories/manual.rst
nikola/data/samplesite/stories/path_handlers.txt
nikola/data/samplesite/stories/social_buttons.txt
nikola/data/samplesite/stories/theming.rst
nikola/data/samplesite/pages/creating-a-theme.rst
nikola/data/samplesite/pages/extending.txt
nikola/data/samplesite/pages/internals.txt
nikola/data/samplesite/pages/manual.rst
nikola/data/samplesite/pages/path_handlers.txt
nikola/data/samplesite/pages/social_buttons.txt
nikola/data/samplesite/pages/theming.rst
nikola/data/symlink-test-link.txt
nikola/data/themes/base/assets/js/moment-with-locales.min.js
nikola/data/themes/base/messages/messages_cz.py
@@ -448,7 +448,7 @@ def __init__(self, **config):
'CODE_COLOR_SCHEME': 'default',
'COMMENT_SYSTEM': 'disqus',
'COMMENTS_IN_GALLERIES': False,
'COMMENTS_IN_STORIES': False,
'COMMENTS_IN_PAGES': False,
'COMPILERS': {
"rest": ('.txt', '.rst'),
"markdown": ('.md', '.mdown', '.markdown'),
@@ -530,6 +530,7 @@ def __init__(self, **config):
'POSTS_SECTION_NAME': "",
'POSTS_SECTION_TITLE': "{name}",
'PRESERVE_EXIF_DATA': False,
# TODO: change in v8
'PAGES': (("stories/*.txt", "stories", "story.tmpl"),),
'PANDOC_OPTIONS': [],
'PRETTY_URLS': False,
@@ -556,7 +557,7 @@ def __init__(self, **config):
'SLUG_TAG_PATH': True,
'SOCIAL_BUTTONS_CODE': '',
'SITE_URL': 'https://example.com/',
'STORY_INDEX': False,
'PAGE_INDEX': False,
'STRIP_INDEXES': False,
'SITEMAP_INCLUDE_FILELESS_DIRS': True,
'TAG_PATH': 'categories',
@@ -733,7 +734,7 @@ def __init__(self, **config):
# TODO: remove on v8
if 'RSS_LINKS_APPEND_QUERY' in config:
utils.LOGGER.warn('The RSS_LINKS_APPEND_QUERY option is deprecated, use FEED_LINKS_APPEND_QUERY instead.')
if 'FEED_TEASERS' in config:
if 'FEED_LINKS_APPEND_QUERY' in config:
utils.LOGGER.warn('FEED_LINKS_APPEND_QUERY conflicts with RSS_LINKS_APPEND_QUERY, ignoring RSS_LINKS_APPEND_QUERY.')
self.config['FEED_LINKS_APPEND_QUERY'] = config['RSS_LINKS_APPEND_QUERY']

@@ -870,6 +871,15 @@ def __init__(self, **config):
utils.LOGGER.warn("WRITE_TAG_CLOUD is not set in your config. Defaulting to True (== writing tag_cloud_data.json).")
utils.LOGGER.warn("Please explicitly add the setting to your conf.py with the desired value, as the setting will default to False in the future.")

# Rename stories to pages (#1891, #2518)
# TODO: remove in v8
if 'COMMENTS_IN_STORIES' in config:
utils.LOGGER.warn('The COMMENTS_IN_STORIES option is deprecated, use COMMENTS_IN_PAGES instead.')
self.config['COMMENTS_IN_PAGES'] = config['COMMENTS_IN_STORIES']
if 'STORY_INDEX' in config:
utils.LOGGER.warn('The STORY_INDEX option is deprecated, use PAGE_INDEX instead.')
self.config['PAGE_INDEX'] = config['STORY_INDEX']

# We use one global tzinfo object all over Nikola.
try:
self.tzinfo = dateutil.tz.gettz(self.config['TIMEZONE'])
@@ -1640,8 +1650,8 @@ def path(self, kind, name, lang=None, is_link=False):
* gallery (name is the gallery name)
* listing (name is the source code file name)
* post_path (name is 1st element in a POSTS/PAGES tuple)
* slug (name is the slug of a post or story)
* filename (name is the source filename of a post/story, in DEFAULT_LANG, relative to conf.py)
* slug (name is the slug of a post or page)
* filename (name is the source filename of a post/page, in DEFAULT_LANG, relative to conf.py)
The returned value is always a path relative to output, like
"categories/whatever.html"
@@ -1714,7 +1724,7 @@ def slug_path(self, name, lang):
return [_f for _f in results[0].permalink(lang).split('/') if _f]

def filename_path(self, name, lang):
"""Link to post or story by source filename.
"""Link to post or page by source filename.
Example:
@@ -2059,7 +2069,7 @@ def generic_page_renderer(self, lang, post, filters, context=None):
if post.use_in_feeds:
context['enable_comments'] = True
else:
context['enable_comments'] = self.config['COMMENTS_IN_STORIES']
context['enable_comments'] = self.config['COMMENTS_IN_PAGES']

deps_dict = {}
if post.prev_post:
@@ -425,7 +425,7 @@ def process_data(self):
"""Go through self.items and save them."""

def import_story(self):
"""Create a story."""
"""Create a page."""
raise NotImplementedError()

def import_post(self):
@@ -482,7 +482,7 @@ def populate_context(self, channel):
PAGES = '(\n'
for extension in extensions:
POSTS += ' ("posts/*.{0}", "posts", "post.tmpl"),\n'.format(extension)
PAGES += ' ("stories/*.{0}", "stories", "story.tmpl"),\n'.format(extension)
PAGES += ' ("pages/*.{0}", "pages", "story.tmpl"),\n'.format(extension)
POSTS += ')\n'
PAGES += ')\n'
context['POSTS'] = POSTS
@@ -1098,7 +1098,7 @@ def process_item_if_post_or_page(self, item):
if post_type == 'post':
out_folder_slug = self.import_postpage_item(item, wordpress_namespace, 'posts', attachments)
else:
out_folder_slug = self.import_postpage_item(item, wordpress_namespace, 'stories', attachments)
out_folder_slug = self.import_postpage_item(item, wordpress_namespace, 'pages', attachments)
# Process attachment data
if attachments is not None:
# If post was exported, store data
@@ -78,9 +78,9 @@
("posts/*.html", "posts", "post.tmpl"),
)""",
'PAGES': """(
("stories/*.rst", "stories", "story.tmpl"),
("stories/*.txt", "stories", "story.tmpl"),
("stories/*.html", "stories", "story.tmpl"),
("pages/*.rst", "pages", "story.tmpl"),
("pages/*.txt", "pages", "story.tmpl"),
("pages/*.html", "pages", "story.tmpl"),
)""",
'COMPILERS': """{
"rest": ('.rst', '.txt'),
@@ -285,7 +285,7 @@ def create_configuration_to_string():
@classmethod
def create_empty_site(cls, target):
"""Create an empty site with directories only."""
for folder in ('files', 'galleries', 'listings', 'posts', 'stories'):
for folder in ('files', 'galleries', 'listings', 'posts', 'pages'):
makedirs(os.path.join(target, folder))

@staticmethod
@@ -203,7 +203,7 @@ def cat_path(i, displayed_i, num_pages, force_addition, extension=None):
}
yield task

if not self.site.config["STORY_INDEX"]:
if not self.site.config["PAGE_INDEX"]:
return
kw = {
"translations": self.site.config['TRANSLATIONS'],
@@ -242,7 +242,7 @@ def cat_path(i, displayed_i, num_pages, force_addition, extension=None):

for post in post_list:
# If there is an index.html pending to be created from
# a story, do not generate the STORY_INDEX
# a page, do not generate the PAGE_INDEX
if post.destination_path(lang) == short_destination:
should_render = False
else:
@@ -54,7 +54,7 @@ def gen_tasks(self):
if post.is_post:
context = {'pagekind': ['post_page']}
else:
context = {'pagekind': ['story_page']}
context = {'pagekind': ['story_page', 'page_page']}
for task in self.site.generic_page_renderer(lang, post, kw["filters"], context):
task['uptodate'] = task['uptodate'] + [config_changed(kw, 'nikola.plugins.task.pages')]
task['basename'] = self.name
@@ -168,7 +168,7 @@ def __init__(
self.data[lang] = utils.load_data(self.meta[lang]['data'])

if 'date' not in default_metadata and not use_in_feeds:
# For stories we don't *really* need a date
# For pages we don't *really* need a date
if self.config['__invariant__']:
default_metadata['date'] = datetime.datetime(2013, 12, 31, 23, 59, 59, tzinfo=tzinfo)
else:
@@ -1362,10 +1362,10 @@ def get_translation_candidate(config, path, lang):
cache/posts/fancy.post.html
>>> print(get_translation_candidate(config, 'cache/posts/fancy.post.html', 'es'))
cache/posts/fancy.post.es.html
>>> print(get_translation_candidate(config, 'cache/stories/charts.html', 'es'))
cache/stories/charts.es.html
>>> print(get_translation_candidate(config, 'cache/stories/charts.html', 'en'))
cache/stories/charts.html
>>> print(get_translation_candidate(config, 'cache/pages/charts.html', 'es'))
cache/pages/charts.es.html
>>> print(get_translation_candidate(config, 'cache/pages/charts.html', 'en'))
cache/pages/charts.html
>>> config = {'TRANSLATIONS_PATTERN': '{path}.{ext}.{lang}', 'DEFAULT_LANG': 'en', 'TRANSLATIONS': {'es':'1', 'en': 1}}
>>> print(get_translation_candidate(config, '*.rst', 'es'))
@@ -17,7 +17,7 @@ fi
nikola init -qd nikola-baseline-build
cd nikola-baseline-build
cp ../tests/data/1-nolinks.rst posts/1.rst
rm "stories/creating-a-theme.rst" "stories/extending.txt" "stories/internals.txt" "stories/manual.rst" "stories/social_buttons.txt" "stories/theming.rst" "stories/path_handlers.txt" "stories/charts.txt"
rm "pages/creating-a-theme.rst" "pages/extending.txt" "pages/internals.txt" "pages/manual.rst" "pages/social_buttons.txt" "pages/theming.rst" "pages/path_handlers.txt" "pages/charts.txt"
LC_ALL='en_US.UTF-8' PYTHONHASHSEED=0 nikola build --invariant
if [[ "$1" == "check" ]]; then
echo -e "\033[36m>> Testing baseline...\033[0m"
@@ -141,8 +141,8 @@
("posts/*.txt", "posts", "post.tmpl"),
)
PAGES = (
("stories/*.rst", "stories", "story.tmpl"),
("stories/*.txt", "stories", "story.tmpl"),
("pages/*.rst", "pages", "story.tmpl"),
("pages/*.txt", "pages", "story.tmpl"),
)

# One or more folders containing files to be copied as-is into the output.
@@ -436,10 +436,10 @@
# the "noannotations" metadata.
# ANNOTATIONS = False

# Create index.html for story folders?
# STORY_INDEX = False
# Enable comments on story pages?
# COMMENTS_IN_STORIES = False
# Create index.html for page folders?
# PAGE_INDEX = False
# Enable comments on page pages?
# COMMENTS_IN_PAGES = False
# Enable comments on picture gallery pages?
# COMMENTS_IN_GALLERIES = False

File renamed without changes.
File renamed without changes.

0 comments on commit 398a724

Please sign in to comment.