diff --git a/data/links.yml b/data/links.yml new file mode 100644 index 0000000..279b7d1 --- /dev/null +++ b/data/links.yml @@ -0,0 +1,4 @@ +github: https://github.com/RealOrangeOne +twitter: https://twitter.com/RealOrangeOne +instagram: https://instagram.com/RealOrangeOne +youtube: https://www.youtube.com/user/TheOrangeOneOfficial diff --git a/project/common/data.py b/project/common/data.py index 596510d..8e4597f 100644 --- a/project/common/data.py +++ b/project/common/data.py @@ -4,17 +4,27 @@ from glob import glob from project.pages.utils import get_title_from_markdown, parse_content -def generate_config(base_dir): - default = yaml.load(open(os.path.join(base_dir, 'data/context.yml'))) or {} - page = yaml.load(open(os.path.join(base_dir, 'data/page_context.yml'))) or {} - switcher = yaml.load(open(os.path.join(base_dir, 'data/path_switch.yml'))) or {} +def get_data_from_file(base_dir, filename): + with open(os.path.join(base_dir, 'data', filename)) as data_file: + return yaml.load(data_file) or {} + +def generate_config(base_dir): + default = get_data_from_file(base_dir, 'context.yml') + page = get_data_from_file(base_dir, 'page_context.yml') + switcher = get_data_from_file(base_dir, 'path_switch.yml') + + # Add projects config default['projects'] = generate_projects(base_dir) + # Join projects config with it's page context for i in range(len(default['projects'])): project = default['projects'][i] if project['path'] in page: # If there's a custom config default['projects'][i] = dict(project, **page[project['path']]) - default['projects'][i]['url'] = '/' + project['path'] + + # Add links config + default['links'] = get_data_from_file(base_dir, 'links.yml') + return default, page, switcher @@ -33,6 +43,7 @@ def generate_projects(base_dir): filename = filename.split('.')[0] files.append({ "name": filename, - "path": 'projects' + path.replace(projects_path, '').split('.')[0] + "path": 'projects' + path.replace(projects_path, '').split('.')[0], + "url": '/projects' + path.replace(projects_path, '').split('.')[0], }) return files diff --git a/templates/base.html b/templates/base.html index 84a2338..eb251e3 100644 --- a/templates/base.html +++ b/templates/base.html @@ -18,13 +18,13 @@
@@ -32,8 +32,8 @@

About | - View Source | Contact + View Source