-
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.
- Loading branch information
0 parents
commit 3f8216a
Showing
134 changed files
with
33,965 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file is for unifying the coding style for different editors and IDEs | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = false | ||
insert_final_newline = true | ||
indent_style = tab | ||
|
||
[{*.yml,*.json}] | ||
indent_style = space | ||
indent_size = 2 |
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,2 @@ | ||
public/js/bootstrap | ||
public/js/jquery |
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 @@ | ||
{ | ||
"extends": "keystone" | ||
} |
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,31 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# Deployed apps should consider commenting this line out: | ||
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
# Ignore .env configuration files | ||
.env | ||
|
||
# Ignore .DS_Store files on OS X | ||
.DS_Store |
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 @@ | ||
web: node keystone.js |
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 @@ | ||
"# Dash" |
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,53 @@ | ||
// Simulate config options from your production environment by | ||
// customising the .env file in your project's root folder. | ||
require('dotenv').config(); | ||
|
||
// Require keystone | ||
var keystone = require('keystone'); | ||
|
||
keystone.init({ | ||
'name': 'Dash', | ||
'brand': 'Dash', | ||
|
||
'less': 'public', | ||
'static': 'public', | ||
'favicon': 'public/favicon.ico', | ||
'views': 'templates/views', | ||
'view engine': 'pug', | ||
|
||
'emails': 'templates/emails', | ||
|
||
'auto update': true, | ||
'session': true, | ||
'auth': true, | ||
'user model': 'User', | ||
}); | ||
keystone.import('models'); | ||
keystone.set('locals', { | ||
_: require('lodash'), | ||
env: keystone.get('env'), | ||
utils: keystone.utils, | ||
editable: keystone.content.editable, | ||
}); | ||
keystone.set('routes', require('./routes')); | ||
|
||
keystone.set('nav', { | ||
posts: ['posts', 'post-categories'], | ||
galleries: 'galleries', | ||
enquiries: 'enquiries', | ||
users: 'users', | ||
}); | ||
|
||
|
||
if (!process.env.MAILGUN_API_KEY || !process.env.MAILGUN_DOMAIN) { | ||
console.log('----------------------------------------' | ||
+ '\nWARNING: MISSING MAILGUN CREDENTIALS' | ||
+ '\n----------------------------------------' | ||
+ '\nYou have opted into email sending but have not provided' | ||
+ '\nmailgun credentials. Attempts to send will fail.' | ||
+ '\n\nCreate a mailgun account and add the credentials to the .env file to' | ||
+ '\nset up your mailgun integration'); | ||
} | ||
|
||
|
||
keystone.start(); |
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,75 @@ | ||
var keystone = require('keystone'); | ||
var Types = keystone.Field.Types; | ||
|
||
/** | ||
* Enquiry Model | ||
* ============= | ||
*/ | ||
|
||
var Enquiry = new keystone.List('Enquiry', { | ||
nocreate: true, | ||
noedit: true, | ||
}); | ||
|
||
Enquiry.add({ | ||
name: { type: Types.Name, required: true }, | ||
email: { type: Types.Email, required: true }, | ||
phone: { type: String }, | ||
enquiryType: { type: Types.Select, options: [ | ||
{ value: 'message', label: 'Just leaving a message' }, | ||
{ value: 'question', label: 'I\'ve got a question' }, | ||
{ value: 'other', label: 'Something else...' }, | ||
] }, | ||
message: { type: Types.Markdown, required: true }, | ||
createdAt: { type: Date, default: Date.now }, | ||
}); | ||
|
||
Enquiry.schema.pre('save', function (next) { | ||
this.wasNew = this.isNew; | ||
next(); | ||
}); | ||
|
||
Enquiry.schema.post('save', function () { | ||
if (this.wasNew) { | ||
this.sendNotificationEmail(); | ||
} | ||
}); | ||
|
||
Enquiry.schema.methods.sendNotificationEmail = function (callback) { | ||
if (typeof callback !== 'function') { | ||
callback = function (err) { | ||
if (err) { | ||
console.error('There was an error sending the notification email:', err); | ||
} | ||
}; | ||
} | ||
|
||
if (!process.env.MAILGUN_API_KEY || !process.env.MAILGUN_DOMAIN) { | ||
console.log('Unable to send email - no mailgun credentials provided'); | ||
return callback(new Error('could not find mailgun credentials')); | ||
} | ||
|
||
var enquiry = this; | ||
var brand = keystone.get('brand'); | ||
|
||
keystone.list('User').model.find().where('isAdmin', true).exec(function (err, admins) { | ||
if (err) return callback(err); | ||
new keystone.Email({ | ||
templateName: 'enquiry-notification', | ||
transport: 'mailgun', | ||
}).send({ | ||
to: admins, | ||
from: { | ||
name: 'Dash', | ||
email: '[email protected]', | ||
}, | ||
subject: 'New Enquiry for Dash', | ||
enquiry: enquiry, | ||
brand: brand, | ||
}, callback); | ||
}); | ||
}; | ||
|
||
Enquiry.defaultSort = '-createdAt'; | ||
Enquiry.defaultColumns = 'name, email, enquiryType, createdAt'; | ||
Enquiry.register(); |
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,20 @@ | ||
var keystone = require('keystone'); | ||
var Types = keystone.Field.Types; | ||
|
||
/** | ||
* Gallery Model | ||
* ============= | ||
*/ | ||
|
||
var Gallery = new keystone.List('Gallery', { | ||
autokey: { from: 'name', path: 'key', unique: true }, | ||
}); | ||
|
||
Gallery.add({ | ||
name: { type: String, required: true }, | ||
publishedDate: { type: Date, default: Date.now }, | ||
heroImage: { type: Types.CloudinaryImage }, | ||
images: { type: Types.CloudinaryImages }, | ||
}); | ||
|
||
Gallery.register(); |
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,32 @@ | ||
var keystone = require('keystone'); | ||
var Types = keystone.Field.Types; | ||
|
||
/** | ||
* Post Model | ||
* ========== | ||
*/ | ||
|
||
var Post = new keystone.List('Post', { | ||
map: { name: 'title' }, | ||
autokey: { path: 'slug', from: 'title', unique: true }, | ||
}); | ||
|
||
Post.add({ | ||
title: { type: String, required: true }, | ||
state: { type: Types.Select, options: 'draft, published, archived', default: 'draft', index: true }, | ||
author: { type: Types.Relationship, ref: 'User', index: true }, | ||
publishedDate: { type: Types.Date, index: true, dependsOn: { state: 'published' } }, | ||
image: { type: Types.CloudinaryImage }, | ||
content: { | ||
brief: { type: Types.Html, wysiwyg: true, height: 150 }, | ||
extended: { type: Types.Html, wysiwyg: true, height: 400 }, | ||
}, | ||
categories: { type: Types.Relationship, ref: 'PostCategory', many: true }, | ||
}); | ||
|
||
Post.schema.virtual('content.full').get(function () { | ||
return this.content.extended || this.content.brief; | ||
}); | ||
|
||
Post.defaultColumns = 'title, state|20%, author|20%, publishedDate|20%'; | ||
Post.register(); |
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,18 @@ | ||
var keystone = require('keystone'); | ||
|
||
/** | ||
* PostCategory Model | ||
* ================== | ||
*/ | ||
|
||
var PostCategory = new keystone.List('PostCategory', { | ||
autokey: { from: 'name', path: 'key', unique: true }, | ||
}); | ||
|
||
PostCategory.add({ | ||
name: { type: String, required: true }, | ||
}); | ||
|
||
PostCategory.relationship({ ref: 'Post', path: 'posts', refPath: 'categories' }); | ||
|
||
PostCategory.register(); |
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,34 @@ | ||
var keystone = require('keystone'); | ||
var Types = keystone.Field.Types; | ||
|
||
/** | ||
* User Model | ||
* ========== | ||
*/ | ||
var User = new keystone.List('User'); | ||
|
||
User.add({ | ||
name: { type: Types.Name, required: true, index: true }, | ||
email: { type: Types.Email, initial: true, required: true, unique: true, index: true }, | ||
password: { type: Types.Password, initial: true, required: true }, | ||
}, 'Permissions', { | ||
isAdmin: { type: Boolean, label: 'Can access Keystone', index: true }, | ||
}); | ||
|
||
// Provide access to Keystone | ||
User.schema.virtual('canAccessKeystone').get(function () { | ||
return this.isAdmin; | ||
}); | ||
|
||
|
||
/** | ||
* Relationships | ||
*/ | ||
User.relationship({ ref: 'Post', path: 'posts', refPath: 'author' }); | ||
|
||
|
||
/** | ||
* Registration | ||
*/ | ||
User.defaultColumns = 'name, email, isAdmin'; | ||
User.register(); |
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,22 @@ | ||
{ | ||
"name": "dash", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"keystone": "4.0.0-beta.5", | ||
"lodash": "^4.13.1", | ||
"pug": "2.0.0-beta11", | ||
"dotenv": "4.0.0", | ||
"keystone-email": "1.0.5", | ||
"async": "2.1.4" | ||
}, | ||
"devDependencies": { | ||
"eslint": "3.15.0", | ||
"eslint-config-keystone": "3.0.0", | ||
"eslint-plugin-react": "^5.1.1" | ||
}, | ||
"scripts": { | ||
"lint": "eslint .", | ||
"start": "node keystone.js" | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.