Add links to context
This commit is contained in:
parent
49430bc950
commit
80b41336b7
3 changed files with 26 additions and 11 deletions
4
data/links.yml
Normal file
4
data/links.yml
Normal 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
|
|
@ -4,17 +4,27 @@ from glob import glob
|
||||||
from project.pages.utils import get_title_from_markdown, parse_content
|
from project.pages.utils import get_title_from_markdown, parse_content
|
||||||
|
|
||||||
|
|
||||||
def generate_config(base_dir):
|
def get_data_from_file(base_dir, filename):
|
||||||
default = yaml.load(open(os.path.join(base_dir, 'data/context.yml'))) or {}
|
with open(os.path.join(base_dir, 'data', filename)) as data_file:
|
||||||
page = yaml.load(open(os.path.join(base_dir, 'data/page_context.yml'))) or {}
|
return yaml.load(data_file) or {}
|
||||||
switcher = yaml.load(open(os.path.join(base_dir, 'data/path_switch.yml'))) 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)
|
default['projects'] = generate_projects(base_dir)
|
||||||
|
# Join projects config with it's page context
|
||||||
for i in range(len(default['projects'])):
|
for i in range(len(default['projects'])):
|
||||||
project = default['projects'][i]
|
project = default['projects'][i]
|
||||||
if project['path'] in page: # If there's a custom config
|
if project['path'] in page: # If there's a custom config
|
||||||
default['projects'][i] = dict(project, **page[project['path']])
|
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
|
return default, page, switcher
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +43,7 @@ def generate_projects(base_dir):
|
||||||
filename = filename.split('.')[0]
|
filename = filename.split('.')[0]
|
||||||
files.append({
|
files.append({
|
||||||
"name": filename,
|
"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
|
return files
|
||||||
|
|
|
@ -18,13 +18,13 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<p class="social">
|
<p class="social">
|
||||||
<a href="https://twitter.com/RealOrangeOne"><i class="icon ion-social-twitter"></i></a>
|
<a href="{{ links.twitter }}"><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.instagram }}"><i class="icon ion-social-instagram-outline"></i></a>
|
||||||
<a href="soon"><i class="icon ion-social-reddit"></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-codepen"></i></a>
|
||||||
<a href="soon"><i class="icon ion-social-twitch-outline"></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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,8 +32,8 @@
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<p class="triple">
|
<p class="triple">
|
||||||
<a href="/about/">About</a> |
|
<a href="/about/">About</a> |
|
||||||
<a href="https://github.com/RealOrangeOne/theorangeone.net" target="_blank">View Source</a> |
|
|
||||||
<a href="">Contact</a>
|
<a href="">Contact</a>
|
||||||
|
<a href="{{ links.github }}/theorangeone.net" target="_blank">View Source</a>
|
||||||
<p>
|
<p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in a new issue