Commit e75ace6a authored by Bat's avatar Bat
Browse files

Initial commit

parents
type: app
database: pg
language: ecr
model: crecto
/doc/
/lib/
/.crystal/
/.shards/
/.vscode/
/tmp/
.env
.encryption_key
production.yml
.DS_Store
/bin/
/node_modules
language: crystal
FROM amberframework/amber:v0.6.7
WORKDIR /app
COPY shard.* /app/
RUN crystal deps
COPY . /app
RUN rm -rf /app/node_modules
CMD amber watch
# plume
This project is powered by [Amber Framework](https://amberframework.org/).
## Installation
1. [Install required dependencies](https://github.com/amberframework/online-docs/blob/master/getting-started/quickstart/zero-to-deploy.md#install-crystal-and-amber)
2. Run `shards install`
## Usage
To setup your database edit `database_url` inside `config/environments/development.yml` file.
To edit your production settings use `amber encrypt`. [See encrypt command guide](https://github.com/amberframework/online-docs/blob/master/getting-started/cli/encrypt.md#encrypt-command)
To run amber server in a **development** enviroment:
```
amber db create migrate
amber watch
```
To build and run a **production** release:
1. Add an environment variable `AMBER_ENV` with a value of `production`
2. Run these commands:
```
npm run release
amber db create migrate
shards build --production
./bin/plume
```
## Docker Compose
To set up the database and launch the server:
```
docker-compose up -d
```
To view the logs:
```
docker-compose logs -f
```
> **Note:** The Docker images are compatible with Heroku.
## Contributing
1. Fork it ( https://github.com/your-github-user/plume/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request
## Contributors
- [your-github-user](https://github.com/your-github-user) Bat' - creator, maintainer
require "./initializers/**"
require "amber"
require "../src/controllers/application_controller"
require "../src/controllers/**"
# About Application.cr File
#
# This is Amber application main entry point. This file is responsible for loading
# initializers, classes, and all application related code in order to have
# Amber::Server boot up.
#
# > We recommend to not modify the order of the require since the order will
# affect the behavior of the application.
#
# With `Amber::Server.configure` block you can redefine the Server configuration
# settings and use ENVIRONMENT variables and/or values evaluated at runtime.
#
# > Important! Yaml configurations are first class citizen and are loaded first before
# this file, we recommend to use yaml configurations before changing any settings here.
# Any uncommented setting here will override the YAML with the value set here.
Amber::Server.configure do |settings|
# Use your environment variables settings here.
#
# Name: A name that identifies this application. This is not internally
# used by the framework.
#
# settings.name = "Plume web application."
#
#
# Colorize Logging: specifies whether or not to use ANSI color codes
# when logging information, display the time and/or to display the severity level.
# Defaults to true.
#
# Log Level defines the verbosity of the Amber logger. This option defaults to
# debug for all environments. The available log levels are: debug, info, warn,
# error, fatal, and unknown.
#
# settings.logging.colorize = true
# settings.logging.severity = debug
# settings.logging.filter = %w(password confirm_password)
# settings.logging.skip = %w()
# settings.logging.context = %w(request headers cookies session params)
#
#
# Secret Key Base: is used for specifying a key which allows sessions
# for the application to be verified against a known secure key to
# prevent tampering. Applications get Amber.secret_key
# initialized to a random key present in `ENV["AMBER_SECRET_KEY"]` or
# `.amber_secret_key` in this order.
#
# settings.secret_key_base= CIiU14sC4my3nCLbFIj880ZD0o8S6N-k6_hmOkuAV6o
#
#
# Host: is the application server host address or ip address. Useful for when
# deploying Amber to a PAAS and likely the assigned server IP is either
# known or unknown. Defaults to an environment variable HOST
#
# settings.host = ENV["HOST"] if ENV["HOST"]?
#
#
# Port Reuse: Amber supports clustering mode which allows to spin
# multiple app instances per core. This setting allows to bind the different
# instances to the same port. Default this setting to true if the number or process
# is grater than 1.
#
# > Read more about Linux PORT REUSE https://lwn.net/Articles/542629/
#
# settings.port_reuse = true
#
#
# Process Count: This will enable Amber to be used in cluster mode,
# spinning an instance for each number of process specified here.
# Rule of thumb, always leave at least 1 core available for system processes/resources.
#
# settings.process_count = ENV["PROCESS_COUNT"].to_i if ENV["PROCESS_COUNT"]?
#
#
# PORT: This is the port that you're application will run on. Examples would be (80, 443, 3000, 8080)
#
settings.port = ENV["PORT"].to_i if ENV["PORT"]?
#
#
# Redis URL: Redis is an in memory key value storage. Amber utilizes redis as
# a storing option for session information.
#
# settings.redis_url = ENV["REDIS_URL"] if ENV["REDIS_URL"]?
#
#
# Database URL: This is the database connection string or data file url.
# The connection string contains the information to establish a connection to the
# database or the data file. Defaults to the database provider you chose at
# at app generation.
#
# settings.database_url = ENV["DATABASE_URL"] if ENV["DATABASE_URL"]?
#
#
# SSL Key File: The private key is a text file used initially to generate a
# Certificate Signing Request (CSR), and later to secure and verify connections
# using the certificate created per that request. The private key is used to create
# a digital signature as you might imagine from the name, the private key should be
# ``closely guarded.
#
# settings.ssl_key_file = ENV["SSL_KEY_FILE"] if ENV["SSL_KEY_FILE"]?
#
#
# SSL Cert File: This represents the signed certificate file. SSL Certificates are
# small data files that digitally bind a cryptographic key to an organization's
# details. When installed on a web server, it activates the padlock and the https
# protocol and allows secure connections from a web server to a browser.
#
# settings.ssl_cert_file = ENV["SSL_CERT_FILE"] if ENV["SSL_CERT_FILE"]?
#
#
# Session: A Hash that specifies the session storage mechanism, expiration and key to be used
# for the application. The `key` specifies the name of the cookie to be used defaults to
# "amber.session". The store can be `encrypted_cookie`, `signed_cookie` or `redis`. Expires
# when set to 0 means this is indefinitely and is expressed in seconds.
#
# settings.session = { "key" => "amber.session", "store" => "signed_cookie", "expires" => 0 }
#
#
# Logger: is the logger that Amber and other capable shards in the project will use
# instead of writing directly to STDOUT. Supply a custom logger to write to syslog, etc.
#
# settings.logger = Amber::Environment::Logger.new(File.open("plume.log", "w"))
#
#
end
qHհ"!dXɂD %>w"Z*/>v Rbb0n~~aYFxoC!e_PsivEY?R!dKhMg}+8囉1?~>'*,x_cXh't}ޛ.ҏ/04pǣS׮: C|2 "8cL nBJwߦ6܊uGlfgEoA1n(C^ :Q4!PDL|
nTIphb,dF.nϔ|E\,l]tD=H FC-kgSvTZJz*G^ t.?XXJcvb8u Ϸ7d}:pAa%c '6* ̀}?y(~,vأlOE r*k @4hxˣNG94*=JOc1{{R@ֲ`%8&Y' KkMAEWV9o-BPGyVv.
OInd|f:`a<Skn1&)3
\ No newline at end of file
secret_key_base: n6rE-vQaQZer1dahRUsPOA2x9MWPUMCjVeFXo2ncI5s
port: 3000
name: plume
logging:
severity: debug
colorize: true
filter:
- password
- confirm_password
skip:
-
context:
- request
- session
- headers
- cookies
- params
host: 0.0.0.0
port_reuse: true
process_count: 1
# ssl_key_file:
# ssl_cert_file:
redis_url: "redis://localhost:6379"
database_url: postgres://postgres:@localhost:5432/plume_development
session:
key: amber.session
store: signed_cookie
expires: 0
secrets:
description: Store your development secrets credentials and settings here.
secret_key_base: jQhMqNBsIz4RAB4s6nUFPMhjdCdRqaIsMp2CQnILN9A
port: 3000
name: plume
logging:
severity: debug
colorize: true
filter:
- password
- confirm_password
skip:
-
context:
- request
- session
- headers
- cookies
- params
host: 0.0.0.0
port_reuse: false
process_count: 1
# ssl_key_file:
# ssl_cert_file:
redis_url: "redis://localhost:6379"
database_url: postgres://postgres:@localhost:5432/plume_test
session:
key: amber.session
store: signed_cookie
expires: 0
secrets:
description: Store your development secrets credentials and settings here.
require "pg"
require "crecto"
Query = Crecto::Repo::Query
module Repo
extend Crecto::Repo
config do |c|
c.adapter = Crecto::Adapters::Postgres
c.uri = Amber.settings.database_url
end
end
Crecto::DbLogger.set_handler(Amber.settings.logger.dup)
Amber::Server.configure do |app|
pipeline :web do
# Plug is the method to use connect a pipe (middleware)
# A plug accepts an instance of HTTP::Handler
plug Amber::Pipe::PoweredByAmber.new
# plug Amber::Pipe::ClientIp.new(["X-Forwarded-For"])
plug Amber::Pipe::Error.new
plug Amber::Pipe::Logger.new
plug Amber::Pipe::Session.new
plug Amber::Pipe::Flash.new
plug Amber::Pipe::CSRF.new
# Reload clients browsers (development only)
plug Amber::Pipe::Reload.new if Amber.env.development?
end
# All static content will run these transformations
pipeline :static do
plug Amber::Pipe::PoweredByAmber.new
# plug Amber::Pipe::ClientIp.new(["X-Forwarded-For"])
plug Amber::Pipe::Error.new
plug Amber::Pipe::Static.new("./public")
end
routes :static do
# Each route is defined as follow
# verb resource : String, controller : Symbol, action : Symbol
get "/*", Amber::Controller::Static, :index
end
routes :web do
get "/", HomeController, :index
end
end
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
let config = {
entry: {
'main.bundle.js': './src/assets/javascripts/main.js',
'main.bundle.css': './src/assets/stylesheets/main.scss'
},
output: {
filename: '[name]',
path: path.resolve(__dirname, '../../public/dist'),
publicPath: '/dist'
},
resolve: {
alias: {
amber: path.resolve(__dirname, '../../lib/amber/assets/js/amber.js')
}
},
module: {
rules: [
{
test: /\.css$/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader']
})
},
{
test: /\.(png|svg|jpg|gif)$/,
exclude: /node_modules/,
use: [
'file-loader?name=/images/[name].[ext]'
]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
exclude: /node_modules/,
use: [
'file-loader?name=/[name].[ext]'
]
},
{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['env']
}
}
]
},
plugins: [
new ExtractTextPlugin('main.bundle.css'),
],
// For more info about webpack logs see: https://webpack.js.org/configuration/stats/
stats: 'errors-only'
};
module.exports = config;
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./common.js');
module.exports = merge(common, {
devtool: 'inline-source-map'
});
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./common.js');
module.exports = merge(common, {
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false }
})
]
});
version: '2'
services:
app:
build: .
image: plume
command: amber watch
environment:
DATABASE_URL: postgres://admin:password@db:5432/plume_development
ports:
- 3000:3000
links:
- db
volumes:
- .:/app
- nodes:/app/node_modules
- shards:/app/lib
migrate:
build: .
image: plume
command: bash -c 'while ! nc -q 1 db 5432 </dev/null; do sleep 1; done && amber db migrate seed'
environment:
DATABASE_URL: postgres://admin:password@db:5432/plume_development
volumes:
- .:/app
links:
- db
db:
image: postgres
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
POSTGRES_DB: plume_development
volumes:
- db:/var/lib/postgres/data
volumes:
db:
nodes:
shards:
{
"name": "plume",
"version": "0.1.0",
"description": "Plume with Amber",
"private": true,
"author": "Bat'",
"license": "UNLICENSED",
"scripts": {
"build": "webpack --config config/webpack/development.js",
"watch": "webpack -w --config config/webpack/development.js",
"release": "webpack -p --config config/webpack/production.js",
"test": "echo \"No test specified\" && exit 1"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"css-loader": "^0.28.7",
"file-loader": "^1.1.5",
"node-sass": "^4.6.0",
"sass-loader": "^6.0.6",
"style-loader": "^0.19.0",
"webpack": "^3.8.1",
"webpack-merge": "^4.1.1",
"extract-text-webpack-plugin": "^3.0.2"
}
}
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->
<!-- Most restrictive policy: -->
<site-control permitted-cross-domain-policies="none"/>
<!-- Least restrictive policy: -->
<!--
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
-->
</cross-domain-policy>
/*
* Globals
*/
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #555; }
h1, .h1,
h2, .h2,
h3, .h3,
h4, .h4,
h5, .h5,
h6, .h6 {
margin-top: 0;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: normal;
color: #333; }
/*
* Override Bootstrap's default container.
*/
@media (min-width: 1200px) {
.container {
width: 970px; } }
/*
* Masthead for nav
*/
.masthead {
background-color: #f4994b;
-webkit-box-shadow: inset 0 -2px 5px rgba(0, 0, 0, 0.1);
box-shadow: inset 0 -2px 5px rgba(0, 0, 0, 0.1); }
/* Nav links */
.nav-item {
position: relative;
display: inline-block;
padding: 10px;
font-weight: 500;
color: #ffe4cd; }
.nav-item:hover,
.nav-item:focus {
color: #fff;
text-decoration: none; }
/* Active state gets a caret at the bottom */
.nav .active {
color: #fff; }
.nav .active:after {
position: absolute;
bottom: 0;
left: 50%;
width: 0;
height: 0;
margin-left: -5px;
vertical-align: middle;
content: " ";
border-right: 5px solid transparent;
border-bottom: 5px solid;
border-left: 5px solid transparent; }
.main {
padding-top: 20px; }
#logo {
background-color: #f4994b;
background-image: url(/dist/images/logo.png);
background-size: contain;
width: 200px;
height: 278px; }
/* Hide logo in small screens */
@media (max-width: 767px) {
#logo {
display: none; } }
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJtYWluLmJ1bmRsZS5jc3MiLCJzb3VyY2VSb290IjoiIn0=*/
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment