Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 7aeb4ec

Browse files
author
Stuart Romanek
committed
initial
1 parent e624850 commit 7aeb4ec

33 files changed

+2848
-561
lines changed

Dockerfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM node:6.5.0
2+
3+
# Create app directory
4+
RUN mkdir -p /app
5+
WORKDIR /app
6+
7+
# Bundle app source
8+
COPY . /app
9+
RUN npm install
10+
11+
# Mount persistent storage
12+
VOLUME /app/data
13+
VOLUME /app/public/uploads
14+
15+
EXPOSE 3000
16+
CMD [ "npm", "start" ]

LICENSE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (c) 2013 P'unk Avenue LLC
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
[![Build Status](https://travis-ci.org/punkave/frontend-starter.svg?branch=feature%2Ffonts-mixin-exts)](https://travis-ci.org/punkave/frontend-starter)
1+
# Apostrophe boilerplate + Gulp starter pack
22

3-
BrowserSync server spins up on http://localhost:3001/ (proxying port 3000). Although http://localhost:3000/ will work, use http://localhost:3001/ to utilize BrowserSync features like mirroring and CSS injection.
3+
## This repo serves as a demo configuration for incorporating Gulp.js with ApostropheCMS.
4+
5+
See `gulpfile.babel.js` for how to push your custom assets to the default place Apostrophe is looking for them.
6+
7+
Combination of the following two repositories:
8+
- https://github.com/apostrophecms/apostrophe-boilerplate
9+
- https://github.com/punkave/frontend-starter

app.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var path = require('path');
2+
3+
var apos = require('apostrophe')({
4+
shortName: 'apostrophe-gulp-starter',
5+
6+
// See lib/modules for basic project-level configuration of our modules
7+
// responsible for serving static assets, managing page templates and
8+
// configuring user acounts.
9+
10+
modules: {
11+
12+
// Apostrophe module configuration
13+
14+
// Note: most configuration occurs in the respective
15+
// modules' directories. See lib/apostrophe-assets/index.js for an example.
16+
// However any modules that are not present by default in Apostrophe must at
17+
// least have a minimal configuration here: `moduleName: {}`
18+
19+
// If a template is not found somewhere else, serve it from the top-level
20+
// `views/` folder of the project
21+
22+
'apostrophe-templates': { viewsFolderFallback: path.join(__dirname, 'views') }
23+
24+
}
25+
});

deployment/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
settings
2+
settings.production

deployment/README

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This is a deployment folder for use with Stagecoach.
2+
3+
You don't have to use Stagecoach.
4+
5+
It's just a neat solution for deploying node apps.
6+
7+
See:
8+
9+
http://github.com/punkave/stagecoach

deployment/dependencies

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# Also a good place to ensure any data folders
4+
# that are *not* supposed to be replaced on every deployment exist
5+
# and create a symlink to them from the latest deployment directory.
6+
7+
# The real 'data' folder is shared. It lives two levels up and one over
8+
# (we're in a deployment dir, which is a subdir of 'deployments', which
9+
# is a subdir of the project's main dir)
10+
11+
HERE=`pwd`
12+
mkdir -p ../../data
13+
ln -s ../../data $HERE/data
14+
15+
# We also have a shared uploads folder which is convenient to keep
16+
# in a separate place so we don't have to have two express.static calls
17+
18+
mkdir -p ../../uploads
19+
ln -s ../../../uploads $HERE/public/uploads
20+
21+
# Install any dependencies that can't just be rsynced over with
22+
# the deployment. Example: node apps have npm modules in a
23+
# node_modules folder. These may contain compiled C++ code that
24+
# won't work portably from one server to another.
25+
26+
# This script runs after the rsync, but before the 'stop' script,
27+
# so your app is not down during the npm installation.
28+
29+
# Make sure node_modules exists so npm doesn't go searching
30+
# up the filesystem tree
31+
mkdir -p node_modules
32+
33+
# If there is no package.json file then we don't need npm install
34+
if [ -f './package.json' ]; then
35+
# Install npm modules
36+
# Use a suitable version of Python
37+
# export PYTHON=/usr/bin/python26
38+
npm install
39+
if [ $? -ne 0 ]; then
40+
echo "Error during npm install!"
41+
exit 1
42+
fi
43+
fi
44+
45+
node app apostrophe-migrations:migrate --safe
46+
# Generate new static asset files for this
47+
# deployment of the app without shutting down
48+
node app apostrophe:generation

deployment/migrate

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# Run any necessary database migration tasks that should happen while the
4+
# site is paused here.
5+
6+
node app apostrophe-migrations:migrate
7+
8+
echo "Site migrated"

deployment/rsync_exclude.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# List files and folders that shouldn't be deployed (such as data folders and runtime status files) here.
2+
# In our projects .git and .gitignore are good candidates, also 'data' which contains persistent files
3+
# that are *not* part of deployment. A good place for things like data/port, data/pid, and any
4+
# sqlite databases or static web content you may need
5+
data
6+
temp
7+
public/uploads
8+
public/modules
9+
public/apos-minified
10+
.git
11+
.gitignore
12+
# We don't deploy these anymore, instead we always 'npm install' to ensure
13+
# that any compiled C++ modules are built for the right architecture
14+
node_modules

deployment/settings.example

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Settings shared by all targets (staging, production, etc). Usually the
4+
# shortname of the project (which is also the hostname for the frontend
5+
# proxy server used for staging sites) and the directory name. For our
6+
# web apps that use sc-proxy we make sure each is a subdirectory
7+
# of /opt/stagecoach/apps
8+
9+
PROJECT=apostrophe
10+
DIR=/opt/stagecoach/apps/$PROJECT
11+
12+
# Adjust the PATH environment variable on the remote host. Here's an example
13+
# for deploying to MacPorts
14+
#ADJUST_PATH='export PATH=/opt/local/bin:$PATH'
15+
16+
# ... But you probably won't need to on real servers. I just find it handy for
17+
# testing parts of stagecoach locally on a Mac. : is an acceptable "no-op" (do-nothing) statement
18+
ADJUST_PATH=':'
19+
20+
# ssh port. Sensible people leave this set to 22 but it's common to do the
21+
# "security by obscurity" thing alas
22+
SSH_PORT=22
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Settings specific to the 'master' deployment target.
4+
# USER is the ssh user, SERVER is the ssh host. USER should
5+
# match the USER setting in /opt/stagecoach/settings on
6+
# the server
7+
8+
USER=myuser
9+
SERVER=myserver.com
10+

deployment/start

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
# Make the site live again, for instance by tweaking a .htaccess file
4+
# or starting a node server. In this example we also set up a
5+
# data/port file so that sc-proxy.js can figure out what port
6+
# to forward traffic to for this site. The idea is that every
7+
# folder in /var/webapps represents a separate project with a separate
8+
# node process, each listening on a specific port, and they all
9+
# need traffic forwarded from a reverse proxy server on port 80
10+
11+
# Useful for debugging
12+
#set -x verbose
13+
14+
if [ ! -f "app.js" ]; then
15+
echo "I don't see app.js in the current directory."
16+
exit 1
17+
fi
18+
19+
# Assign a port number if we don't yet have one
20+
21+
if [ -f "data/port" ]; then
22+
PORT=`cat data/port`
23+
else
24+
# No port set yet for this site. Scan and sort the existing port numbers if any,
25+
# grab the highest existing one
26+
PORT=`cat ../../../*/data/port 2>/dev/null | sort -n | tail -1`
27+
if [ "$PORT" == "" ]; then
28+
echo "First app ever, assigning port 3000"
29+
PORT=3000
30+
else
31+
# Bash is much nicer than sh! We can do math without tears!
32+
let PORT+=1
33+
fi
34+
echo $PORT > data/port
35+
echo "First startup, chose port $PORT for this site"
36+
fi
37+
38+
# Run the app via 'forever' so that it restarts automatically if it fails
39+
# Use `pwd` to make sure we have a full path, forever is otherwise easily confused
40+
# and will stop every server with the same filename
41+
42+
# Use a "for" loop. A classic single-port file will do the
43+
# right thing, but so will a file with multiple port numbers
44+
# for load balancing across multiple cores
45+
for port in $PORT
46+
do
47+
export PORT=$port
48+
forever --minUptime=1000 --spinSleepTime=10000 -o data/console.log -e data/error.log start `pwd`/app.js && echo "Site started"
49+
done
50+
51+
# Run the app without 'forever'. Record the process id so 'stop' can kill it later.
52+
# We recommend installing 'forever' instead for node apps. For non-node apps this code
53+
# may be helpful
54+
#
55+
# node app.js >> data/console.log 2>&1 &
56+
# PID=$!
57+
# echo $PID > data/pid
58+
#
59+
#echo "Site started"

deployment/stop

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
# Shut the site down, for instance by tweaking a .htaccess file to display
4+
# a 'please wait' notice, or stopping a node server
5+
6+
if [ ! -f "app.js" ]; then
7+
echo "I don't see app.js in the current directory."
8+
exit 1
9+
fi
10+
11+
# Stop the node app via 'forever'. You'll get a harmless warning if the app
12+
# was not already running. Use `pwd` to make sure we have a full path,
13+
# forever is otherwise easily confused and will stop every server with
14+
# the same filename
15+
forever stop `pwd`/app.js && echo "Site stopped"
16+
17+
# Stop the app without 'forever'. We recommend using 'forever' for node apps,
18+
# but this may be your best bet for non-node apps
19+
#
20+
# if [ -f "data/pid" ]; then
21+
# kill `cat data/pid`
22+
# rm data/pid
23+
# echo "Site stopped"
24+
# else
25+
# echo "Site was not running"
26+
# fi
27+

gulpfile.babel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import sass from 'gulp-sass';
1111
import source from 'vinyl-source-stream';
1212

1313
const src = 'src/';
14-
const dest = 'public/';
14+
const dest = 'lib/modules/apostrophe-assets/public/';
1515

1616
const spawn = require('child_process').spawn;
1717
const bs = browserSync.create();
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This configures the apostrophe-assets module to push a 'site.less'
2+
// stylesheet by default, and to use jQuery 3.x
3+
4+
module.exports = {
5+
jQuery: 3,
6+
stylesheets: [
7+
{
8+
name: 'site'
9+
}
10+
],
11+
scripts: [
12+
{
13+
name: 'site'
14+
}
15+
]
16+
};

lib/modules/apostrophe-pages/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This configures the apostrophe-pages module to add a "home" page type to the
2+
// pages menu
3+
4+
module.exports = {
5+
types: [
6+
{
7+
name: 'home',
8+
label: 'Home'
9+
}
10+
11+
// Add more page types here, but make sure you create a corresponding
12+
// template in lib/modules/apostrophe-pages/views/pages!
13+
]
14+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{#
2+
Use this template to build out your 404 error pages. Like page templates,
3+
it inherits a global layout.
4+
#}
5+
6+
{% extends "layout.html" %}
7+
8+
{% block title %}404 - Page not found{% endblock %}
9+
10+
{% block main %}
11+
We're sorry. We couldn't find the page you're looking for.
12+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{#
2+
This is an example home page template. It inherits and extends a layout template
3+
that lives in the top-level views/ folder for convenience
4+
#}
5+
6+
{% extends "layout.html" %}
7+
8+
{% block main %}
9+
<div class="main-content">
10+
<h3>Hello world!
11+
{% if not data.user %}
12+
<a class="login-link" href="/login">Login</a>
13+
{% endif %}
14+
</h3>
15+
<p>This is a very bare bones Apostrophe project. Now, get to work and make a real website!</p>
16+
</div>
17+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{#
2+
This file extends Apostrophe's outerLayoutBase template, which we don't recommend
3+
overriding directly. Changes in this file, if any, are usually block overrides to
4+
modify the outer chrome, outside the main content area of the page. Most of the
5+
time you should just edit `layout.html` in the top level `views/` folder.
6+
#}
7+
8+
{% extends "outerLayoutBase.html" %}

lib/modules/apostrophe-users/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This configures the apostrophe-users module to add an admin-level
2+
// group by default:
3+
4+
module.exports = {
5+
groups: [
6+
{
7+
title: 'guest',
8+
permissions: [ ]
9+
},
10+
{
11+
title: 'admin',
12+
permissions: [ 'admin' ]
13+
}
14+
]
15+
};

local.example.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Settings specific to this server. Change the URL
2+
// if you are deploying in production. Then copy to
3+
// data/local.js. That folder is shared by all
4+
// deployments in our stagecoach recipe
5+
6+
module.exports = {
7+
modules: {
8+
'apostrophe-assets': {
9+
// Set to true for full CSS and JS minify, on staging and production servers
10+
// minify: true
11+
},
12+
// If these are your db settings then you don't need to be explicit. If not
13+
// you can uncomment this and get more specific.
14+
'apostrophe-db': {
15+
// uri: 'mongodb://localhost:27017/apostrophe-sandbox'
16+
// There is legacy support for host, port, name, user and password options,
17+
// but this is not necessary. They can all go in the uri option like this:
18+
// mongodb://user:password@host:port/dbname
19+
}
20+
}
21+
};

0 commit comments

Comments
 (0)