Skip to content

Commit

Permalink
Use a default directory for projects
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
punchagan committed Jul 1, 2016
1 parent 3235300 commit 030b78b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions v7/projectpages/README.md
Expand Up @@ -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 a special path, 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).
Expand Down
5 changes: 3 additions & 2 deletions v7/projectpages/projectpages.py
Expand Up @@ -40,10 +40,11 @@ class ProjectPages(Task):

def set_site(self, site):
site.register_path_handler('project', self.project_path)
site._GLOBAL_CONTEXT['project_path'] = site.config['PROJECT_PATH']
project_path = site.config.get('PROJECT_PATH', 'projects')
site._GLOBAL_CONTEXT['project_path'] = 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, project_path, site.config['INDEX_FILE']).replace('\\', '/')

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

Expand Down

0 comments on commit 030b78b

Please sign in to comment.