Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getnikola/plugins
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3235300b3f52
Choose a base ref
...
head repository: getnikola/plugins
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1a34ebebe8a0
Choose a head ref
  • 3 commits
  • 3 files changed
  • 2 contributors

Commits on Jul 1, 2016

  1. Use a default directory for projects

    Installing the plugin and running any Nikola command before setting the
    PROJECT_PATH causes errors.
    
    Also, having a default value for projects is more convenient and in-line
    with the defaults we have for posts and pages.
    punchagan committed Jul 1, 2016
    Copy the full SHA
    030b78b View commit details
  2. Merge pull request #155 from getnikola/projects-default-dir

    Use a default directory for projects
    Kwpolska committed Jul 1, 2016

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    86d2ab7 View commit details
  3. Use the correct project directory everywhere

    Signed-off-by: Chris Warrick <kwpolska@gmail.com>
    Kwpolska committed Jul 1, 2016

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1a34ebe View commit details
Showing with 14 additions and 9 deletions.
  1. +5 −4 v7/projectpages/README.md
  2. +1 −1 v7/projectpages/projectpages.plugin
  3. +8 −4 v7/projectpages/projectpages.py
9 changes: 5 additions & 4 deletions v7/projectpages/README.md
Original file line number Diff line number Diff line change
@@ -19,13 +19,14 @@ Why use a plugin?
Usage
-----

1. Create an entry in `PAGES` for a special path, eg.
1. `projects` directory is the default directory for projects. You can change
this by setting `PROJECT_PATH` to a different value:

("projects/*.rst", "projects", "project.tmpl")
PROJECT_PATH = 'projects'

2. Create a setting named `PROJECT_PATH` pointing at the directory:
2. Create an entry in `PAGES` for your project directory, eg.

PROJECT_PATH = 'projects'
("projects/*.rst", "projects", "project.tmpl")

3. Create project pages in reStructuredText (or any other supported markup language).
4. Optionally create your own templates (some are provided with the plugin).
2 changes: 1 addition & 1 deletion v7/projectpages/projectpages.plugin
Original file line number Diff line number Diff line change
@@ -7,6 +7,6 @@ MinVersion = 7.1.0+

[Documentation]
Author = Chris Warrick
Version = 0.1.8
Version = 0.1.9
Website = https://chriswarrick.com/projects/
Description = Generate project pages
12 changes: 8 additions & 4 deletions v7/projectpages/projectpages.py
Original file line number Diff line number Diff line change
@@ -37,13 +37,16 @@ class ProjectPages(Task):

name = 'projectpages'
dates = {}
conf_project_path = 'projects'

def set_site(self, site):
"""Set Nikola site."""
site.register_path_handler('project', self.project_path)
site._GLOBAL_CONTEXT['project_path'] = site.config['PROJECT_PATH']
self.conf_project_path = site.config.get('PROJECT_PATH', 'projects')
site._GLOBAL_CONTEXT['project_path'] = self.conf_project_path
site._GLOBAL_CONTEXT['project_index'] = {}
for lang, tpath in site.config['TRANSLATIONS'].items():
site._GLOBAL_CONTEXT['project_index'][lang] = '/' + os.path.join(tpath, site.config['PROJECT_PATH'], site.config['INDEX_FILE']).replace('\\', '/')
site._GLOBAL_CONTEXT['project_index'][lang] = '/' + os.path.join(tpath, self.conf_project_path, site.config['INDEX_FILE']).replace('\\', '/')

# If you want to use breadcrumbs as provided by the crumbs template:

@@ -54,11 +57,12 @@ def set_site(self, site):
return super(ProjectPages, self).set_site(site)

def project_path(self, name, lang):
"""Generate links to project pages."""
return [_f for _f in self.projects[name].permalink(lang).split('/') if _f]

def is_project(self, p):
"""Test projecthood of a page."""
return p.destination_path(lang=self.kw['default_lang']).startswith(self.site.config['PROJECT_PATH'])
return p.destination_path(lang=self.kw['default_lang']).startswith(self.conf_project_path)

def find_projects(self):
"""Find all projects."""
@@ -93,7 +97,7 @@ def gen_tasks(self):
self.image_ext_list.extend(self.site.config.get('EXTRA_IMAGE_EXTENSIONS', []))

self.kw = {
'project_path': self.site.config['PROJECT_PATH'],
'project_path': self.conf_project_path,
'index_file': self.site.config['INDEX_FILE'],
'strip_indexes': self.site.config['STRIP_INDEXES'],
'output_folder': self.site.config['OUTPUT_FOLDER'],