Skip to content

Commit 030b78b

Browse files
committedJul 1, 2016
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.
1 parent 3235300 commit 030b78b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed
 

‎v7/projectpages/README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ Why use a plugin?
1919
Usage
2020
-----
2121

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

24-
("projects/*.rst", "projects", "project.tmpl")
25+
PROJECT_PATH = 'projects'
2526

26-
2. Create a setting named `PROJECT_PATH` pointing at the directory:
27+
2. Create an entry in `PAGES` for a special path, eg.
2728

28-
PROJECT_PATH = 'projects'
29+
("projects/*.rst", "projects", "project.tmpl")
2930

3031
3. Create project pages in reStructuredText (or any other supported markup language).
3132
4. Optionally create your own templates (some are provided with the plugin).

‎v7/projectpages/projectpages.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ class ProjectPages(Task):
4040

4141
def set_site(self, site):
4242
site.register_path_handler('project', self.project_path)
43-
site._GLOBAL_CONTEXT['project_path'] = site.config['PROJECT_PATH']
43+
project_path = site.config.get('PROJECT_PATH', 'projects')
44+
site._GLOBAL_CONTEXT['project_path'] = project_path
4445
site._GLOBAL_CONTEXT['project_index'] = {}
4546
for lang, tpath in site.config['TRANSLATIONS'].items():
46-
site._GLOBAL_CONTEXT['project_index'][lang] = '/' + os.path.join(tpath, site.config['PROJECT_PATH'], site.config['INDEX_FILE']).replace('\\', '/')
47+
site._GLOBAL_CONTEXT['project_index'][lang] = '/' + os.path.join(tpath, project_path, site.config['INDEX_FILE']).replace('\\', '/')
4748

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

0 commit comments

Comments
 (0)
Please sign in to comment.