1
Fork 0

Add links to context

This commit is contained in:
Jake Howard 2016-04-08 21:34:08 +01:00
parent 49430bc950
commit 80b41336b7
3 changed files with 26 additions and 11 deletions

4
data/links.yml Normal file
View file

@ -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

View file

@ -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

View file

@ -18,13 +18,13 @@
<div class="row">
<div class="col-xs-12">
<p class="social">
<a href="https://twitter.com/RealOrangeOne"><i class="icon ion-social-twitter"></i></a>
<a href="https://instagram.com/RealOrangeOne"><i class="icon ion-social-instagram-outline"></i></a>
<a href="{{ links.twitter }}"><i class="icon ion-social-twitter"></i></a>
<a href="{{ links.instagram }}"><i class="icon ion-social-instagram-outline"></i></a>
<a href="soon"><i class="icon ion-social-reddit"></i></a>
<a href="https://www.youtube.com/user/TheOrangeOneOfficial"><i class="icon ion-social-youtube"></i></a>
<a href="{{ links.youtube }}"><i class="icon ion-social-youtube"></i></a>
<a href="soon"><i class="icon ion-social-codepen"></i></a>
<a href="soon"><i class="icon ion-social-twitch-outline"></i></a>
<a href="https://github.com/RealOrangeOne"><i class="icon ion-social-octocat"></i></a>
<a href="{{ links.github }}"><i class="icon ion-social-octocat"></i></a>
</p>
</div>
</div>
@ -32,8 +32,8 @@
<div class="col-xs-12">
<p class="triple">
<a href="/about/">About</a> |
<a href="https://github.com/RealOrangeOne/theorangeone.net" target="_blank">View Source</a> |
<a href="">Contact</a>
<a href="{{ links.github }}/theorangeone.net" target="_blank">View Source</a>
<p>
</div>
</div>