Skip to content

Commit

Permalink
Add support for sub-directory URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Sep 28, 2016
1 parent 8ad6348 commit fbeff88
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 11 deletions.
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source 'https://rubygems.org'

gem 'jekyll', '3.1.6'

group :jekyll_plugins do
gem 'jekyll-github-metadata'
end
49 changes: 49 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.4.0)
colorator (0.1)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.14)
jekyll (3.1.6)
colorator (~> 0.1)
jekyll-sass-converter (~> 1.0)
jekyll-watch (~> 1.1)
kramdown (~> 1.3)
liquid (~> 3.0)
mercenary (~> 0.3.3)
rouge (~> 1.7)
safe_yaml (~> 1.0)
jekyll-github-metadata (2.0.2)
jekyll (~> 3.1)
octokit (~> 4.0)
jekyll-sass-converter (1.4.0)
sass (~> 3.4)
jekyll-watch (1.5.0)
listen (~> 3.0, < 3.1)
kramdown (1.12.0)
liquid (3.0.6)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
mercenary (0.3.6)
multipart-post (2.0.0)
octokit (4.3.0)
sawyer (~> 0.7.0, >= 0.5.3)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
rouge (1.11.1)
safe_yaml (1.0.4)
sass (3.4.22)
sawyer (0.7.0)
addressable (>= 2.3.5, < 2.5)
faraday (~> 0.8, < 0.10)

PLATFORMS
ruby

DEPENDENCIES
jekyll (= 3.1.6)
jekyll-github-metadata
13 changes: 11 additions & 2 deletions _layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@
---
<!DOCTYPE html>
<html lang="en">

{% if jekyll.environment == 'development' %}
{% assign baseUrl = '' %}
{% else %}
{% assign baseUrl = site.github.url | default: 'site.url' %}
{% assign baseUrl = baseUrl | replace: 'http://', '//' %}
{% endif %}

<head>
{% include meta.html %}

<link rel="stylesheet" type="text/css" href="/css/main.css">
<link rel="stylesheet" type="text/css" href="{{ baseUrl }}/css/main.css">
</head>
<body>
<div id="root"></div>

{% capture currentProfile %}{% include getCurrentProfile %}{% endcapture %}

<script>window.BASE_URL = {{ baseUrl | jsonify }}</script>
<script>window.PROFILES = {% include listAllProfiles %}</script>
<script>window.TESTS = {% include listProfileTests profile=currentProfile %}</script>
<script src="/bundle.js"></script>
<script src="{{ baseUrl }}/bundle.js"></script>
</body>
</html>
8 changes: 6 additions & 2 deletions app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class App extends React.Component {
results: null,
tests: window.TESTS
}

this.baseUrl = window.BASE_URL || ''
}

_fetchData(dateFrom, dateTo) {
Expand All @@ -44,10 +46,12 @@ class App extends React.Component {
const year = test.toString().slice(0, 4)
const month = test.toString().slice(4, 6)

const path = `/results/${this.state.profile.slug}/${year}/${month}.json`
const path = `${this.baseUrl}/results/${this.state.profile.slug}/${year}/${month}.json`

return fetch(path).then(response => {
return response.json()
}).catch(err => {
console.log('** ERR:', err)
})
})

Expand Down Expand Up @@ -90,7 +94,7 @@ class App extends React.Component {

window.history.pushState(null, null, `/${newProfile}/?period=${this.state.period}`)

fetch('/profiles.json').then(response => {
fetch(`${this.baseUrl}/profiles.json`).then(response => {
return response.json()
}).then(profiles => {
const profile = profiles.find(profile => profile.slug === newProfile)
Expand Down
14 changes: 7 additions & 7 deletions bundle.js

Large diffs are not rendered by default.

0 comments on commit fbeff88

Please sign in to comment.