Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ghost 3 #174

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"postdeploy": "bin/init-deployment"
},
"success_url": "/ghost",
"addons": [
"jawsdb",
"mailgun"
],
"addons": ["jawsdb", "mailgun"],
"env": {
"PUBLIC_URL": {
"description": "The HTTPS URL of this app: either your custom domain or default 'herokuapp.com' hostname.",
Expand Down
7 changes: 5 additions & 2 deletions bin/common/env-values.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
mysqlDatabaseUrl: process.env.MYSQL_DATABASE_URL || process.env.JAWSDB_URL || process.env.CLEARDB_DATABASE_URL
}
mysqlDatabaseUrl:
process.env.MYSQL_DATABASE_URL ||
process.env.JAWSDB_URL ||
process.env.CLEARDB_DATABASE_URL
};
120 changes: 61 additions & 59 deletions bin/create-config
Original file line number Diff line number Diff line change
@@ -1,50 +1,82 @@
#!/usr/bin/env node
// Ghost Configuration for Heroku

var fs = require('fs');
var path = require('path');
var url = require('url');
const fs = require('fs');
const path = require('path');
const url = require('url');

var envValues = require('./common/env-values');
var appRoot = path.join(__dirname, '..');
const envValues = require('./common/env-values');
const appRoot = path.join(__dirname, '..');

function createConfig() {
var fileStorage, storage;
const getMysqlConfig = connectionUrl => {
if (connectionUrl === null) {
return {};
}

const dbConfig = url.parse(connectionUrl);
if (dbConfig === null) {
return {};
}

const dbAuth = dbConfig.auth ? dbConfig.auth.split(':') : [];
const dbUser = dbAuth[0];
const dbPassword = dbAuth[1];

let dbName;
if (dbConfig.pathname === null) {
dbName = 'ghost';
} else {
dbName = dbConfig.pathname.split('/')[1];
}

const dbConnection = {
host: dbConfig.hostname,
port: dbConfig.port || '3306',
user: dbUser,
password: dbPassword,
database: dbName
};
return dbConnection;
};

const createConfig = () => {
let fileStorage;
let storage;

if (!!process.env.S3_ACCESS_KEY_ID) {
fileStorage = true
fileStorage = true;
storage = {
active: 's3',
's3': {
accessKeyId: process.env.S3_ACCESS_KEY_ID,
s3: {
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_ACCESS_SECRET_KEY,
bucket: process.env.S3_BUCKET_NAME,
region: process.env.S3_BUCKET_REGION,
assetHost: process.env.S3_ASSET_HOST_URL
bucket: process.env.S3_BUCKET_NAME,
region: process.env.S3_BUCKET_REGION,
assetHost: process.env.S3_ASSET_HOST_URL
}
}
};
} else if (!!process.env.BUCKETEER_AWS_ACCESS_KEY_ID) {
fileStorage = true
fileStorage = true;
storage = {
active: 's3',
's3': {
accessKeyId: process.env.BUCKETEER_AWS_ACCESS_KEY_ID,
s3: {
accessKeyId: process.env.BUCKETEER_AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.BUCKETEER_AWS_SECRET_ACCESS_KEY,
bucket: process.env.BUCKETEER_BUCKET_NAME,
region: process.env.S3_BUCKET_REGION,
assetHost: process.env.S3_ASSET_HOST_URL
bucket: process.env.BUCKETEER_BUCKET_NAME,
region: process.env.S3_BUCKET_REGION,
assetHost: process.env.S3_ASSET_HOST_URL
}
}
};
} else {
fileStorage = false
storage = {}
fileStorage = false;
storage = {};
}

config = {
url: process.env.PUBLIC_URL,
logging: {
level: "info",
transports: ["stdout"]
level: 'info',
transports: ['stdout']
},
mail: {
transport: 'SMTP',
Expand All @@ -56,8 +88,8 @@ function createConfig() {
}
}
},
fileStorage: fileStorage,
storage: storage,
fileStorage,
storage,
database: {
client: 'mysql',
connection: getMysqlConfig(envValues.mysqlDatabaseUrl),
Expand All @@ -74,37 +106,7 @@ function createConfig() {
};

return config;
}

function getMysqlConfig(connectionUrl) {
if (connectionUrl == null) {
return {};
}

var dbConfig = url.parse(connectionUrl);
if (dbConfig == null) {
return {};
}

var dbAuth = dbConfig.auth ? dbConfig.auth.split(':') : [];
var dbUser = dbAuth[0];
var dbPassword = dbAuth[1];

if (dbConfig.pathname == null) {
var dbName = 'ghost';
} else {
var dbName = dbConfig.pathname.split('/')[1];
}

var dbConnection = {
host: dbConfig.hostname,
port: dbConfig.port || '3306',
user: dbUser,
password: dbPassword,
database: dbName
};
return dbConnection;
}
};

var configContents = JSON.stringify(createConfig(), null, 2);
const configContents = JSON.stringify(createConfig(), null, 2);
fs.writeFileSync(path.join(appRoot, 'config.production.json'), configContents);
18 changes: 9 additions & 9 deletions bin/wait-for-db
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/usr/bin/env node

var mysql = require('mysql');
var envValues = require('./common/env-values');
const mysql = require('mysql');
const envValues = require('./common/env-values');

console.error(`Awaiting MySQL database…`);
pingDatabaseUntilConnected();

function pingDatabaseUntilConnected() {
var connection = mysql.createConnection(envValues.mysqlDatabaseUrl);
connection.query('SELECT 1', function (error, results, fields) {
const pingDatabaseUntilConnected = () => {
const connection = mysql.createConnection(envValues.mysqlDatabaseUrl);
connection.query('SELECT 1', (error, results, fields) => {
if (error) {
console.error(`Database not yet available: ${error.message}`);
setTimeout(pingDatabaseUntilConnected, 5000);
Expand All @@ -18,4 +15,7 @@ function pingDatabaseUntilConnected() {
process.exit(0);
}
});
}
};

console.error(`Awaiting MySQL database…`);
pingDatabaseUntilConnected();
5 changes: 1 addition & 4 deletions config.development.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
"transport": "Direct"
},
"logging": {
"transports": [
"file",
"stdout"
]
"transports": ["file", "stdout"]
},
"process": "local",
"paths": {
Expand Down
13 changes: 13 additions & 0 deletions content/settings/routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
routes:
/signup/: members/signup
/signin/: members/signin
/account/: members/account

collections:
/:
permalink: /{slug}/
template: index

taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
1 change: 1 addition & 0 deletions content/themes/lyra
Loading