-
-
View Source
+
+ {% for key, account in ACCOUNTS.items() %}
+
+ {% endfor %}
+
diff --git a/content/pages/contact.html b/content/pages/contact.html
new file mode 100644
index 0000000..4b5de2c
--- /dev/null
+++ b/content/pages/contact.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+ The fastest way to contact me is through twitter. Just tag me or send me a message and I'll respond as soon as possible!
+
+
+
+
+
+
Need something more formal?
+
+ If you need to contact me in a more formal capacity, send me an email! I aim to respond to all emails within 3 days.
+
+
+
+
+
diff --git a/pelicanconf.py b/pelicanconf.py
index e3e5a2f..5525d61 100644
--- a/pelicanconf.py
+++ b/pelicanconf.py
@@ -7,6 +7,7 @@ sys.path.insert(0, os.path.realpath('./'))
AUTHOR = "Jake Howard"
SITENAME = "TheOrangeOne"
SITEURL = "https://theorangeone.net"
+CONTACT_EMAIL = "info@theorangeone.net"
PATH = 'content'
TIMEZONE = "Europe/London"
DEFAULT_LANG = "en"
@@ -111,7 +112,8 @@ JINJA_FILTERS = {
"limit": filters.limit,
"get_title": filters.get_title,
"get_html_title": filters.get_html_title,
- "get_image": filters.get_image
+ "get_image": filters.get_image,
+ "encode_text": filters.encode_text
}
JINJA_ENVIRONMENT = {
diff --git a/plugins/filters.py b/plugins/filters.py
index 402954d..d61bbfb 100644
--- a/plugins/filters.py
+++ b/plugins/filters.py
@@ -39,3 +39,7 @@ def get_html_title(instance):
def get_image(instance):
return get_attribute(instance, 'image') or (hasattr(instance, 'page') and get_attribute(instance.page, 'name')) or ''
+
+
+def encode_text(text):
+ return " ".join([str(ord(c)) for c in text])
diff --git a/tests/__init__.py b/tests/__init__.py
index 1b8d62f..fb9ff31 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -9,7 +9,7 @@ class TestClient:
def get(self, path, JS=True):
file_path = self.build_path(path)
content = "".join(open(file_path).readlines())
- if path.endswith('html'):
+ if file_path.endswith('html'):
content = BeautifulSoup(content, 'html.parser')
if JS:
for script in content(["noscript"]): # Remove noscript tags
@@ -19,6 +19,8 @@ class TestClient:
def build_path(self, path):
if path.startswith('/'):
path = path[1:]
+ if path.endswith('/'):
+ path += 'index.html'
return os.path.join(self.output_path, path)
def exists(self, path):
diff --git a/tests/tests_common.py b/tests/tests_common.py
index b935074..2713db2 100644
--- a/tests/tests_common.py
+++ b/tests/tests_common.py
@@ -96,5 +96,11 @@ class TestClientTestCase(TestCase):
def test_file_exists(self):
self.assertTrue(self.client.exists('index.html'))
+ def test_build_path_without_index(self):
+ self.assertEqual(
+ self.client.build_path('foo/'),
+ self.client.build_path('foo/index.html')
+ )
+
def test_file_doesnt_exist(self):
self.assertFalse(self.client.exists('foo.bar'))
diff --git a/tests/tests_pages.py b/tests/tests_pages.py
index 2afd2ae..a54d339 100644
--- a/tests/tests_pages.py
+++ b/tests/tests_pages.py
@@ -1,5 +1,6 @@
from tests import TestCase
from config import social as social_settings
+import pelicanconf as settings
import os.path
@@ -47,18 +48,6 @@ class AboutPageTestCase(TestCase):
self.assertHeaderTitle(content, 'About')
self.assertTitle(content, 'About')
- def test_website_section(self):
- content = self.client.get('about/index.html')
- section = content.find('section', id='website')
- subtitle = section.find('h2')
- self.assertEqual('Website', self.get_children(subtitle))
-
- def test_server_section(self):
- content = self.client.get('about/index.html')
- section = content.find('section', id='server')
- subtitle = section.find('h2')
- self.assertEqual('Server', self.get_children(subtitle))
-
def test_github_card(self):
content = self.client.get('about/index.html')
tags = content.find_all('div', class_='github-card')
@@ -67,6 +56,33 @@ class AboutPageTestCase(TestCase):
self.assertEqual('medium', tag.attrs['data-theme'])
self.assertEqual(social_settings['accounts']['github'][1], tag.attrs['data-github'])
+ def test_accounts(self):
+ content = self.client.get('about/index.html')
+ accounts = content.find_all('div', class_='account')
+ defined_accounts = [s for k, s in settings.ACCOUNTS.items()]
+ self.assertEqual(len(accounts), len(defined_accounts))
+ site_names = [s['site'] for s in defined_accounts]
+ urls = [s['url'] for s in defined_accounts]
+ icons = [s['icon'] for s in defined_accounts]
+ for account in accounts:
+ self.assertIn(account.find('a').attrs['href'], urls)
+ self.assertIn(account.find('i').attrs['class'][-1], icons)
+ self.assertIn(self.get_children(account.find('h3')), site_names)
+
+
+class ContactPageTestCase(TestCase):
+ def test_title(self):
+ content = self.client.get('contact/')
+ self.assertHeaderTitle(content, 'Contact Me')
+ self.assertTitle(content, 'Contact Me')
+
+ def test_contact_links(self):
+ content = self.client.get('contact/')
+ links = content.find_all('section')[2].find_all('a')
+ self.assertEqual(links[1].attrs['href'], settings.ACCOUNTS['twitter']['url'])
+ decoded_value = ''.join([chr(int(c)) for c in links[0].attrs['data-value'].split(' ')])
+ self.assertEqual(decoded_value, settings.CONTACT_EMAIL)
+
class Page404TestCase(TestCase):
def test_title(self):
diff --git a/theme/static/src/js/app.js b/theme/static/src/js/app.js
index df81682..3b86b80 100644
--- a/theme/static/src/js/app.js
+++ b/theme/static/src/js/app.js
@@ -30,3 +30,14 @@ $('.navbar-brand').bind('click', function (event) {
}
event.preventDefault();
});
+
+
+$('.protected-mailto').bind('click', function (evt) {
+ evt.preventDefault();
+ var char_codes = $(this).data('value').split(' ');
+ var plain_text = [];
+ for (var i = 0; i < char_codes.length; i++) {
+ plain_text.push(String.fromCharCode(parseInt(char_codes[i], 10)));
+ }
+ window.location = 'mailto:' + plain_text.join('');
+});
diff --git a/theme/static/src/scss/functional.scss b/theme/static/src/scss/functional.scss
index 58c9665..3d4f6a2 100644
--- a/theme/static/src/scss/functional.scss
+++ b/theme/static/src/scss/functional.scss
@@ -16,3 +16,7 @@
padding: 0 $grid-gutter-width / 2;
}
+
+a.no-underline:hover {
+ text-decoration: inherit;
+}
diff --git a/theme/static/src/scss/index.scss b/theme/static/src/scss/index.scss
index 1b958f4..48f3735 100644
--- a/theme/static/src/scss/index.scss
+++ b/theme/static/src/scss/index.scss
@@ -110,3 +110,13 @@ header#header {
.github-card-container > iframe {
max-width: 100%;
}
+
+.protected-mailto {
+ cursor: pointer;
+}
+
+.service-box.account {
+ a:hover {
+ color: $brand-orange-dark;
+ }
+}