App restructure - closes #245

- This is a first pass at getting a more logical structure. The focus is on moving from admin/frontend to client/server.
- The location of the databases is highly important, this isn't expected to change again
In the future
- client/assets should probably become public/
- more stuff should be shared (helpers etc)
- cleanup some confusion around tpl and views
This commit is contained in:
Hannah Wolfe 2013-07-11 20:02:18 +01:00
parent 316a50b7ff
commit 30b4eb07f7
138 changed files with 194 additions and 175 deletions

View File

@ -21,4 +21,4 @@ projectFilesBackup
.DS_Store
# Ghost DB file
ghost/data/*.db
*.db

17
.gitignore vendored
View File

@ -26,15 +26,14 @@ projectFilesBackup
.build
.dist
/core/admin/assets/tpl/hbs-tpl.js
/core/admin/assets/css
/core/admin/assets/sass/modules/bourbon
/core/client/tpl/hbs-tpl.js
/core/client/assets/css
.sass-cache/
/core/admin/assets/sass/config.rb
/core/admin/assets/sass/layouts/config.rb
/core/admin/assets/sass/modules/config.rb
/core/admin/assets/sass/modules/bourbon
/ghost/.idea/
/core/shared/data/export/exported*
/core/client/assets/sass/config.rb
/core/client/assets/sass/layouts/config.rb
/core/client/assets/sass/modules/config.rb
/core/client/assets/sass/modules/bourbon
/core/client/assets/sass/modules/bourbon/*
/core/server/data/export/exported*
/docs
/_site

View File

@ -6,7 +6,7 @@ var path = require('path'),
var cfg = {
// Common paths to be used by tasks
paths: {
adminAssets: './core/admin/assets',
adminAssets: './core/client/assets',
build: buildDirectory,
nightlyBuild: path.join(buildDirectory, 'nightly'),
weeklyBuild: path.join(buildDirectory, 'weekly'),
@ -21,7 +21,7 @@ var path = require('path'),
// JSLint all the things!
jslintm: {
node: {
server: {
directives: {
// node environment
node: true,
@ -39,17 +39,12 @@ var path = require('path'),
files: {
src: [
"*.js",
"core/**/*.js"
"core/*.js",
"core/server/**/*.js"
]
},
// Lint core files, but not libs, frontend or hbs files
exclude: [
"**/assets/lib/**/*.js",
"**/assets/js/**/*.js",
"**/assets/tpl/*.js"
]
}
},
frontend: {
client: {
directives: {
// node environment
node: false,
@ -63,7 +58,32 @@ var path = require('path'),
unparam: true
},
files: {
src: "**/assets/js/**/*.js"
src: "core/client/**/*.js"
},
exclude: [
"core/client/assets/**/*.js",
"core/client/tpl/**/*.js"
]
},
shared: {
directives: {
// node environment
node: true,
// browser environment
browser: false,
// allow dangling underscores in var names
nomen: true,
// allow to do statements
todo: true,
// allow unused parameters
unparam: true,
// don't require use strict pragma
sloppy: true
},
files: {
src: [
"core/shared/**/*.js"
]
}
}
},
@ -107,12 +127,12 @@ var path = require('path'),
options: {
namespace: "JST",
processName: function (filename) {
filename = filename.replace('./core/admin/assets/tpl/', '');
filename = filename.replace('./core/client/tpl/', '');
return filename.replace('.hbs', '');
}
},
files: {
"<%= paths.adminAssets %>/tpl/hbs-tpl.js": "<%= paths.adminAssets %>/tpl/**/*.hbs"
"core/client/tpl/hbs-tpl.js": "core/client/tpl/**/*.hbs"
}
}
},
@ -126,15 +146,13 @@ var path = require('path'),
"config.js",
"index.js",
"core/ghost.js",
"core/admin/assets/js/*.js",
"core/admin/assets/js/**/*.js",
"core/admin/controllers/*.js",
"core/frontend/**/*.js",
"core/lang/i18n.js",
"core/server/**/*.js",
"core/shared/**/*.js",
"core/shared/*.js",
"core/test/**/*.js",
"core/test/ghost.js"
"core/client/**/*.js"
],
"except": [
"!core/client/assets/**/*.js",
"!core/client/tpl/**/*.js"
]
}
}
@ -142,7 +160,7 @@ var path = require('path'),
watch: {
handlebars: {
files: '<%= paths.adminAssets %>/tpl/**/*.hbs',
files: 'core/client/tpl/**/*.hbs',
tasks: ['handlebars']
},
sass: {
@ -158,7 +176,7 @@ var path = require('path'),
src: [
'**',
'!node_modules/**',
'!core/shared/data/*.db',
'!core/server/data/*.db',
'!.sass*',
'!.af*',
'!.git*',
@ -174,7 +192,7 @@ var path = require('path'),
src: [
'**',
'!node_modules/**',
'!core/shared/data/*.db',
'!core/server/data/*.db',
'!.sass*',
'!.af*',
'!.git*',
@ -190,11 +208,12 @@ var path = require('path'),
src: [
'**',
'!node_modules/**',
'!core/shared/data/*.db',
'!core/server/data/*.db',
'!.sass*',
'!.af*',
'!.git*',
'!.groc*',
'!.iml*',
'!.travis.yml'
],
dest: "<%= paths.buildBuild %>/"

View File

@ -58,7 +58,7 @@ config.env = {
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/core/shared/data/ghost-test.db')
filename: path.join(__dirname, '/core/server/data/ghost-test.db')
}
},
url: {
@ -71,7 +71,7 @@ config.env = {
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/core/shared/data/ghost-travis.db')
filename: path.join(__dirname, '/core/server/data/ghost-travis.db')
}
},
url: {
@ -84,7 +84,7 @@ config.env = {
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/core/shared/data/ghost-dev.db')
filename: path.join(__dirname, '/core/server/data/ghost-dev.db')
},
debug: false
},
@ -98,7 +98,7 @@ config.env = {
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/core/shared/data/ghost-staging.db')
filename: path.join(__dirname, '/core/server/data/ghost-staging.db')
},
debug: false
},
@ -112,7 +112,7 @@ config.env = {
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/core/shared/data/ghost.db')
filename: path.join(__dirname, '/core/server/data/ghost.db')
},
debug: false
},

View File

@ -2,11 +2,10 @@
Core contains the bread and butter of ghost. It is currently divided up into:
* **admin** - the views, controllers, assets and helpers for rendering & working the admin panel
* **frontend** - the controllers & helpers for creating the frontend of the blog. Views & assets live in themes
* **lang** - the current home of everything i18n, this was done as a proof of concept on a very early version of the prototype and needs love
* **shared** - basically everything to do with data & models. The sqlite db file lives in the data folder here. This is the part that needs the most work so it doesn't make much sense yet, and is also the highest priority
* **test** - currently contains two sad unit tests and a set of html prototypes of the admin UI. Really, this folder should reflect all of core. It is my personal mission to make that happen ASAP & get us linked up with Travis.
* **ghost.js** - currently both the glue that binds everything together and what gives us the API for registering themes and plugins. The initTheme function is a bit of a hack which lets us serve different views & static content up for the admin & frontend.
* **client** - the assets, helpers, models, view and templates for rendering the admin panel backbone app
* **server** - the controllers & helpers for driving the server side app along with the model, api, and data
* **shared** - just contains lang for now, although it's not shared yet, more stuff should go here soon like handlebars helpers
* **test** - contains unit tests and a set of html prototypes of the admin UI. Really, this folder should reflect all of core
* **ghost.js** - currently both the glue that binds everything together and what gives us the API for registering themes and plugins. The initTheme function is a bit of a hack which lets us serve different views & static content up for the admin & blog
This structure is by no means final and recommendations are more than welcome.

View File

@ -1,76 +0,0 @@
<!doctype html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if (IE 7)&!(IEMobile)]><html class="no-js lt-ie9 lt-ie8" lang="en"><![endif]-->
<!--[if (IE 8)&!(IEMobile)]><html class="no-js lt-ie9" lang="en"><![endif]-->
<!--[if (gte IE 9)| IEMobile |!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<title>{{siteTitle}}</title>
<meta name="description" content="{{siteDescription}}">
<meta name="author" content="">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="shortcut icon" href="/favicon.ico">
<meta http-equiv="cleartype" content="on">
<link rel="stylesheet" type='text/css' href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,700'>
<link rel="stylesheet" href="/core/admin/assets/css/screen.css">
<link rel="stylesheet" type="text/css" href="/core/admin/assets/lib/codemirror/codemirror.css"> <!-- TODO: Kill this - #29 -->
{{{block "pageStyles"}}}
</head>
<body class="{{bodyClass}}">
{{#unless hideNavbar}}
{{> navbar}}
{{/unless}}
<main role="main" id="main">
{{> flashes}}
{{{body}}}
</main>
<script src="/core/admin/assets/lib/jquery/jquery.min.js"></script>
<script src="/core/admin/assets/lib/icheck/jquery.icheck.min.js"></script>
<script src="/core/admin/assets/lib/underscore.js"></script>
<script src="/core/admin/assets/lib/backbone/backbone.js"></script>
<script src="/core/admin/assets/lib/handlebars/handlebars-runtime.js"></script>
<script src="/core/admin/assets/lib/codemirror/codemirror.js"></script>
<script src="/core/admin/assets/lib/codemirror/mode/markdown/markdown.js"></script>
<script src="/core/admin/assets/lib/showdown/showdown.js"></script>
<script src="/core/admin/assets/lib/showdown/extensions/ghostdown.js"></script>
<script src="/core/admin/assets/lib/shortcuts.js"></script>
<script src="/core/admin/assets/lib/countable.js"></script>
<script src="/core/admin/assets/lib/jquery/jquery-ui-1.10.3.custom.min.js"></script>
<script src="/core/admin/assets/lib/packery.pkgd.min.js"></script>
<script src="/core/admin/assets/js/init.js"></script>
<script src="/core/admin/assets/tpl/hbs-tpl.js"></script>
<script src="/core/admin/assets/js/toggle.js"></script>
<script src="/core/admin/assets/js/admin-ui-temp.js"></script>
<script src="/core/admin/assets/js/markdown-actions.js"></script>
<script src="/core/admin/assets/js/tagui.js"></script>
<script src="/core/admin/assets/lib/moment.js"></script>
<script src="/core/admin/assets/js/helpers/index.js"></script>
<!-- // require '/core/admin/assets/js/models/*' -->
<script src="/core/admin/assets/js/models/post.js"></script>
<script src="/core/admin/assets/js/models/widget.js"></script>
<script src="/core/admin/assets/js/models/settings.js"></script>
<!-- // require '/core/admin/assets/js/views/*' -->
<script src="/core/admin/assets/js/views/base.js"></script>
<script src="/core/admin/assets/js/views/dashboard.js"></script>
<script src="/core/admin/assets/js/views/blog.js"></script>
<script src="/core/admin/assets/js/views/editor.js"></script>
<script src="/core/admin/assets/js/views/settings.js"></script>
<script src="/core/admin/assets/js/views/debug.js"></script>
<script src="/core/admin/assets/js/router.js"></script>
{{{block "bodyScripts"}}}
<script>
Ghost.init();
</script>
</body>
</html>

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

View File

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 89 KiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -19,7 +19,7 @@
============================================================================= */
// Bourbon - http://bourbon.io/
@import "bourbon/bourbon";
@import "bourbon/_bourbon";
$rounded: 2px;
$shadow: rgba(0,0,0,0.05) 0 1px 5px;
$default-transition-duration: 0.3s;

View File

@ -5,7 +5,7 @@
var config = require('./../config'),
when = require('when'),
express = require('express'),
errors = require('../core/shared/errorHandling'),
errors = require('./server/errorHandling'),
fs = require('fs'),
path = require('path'),
hbs = require('express-hbs'),
@ -13,9 +13,9 @@ var config = require('./../config'),
_ = require('underscore'),
Polyglot = require('node-polyglot'),
models = require('./shared/models'),
models = require('./server/models'),
requireTree = require('./shared/require-tree'),
requireTree = require('./server/require-tree'),
themePath = path.resolve(__dirname + '../../content/themes'),
pluginPath = path.resolve(__dirname + '../../content/plugins'),
themeDirectories = requireTree(themePath),
@ -100,11 +100,11 @@ Ghost = function () {
},
paths: function () {
return {
'activeTheme': __dirname + '/../content/' + config.themeDir + '/' + config.activeTheme + '/',
'adminViews': __dirname + '/admin/views/',
'frontendViews': __dirname + '/frontend/views/',
'lang': __dirname + '/lang/',
'availableThemes': instance.themeDirectories,
'activeTheme': __dirname + '/../content/' + config.themeDir + '/' + config.activeTheme + '/',
'adminViews': __dirname + '/server/views/',
'helperTemplates': __dirname + '/server/helpers/tpl/',
'lang': __dirname + '/shared/lang/',
'availableThemes': instance.themeDirectories,
'availablePlugins': instance.pluginDirectories
};
}
@ -179,7 +179,7 @@ Ghost.prototype.compileTemplate = function (templatePath) {
Ghost.prototype.loadTemplate = function (name) {
// TODO: allow themes to override these templates
var templatePath = path.join(this.paths().frontendViews, name + '.hbs');
var templatePath = path.join(this.paths().helperTemplates, name + '.hbs');
return this.compileTemplate(templatePath);
};
@ -284,7 +284,9 @@ Ghost.prototype.initTheme = function (app) {
} else {
app.engine('hbs', hbs.express3({partialsDir: self.paths().adminViews + 'partials'}));
app.set('views', self.paths().adminViews);
app.use('/core/admin/assets', express['static'](path.join(__dirname, '/admin/assets')));
app.use('/public', express['static'](path.join(__dirname, '/client/assets')));
app.use('/public', express['static'](path.join(__dirname, '/client')));
}
app.use(express['static'](self.paths().activeTheme));
app.use('/content/images', express['static'](path.join(__dirname, '/../content/images')));

View File

@ -1,12 +1,12 @@
var Ghost = require('../../ghost'),
dataExport = require('../../shared/data/export'),
dataImport = require('../../shared/data/import'),
dataExport = require('../data/export'),
dataImport = require('../data/import'),
_ = require('underscore'),
fs = require('fs'),
path = require('path'),
when = require('when'),
nodefn = require('when/node/function'),
api = require('../../shared/api'),
api = require('../api'),
ghost = new Ghost(),
dataProvider = ghost.dataProvider,
@ -238,7 +238,7 @@ adminControllers = {
return migration.down();
}, function () {
// If no version in the DB, assume 001
var migration = require("../../shared/data/migration/001");
var migration = require(".././migration/001");
// Run the downward migration
return migration.down();

View File

@ -5,7 +5,7 @@
/*global require, module */
var Ghost = require('../../ghost'),
api = require('../../shared/api'),
api = require('../api'),
ghost = new Ghost(),
frontendControllers;

Some files were not shown because too many files have changed in this diff Show More