Skip to content

Commit

Permalink
Allow relations between details entries
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-roesch committed Jul 16, 2020
1 parent a71ddc3 commit f0750d3
Show file tree
Hide file tree
Showing 16 changed files with 212 additions and 59 deletions.
10 changes: 3 additions & 7 deletions bin/dump-translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@
const fs = require('fs')

const events = JSON.parse(fs.readFileSync('./src/store/events.json', 'utf8'))
fs.mkdirSync(`./translations/en/events`, { recursive: true })
events.forEach((event) => {
const path = `./translations/en/events/${event.id}.md`

if (fs.existsSync(path)) {
return
}

let data = `# ${event.id}\nBlurb\n`

if (event.details) {
data += '\n## Details\nDetails\n'
}

fs.writeFileSync(path, data)
fs.writeFileSync(path, `# ${event.id}\nBlurb\n\n## Details\nDetails\n`)

console.log(`Created new translation file for event ${event.id}`)
})

function dump (type) {
const entries = JSON.parse(fs.readFileSync(`./src/store/${type}.json`, 'utf8'))
fs.mkdirSync(`./translations/en/${type}`, { recursive: true })
entries.forEach((entry) => {
const path = `./translations/en/${type}/${entry.id}.md`

Expand Down
Binary file added public/img/characters/taravangian.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default {
return
}
if (this.$route.name === 'event' && this.$route.params.id === newEvent.id) {
if (this.$route.name === 'events' && this.$route.params.id === newEvent.id) {
return
}
Expand All @@ -81,7 +81,7 @@ export default {
</script>

<style lang="scss">
@import url('https://fonts.googleapis.com/css2?family=Lora:wght@400;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&display=swap');
body {
margin: 0;
Expand All @@ -93,7 +93,7 @@ body {
}
#app {
font-family: 'Lora', serif;
font-family: 'Libre Baskerville', serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
position: absolute;
Expand All @@ -118,7 +118,7 @@ body {
}
button {
font-family: 'Lora', serif;
font-family: 'Libre Baskerville', serif;
}
.loading__fade {
Expand Down
167 changes: 163 additions & 4 deletions src/components/Details.vue

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/components/EventCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div
:class="[
'event-card',
{ 'event-card--image': event.image !== undefined, 'event-card--details-visible': $route.name === 'event' }
{ 'event-card--image': event.image !== undefined, 'event-card--details-visible': $route.name === 'events' }
]"
>
<div class="event-card__content">
Expand All @@ -19,7 +19,7 @@
:inline="true"
class="event-card__text"
>
<router-link v-if="event.details === true" :to="`/${$route.params.locale}/events/${event.id}`" class="event-card__read-more">
<router-link :to="`/${$route.params.locale}/events/${event.id}`" class="event-card__read-more">
Read more
</router-link>
</Markdown>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Scrubber.vue
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ export default {
font-size: 1em;
padding: 4px 0;
margin: 0;
font-family: 'Lora', serif;
font-family: 'Libre Baskerville', serif;
cursor: pointer;
outline: none;
overflow: hidden;
Expand Down
2 changes: 1 addition & 1 deletion src/components/editor/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ export default {
</script>

<style lang="scss">
@import url('https://fonts.googleapis.com/css2?family=Lora:wght@400;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&display=swap');
.editor {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/components/editor/EventPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default {
color: #242629;
transition: all 0.2s ease-in-out;
opacity: 1;
font-family: 'Lora', serif;
font-family: 'Libre Baskerville', serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
Expand Down
5 changes: 0 additions & 5 deletions src/components/editor/EventProperties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@

<label for="event-properties__id">ID</label>
<input id="event-properties__id" v-model="event.id" type="text">
<label for="event-properties__has-details">
<input id="event-properties__has-details" v-model="event.details" type="checkbox">

Has Details
</label>

<div class="event-properties__coordinates">
<h3>
Expand Down
2 changes: 1 addition & 1 deletion src/components/map/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default {
},
computed: {
activeLocation () {
return this.transitions && this.$route.name === 'location' ? this.$store.state.mappings.location[this.$route.params.id] : null
return this.transitions && this.$route.name === 'location' ? this.$store.state.mappings.locations[this.$route.params.id] : null
},
activeEvent () {
return this.transitions ? this.$store.state.activeEvent : null
Expand Down
12 changes: 4 additions & 8 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@ Vue.use(VueRouter)

const detailRoutes = [
{
name: 'event',
path: 'events',
name: 'events',
specialAction: event => store.commit('selectEvent', event)
},
{
name: 'location',
path: 'locations',
name: 'locations',
specialAction: () => store.commit('unselectEvent')
},
{
name: 'character',
path: 'characters',
name: 'characters',
specialAction: () => store.commit('unselectEvent')
},
{
name: 'misc',
path: 'misc',
specialAction: () => store.commit('unselectEvent')
}
]
Expand All @@ -35,7 +31,7 @@ const router = new VueRouter({
path: '/:locale',
children: detailRoutes.map(({ name, path, specialAction }) => ({
name,
path: `${path}/:id`,
path: `${name}/:id`,
meta: {
details: true
},
Expand Down
7 changes: 6 additions & 1 deletion src/store/characters.json
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
[ ]
[
{
"id": "taravangian",
"image": "taravangian.jpg"
}
]
38 changes: 19 additions & 19 deletions src/store/events.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"date": [
-6000
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 486.1,
"y": 317.6
Expand Down Expand Up @@ -122,7 +122,7 @@
"date": [
1139
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 720.9,
"y": 276.8
Expand All @@ -133,7 +133,7 @@
"date": [
1141
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 727,
"y": 304.8
Expand All @@ -144,7 +144,7 @@
"date": [
1145
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 738.7,
"y": 250.3
Expand All @@ -155,12 +155,11 @@
"date": [
1150
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 738.7,
"y": 250.3
},
"details": true
}
},
{
"id": "kaladin-birth",
Expand Down Expand Up @@ -203,7 +202,7 @@
"date": [
1162
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 734.7,
"y": 196.8
Expand All @@ -229,7 +228,7 @@
1166,
3
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 293.2,
"y": 263.9
Expand All @@ -241,7 +240,7 @@
1166,
8
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 754.2,
"y": 352.1
Expand All @@ -253,7 +252,7 @@
1166,
10
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 734.7,
"y": 196.8
Expand All @@ -265,7 +264,7 @@
1167,
9
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 627.5,
"y": 256.1
Expand All @@ -277,7 +276,7 @@
1167,
10
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 738.6,
"y": 250.3
Expand All @@ -289,7 +288,7 @@
1168,
7
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 484.9,
"y": 332.6
Expand All @@ -301,7 +300,7 @@
1168,
10
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 734.7,
"y": 196.8
Expand All @@ -320,7 +319,8 @@
"coordinates": {
"x": 484.5,
"y": 332.4
}
},
"related": [ "characters/taravangian", "locations/valley" ]
},
{
"id": "tien-death",
Expand Down Expand Up @@ -358,7 +358,7 @@
1172,
9
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 704.6,
"y": 208.8
Expand All @@ -370,7 +370,7 @@
1172,
10
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 627.5,
"y": 256.1
Expand All @@ -396,7 +396,7 @@
1173,
7
],
"tags": [],
"tags": [ ],
"coordinates": {
"x": 589.2,
"y": 286.3
Expand Down
8 changes: 4 additions & 4 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ events.forEach((event) => {

const mappings = {}

mappings.event = events.reduce((acc, event) => ({
mappings.events = events.reduce((acc, event) => ({
...acc,
[event.id]: { type: 'events', ...event }
}), {})

mappings.location = baseLocations.reduce((acc, location) => ({
mappings.locations = baseLocations.reduce((acc, location) => ({
...acc,
[location.id]: { type: 'locations', ...location }
}), {})

mappings.character = baseCharacters.reduce((acc, character) => ({
mappings.characters = baseCharacters.reduce((acc, character) => ({
...acc,
[character.id]: { type: 'characters', ...character }
}), {})
Expand All @@ -87,7 +87,7 @@ mappings.misc = baseMisc.reduce((acc, entry) => ({
[entry.id]: { type: 'misc', ...entry }
}), {})

const locationsByMapId = Object.values(mappings.location).filter(location => location.mapId !== undefined).reduce((acc, location) => ({
const locationsByMapId = Object.values(mappings.locations).filter(location => location.mapId !== undefined).reduce((acc, location) => ({
...acc,
[location.mapId]: location
}), {})
Expand Down
2 changes: 2 additions & 0 deletions translations/en/characters/taravangian.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# taravangian
Details
2 changes: 1 addition & 1 deletion translations/en/locations/valley.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Valley
# The Valley
Details

0 comments on commit f0750d3

Please sign in to comment.