-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dynamic pages that can be created from the backend (#96)
* Add modular pages to the website
- Loading branch information
1 parent
f4958ea
commit d5597f5
Showing
34 changed files
with
1,483 additions
and
1,350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Controller from '@ember/controller'; | ||
import saveModelMixin from "roboteam-website/mixins/save-model" | ||
import { computed } from '@ember/object' | ||
|
||
export default Controller.extend(saveModelMixin, { | ||
init() { | ||
this._super(...arguments); | ||
this.requiredProperties = ["title", "content", "page"]; | ||
}, | ||
noticeDuringSave: "Updating page item...", | ||
noticeAfterSave: "Page item updated!", | ||
modelName: "model", | ||
transitionAfterSuccess: "admin.page-item", | ||
transitionToIndexRoute: true, | ||
imagePath: "images/page/items", | ||
allPages: computed(function() { | ||
return this.store.findAll('page'); | ||
}), | ||
actions: { | ||
customSave: function() { | ||
if (this.get('file') || this.get('model.imageSrc')) { | ||
this.send('saveModelWithImage'); | ||
} else { | ||
this.send('saveModel'); | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Controller from '@ember/controller'; | ||
import removeModelAction from 'roboteam-website/mixins/remove-model-action'; | ||
import changeOrder from 'roboteam-website/mixins/change-order'; | ||
|
||
export default Controller.extend(removeModelAction, changeOrder, { | ||
modelType: "pageitem", | ||
modelNameProperty: "title", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import EditController from "roboteam-website/controllers/admin/page-item/edit"; | ||
|
||
export default EditController.extend({ }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Controller from '@ember/controller'; | ||
import saveModelMixin from "roboteam-website/mixins/save-model" | ||
|
||
export default Controller.extend(saveModelMixin, { | ||
init() { | ||
this._super(...arguments); | ||
this.requiredProperties = ["name", "description"]; | ||
}, | ||
noticeDuringSave: "Updating page...", | ||
noticeAfterSave: "Page updated!", | ||
modelName: "model", | ||
transitionAfterSuccess: "admin.page", | ||
transitionToIndexRoute: true, | ||
imagePath: "images/page", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Controller from '@ember/controller'; | ||
import removeModelAction from 'roboteam-website/mixins/remove-model-action'; | ||
import changeOrder from 'roboteam-website/mixins/change-order'; | ||
|
||
export default Controller.extend(removeModelAction, changeOrder, { | ||
modelType: "page", | ||
modelNameProperty: "name", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import EditController from "roboteam-website/controllers/admin/page/edit"; | ||
|
||
export default EditController.extend({ }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Controller from '@ember/controller'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default Controller.extend({ | ||
settings: service(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import DS from 'ember-data'; | ||
|
||
const { attr, Model } = DS; | ||
import { computed } from '@ember/object'; | ||
|
||
export default Model.extend({ | ||
createdAt: attr('date'), | ||
updatedAt: attr('date'), | ||
name: attr('string'), | ||
imageSrc: attr('string'), | ||
description: attr('string'), | ||
order: attr('number'), | ||
|
||
namedId: computed('name', function() { | ||
if (!this.get('name')) return ''; | ||
const trimmed = this.get('name').trim(); | ||
return trimmed.toLowerCase().replace(' ', '_'); | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import DS from 'ember-data'; | ||
|
||
const { attr, Model } = DS; | ||
import { computed } from '@ember/object' | ||
|
||
export default Model.extend({ | ||
title: attr('string'), | ||
content: attr('string'), | ||
imageSrc: attr('string'), | ||
videoSrc: attr('string'), | ||
page: attr('string'), | ||
order: attr('number'), | ||
createdAt: attr('date'), | ||
updatedAt: attr('date'), | ||
|
||
vimeoId: computed('videoSrc', function() { | ||
const src = this.get('videoSrc'); | ||
if (!src) return src; | ||
if (src.startsWith('https://vimeo.com/')) { | ||
return src.replace('https://vimeo.com/', ''); | ||
} | ||
|
||
if (src.startsWith('http://vimeo.com/')) { | ||
return src.replace('http://vimeo.com/', ''); | ||
} | ||
|
||
if (src.startsWith('vimeo.com/')) { | ||
return src.replace('vimeo.com/', ''); | ||
} | ||
|
||
return src.replace(/\D/g, ''); | ||
}), | ||
|
||
showVideo: computed('vimeoId', function() { | ||
return this.get('vimeoId') && this.get('vimeoId') !== ""; | ||
}), | ||
|
||
showImage: computed('imageSrc', function() { | ||
return this.get('imageSrc') && this.get('imageSrc') !== ""; | ||
}), | ||
|
||
fullwidth: computed('showVideo', 'showImage', function() { | ||
return !this.get('showVideo') && !this.get('showImage'); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import EditRoute from 'roboteam-website/routes/base/edit'; | ||
|
||
export default EditRoute.extend({ | ||
modelName: "pageitem", | ||
modelRouteParam: "pageitem_id", | ||
useVideo: false, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import IndexRoute from 'roboteam-website/routes/base/index'; | ||
|
||
export default IndexRoute.extend({ | ||
modelName: "pageitem" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import NewRoute from 'roboteam-website/routes/base/new'; | ||
|
||
export default NewRoute.extend({ | ||
modelName: "pageitem", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import EditRoute from 'roboteam-website/routes/base/edit'; | ||
|
||
export default EditRoute.extend({ | ||
modelName: "page", | ||
modelRouteParam: "page_id" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import IndexRoute from 'roboteam-website/routes/base/index'; | ||
|
||
export default IndexRoute.extend({ | ||
modelName: "page" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import NewRoute from 'roboteam-website/routes/base/new'; | ||
|
||
export default NewRoute.extend({ | ||
modelName: "page" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ShowRouteUnauthenticated } from 'roboteam-website/routes/base/show'; | ||
import { hash } from 'rsvp'; | ||
|
||
export default ShowRouteUnauthenticated.extend({ | ||
modelName: "page", | ||
modelRouteParam: "name", | ||
model(params) { | ||
return this.store.query("page", { reload: true }).then(pages => { | ||
const page = pages.filter(page => page.namedId === params["namedId"])[0]; | ||
if (page === undefined) { | ||
return this.transitionTo('/404'); | ||
} | ||
return this.store.query('pageitem', { orderBy: 'order', reload: true }).then(pageItems => { | ||
pageItems = pageItems.filter(item => item.page === page.namedId); | ||
return hash({ | ||
page, | ||
pageItems, | ||
params, | ||
pages | ||
}); | ||
}); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ | |
@import 'news'; | ||
@import '404'; | ||
@import 'design-presentation'; | ||
|
||
@import 'page'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.page-header { | ||
height: 360px; | ||
} | ||
|
||
.page-header-gradient { | ||
position: absolute; | ||
background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.7) 100%); | ||
height: 360px; | ||
width: 100%; | ||
} | ||
|
||
.page-header-image { | ||
position: absolute; | ||
width: 100%; | ||
height: 360px; | ||
object-fit: cover; | ||
background-position: center; | ||
z-index:-1; | ||
background: #000; | ||
} | ||
|
||
.vimeo-container { | ||
padding:56.25% 0 0 0; | ||
position:relative; | ||
|
||
.vimeo-video { | ||
position:absolute; | ||
top:0; | ||
left:0; | ||
width:100%; | ||
height:100%; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{partial "admin/page-item/form"}} |
Oops, something went wrong.