Skip to content

Commit

Permalink
use Phoenix 0.14, use brunch and bower for asset management
Browse files Browse the repository at this point in the history
  • Loading branch information
gutschilla committed Jul 15, 2015
1 parent 47bd803 commit d6a41ed
Show file tree
Hide file tree
Showing 63 changed files with 13,621 additions and 8,486 deletions.
2 changes: 1 addition & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"directory": "priv/static/bower_components"
"directory": "bower_components"
}
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ erl_crash.dump
/node_modules

# bower-installed stuff
/priv/static/bower_components
/bower_components

# for real products, uncomment this:
# /config/prod.secret.exs

# Since we are building js and css from web/static,
# we ignore priv/static/{css,js}. You may want to
# comment this depending on your deployment strategy.
/priv/static/css
/priv/static/js

# used by brunch/sass
/web/static/css/.sass-cache/

# When I use Komodo IDE
/phoenix-skeleton.komodoproject
57 changes: 42 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# Phoenix-Sekeleton

Master branch currently supports Phoenix v0.11.0
Master branch currently supports Phoenix v0.14.0

# Coming soon!
# What's new in 0.14.0?

Yay! Nothing much happened here for the last few weeks.
- Support fort phoenix 0.14
- integrate brunch to handle assets
- improved documentation: added Postgre commands for fast setup of development database
- deployment guide: systemd files, running skeleton app as unprivileged user
- return to old "Skeleton" namespace for everything.

- Next release will support phoenix 0.13.1 and integrate more nicely with brunch or webpack (still cannot decide on what to use).
- Have navigation as Elixir Agent
# Coming Soon!

- Have navigation as Elixir Agent (current implementation is way too quick'n'dirty.

## Feature Roadmap
- [x] Basic routing
Expand All @@ -17,7 +22,7 @@ Yay! Nothing much happened here for the last few weeks.
- [x] basic Login page
- [x] Authorization
- [x] Userroles Ecto defintion
- [x] Skeleton4.Helper.roles_of( user ) returns string_
- [x] Skeleton.Helper.roles_of( user ) returns string_
- [ ] Means to check for roles in controllers/actions
- [x] Memcached Session store
- this is done via the plug gutschilla/plug-session-memcached
Expand All @@ -32,11 +37,22 @@ Yay! Nothing much happened here for the last few weeks.
- [ ] CouchDB connector
- [ ] Hello2.Admin.RESTCrud controller
- [ ] validate/save
- [ ] uploads
- [ ] Image resizing
- [ ] uploads ()
- [ ] Image resizing (will be done via dragonfly-server [using convert/ImageMagick])
- [ ] TinySite CMS
- [ ] Create mix task to boostrap components instead of copy/paste+search/replace

# Installation

1. Install Elixir dependencies with `mix deps.get`
2. Install npm dependencies for ranch with `npm install`
- on Debuan/Ubuntu "deb.nodesource.com" works great
3. Install bower dependecies with `bower install`
4. Check system dependencies, run postgre dev script below
5. Start Phoenix endpoint with `mix phoenix.server`

Now you can visit `localhost:4000` from your browser.

# System dependencies

- Erlang/Elixir, of course ;-)
Expand All @@ -49,12 +65,23 @@ Yay! Nothing much happened here for the last few weeks.
- bower package manager
- tested with 1.3.12

# Installation
## Create development database

1. Install Elixir dependencies with `mix deps.get`
2. Install npm dependencies for ranch with `npm install`
- on Debuan/Ubuntu "deb.nodesource.com" works great
3. Install bower dependecies with `bower install`
2. Start Phoenix endpoint with `mix phoenix.server`
This will create a database "skeleton_dev" owned by "skeleton_dev_user" with password "skeleton_dev_pass". Tune this to yout needs.

Now you can visit `localhost:4000` from your browser.
```
CREATE ROLE skeleton_dev_user LOGIN
ENCRYPTED PASSWORD 'md5465fc2608ab7a4ebe4eaa198e63b85a7'
NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;
CREATE DATABASE skeleton_dev
WITH OWNER = skeleton_dev_user
ENCODING = 'UTF8'
TABLESPACE = pg_default
LC_COLLATE = 'de_DE.UTF-8'
LC_CTYPE = 'de_DE.UTF-8'
CONNECTION LIMIT = -1;
```

# Feedback

Is more than welcome. I am still learing this whole Elixir and Erlang/OTP thing so be rude, be harsh but be helpful.
19 changes: 9 additions & 10 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"name": "phoenix-skeleton4",
"version": "0.0.1",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"components"
],
"version": "0.14.0",
"authors": [
"Martin Gutsch <gutsch@zwoelf.net>"
],
Expand All @@ -14,15 +20,8 @@
"postgre"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"bootstrap": "~3.3.4",
"jquery": "~2.1.3"
"jquery": "1.*",
"bootstrap": "~3.3.5"
}
}
13 changes: 13 additions & 0 deletions brunch-config.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = config:
files:
javascripts: joinTo: 'js/app.js'
stylesheets: joinTo: 'css/app.css'
paths:
watched: ["web/static", "test/static"]
public: "priv/static"
plugins:
babel:
ignore: [
/^(web\/static\/vendor)/
/^(bower_components)/
]
39 changes: 0 additions & 39 deletions brunch-config.js

This file was deleted.

12 changes: 6 additions & 6 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
use Mix.Config

# Configures the endpoint
config :skeleton4, Skeleton4.Endpoint,
config :skeleton, Skeleton.Endpoint,
url: [host: "localhost"],
root: Path.expand("..", __DIR__),
secret_key_base: "Xr16fZ4OwibbjqGi8gy8ectpRuGuPpECjCbG9ChpCfqE0W1Y3kJrDUmRNlWSFeQ3",
debug_errors: false,
pubsub: [name: Skeleton4.PubSub,
root: Path.dirname(__DIR__),
secret_key_base: "wzTwKg+PNLR7M595wCG9aNDXgD46hTbrKrS714zbjiL/Jh6CwLai1p5cHATxVeUE",
render_errors: [default_format: "html"],
pubsub: [name: Skeleton.PubSub,
adapter: Phoenix.PubSub.PG2]

# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env}.exs"
14 changes: 8 additions & 6 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use Mix.Config
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with brunch.io to recompile .js and .css sources.
config :skeleton4, Skeleton4.Endpoint,
config :skeleton, Skeleton.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
cache_static_lookup: false,
watchers: [node: ["node_modules/brunch/bin/brunch", "watch"]]

# Watch static and templates for browser reloading.
config :skeleton4, Skeleton4.Endpoint,
config :skeleton, Skeleton.Endpoint,
live_reload: [
patterns: [
~r{priv/static/.*(js|css|png|jpeg|jpg|gif)$},
Expand All @@ -27,8 +27,10 @@ config :skeleton4, Skeleton4.Endpoint,
config :logger, :console, format: "[$level] $message\n"

# Configure your database
config :skeleton4, Skeleton4.Repo,
config :skeleton, Skeleton.Repo,
adapter: Ecto.Adapters.Postgres,
username: "skeleton4_user",
password: "skeleton4_pass",
database: "skeleton4"
username: "skeleton_dev_user",
password: "skeleton_dev_pass",
database: "skeleton_dev",
hostname: "192.168.0.240",
size: 10 # The amount of database connections in the pool
17 changes: 12 additions & 5 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@ use Mix.Config
#
# You should also configure the url host to something
# meaningful, we use this information when generating URLs.
config :skeleton4, Skeleton4.Endpoint,
#
# Finally, we also include the path to a manifest
# containing the digested version of static files. This
# manifest is generated by the mix phoenix.digest task
# which you typically run after static files are built.
config :skeleton, Skeleton.Endpoint,
http: [port: {:system, "PORT"}],
url: [host: "example.com"]
url: [host: "example.com", port: 80],
cache_static_manifest: "priv/static/manifest.json"

# ## SSL Support
#
# To get SSL working, you will need to add the `https` key
# to the previous section:
# to the previous section, and set your `:url` port to 443
#
# config:skeleton4, Skeleton4.Endpoint,
# config :skeleton, Skeleton.Endpoint,
# ...
# url: [host: "example.com", port: 443],
# https: [port: 443,
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")]
Expand All @@ -37,7 +44,7 @@ config :logger, level: :info
# Alternatively, you can configure exactly which server to
# start per endpoint:
#
# config :skeleton4, Skeleton4.Endpoint, server: true
# config :skeleton, Skeleton.Endpoint, server: true
#

# Finally import the config/prod.secret.exs
Expand Down
9 changes: 5 additions & 4 deletions config/prod.secret.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ use Mix.Config
# In this file, we keep production configuration that
# you likely want to automate and keep it away from
# your version control system.
config :skeleton4, Skeleton4.Endpoint,
secret_key_base: "bzaui+SHRFxYTfdej43TqcriqHel6HzJvXET5+d8Az8ihVtvQsCy5bP0GPp/mgUA"
config :skeleton, Skeleton.Endpoint,
secret_key_base: "k40PLP1kAhQHAjslbMA8c/9dp/1FptVYxH1fYVjT3YsqR/uN8HhUU+kj8WeXnZIr"

# Configure your database
config :skeleton4, Skeleton4.Repo,
config :skeleton, Skeleton.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
database: "skeleton4_prod"
database: "skeleton_prod",
size: 20 # The amount of database connections in the pool
14 changes: 7 additions & 7 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ use Mix.Config

# We don't run a server during test. If one is required,
# you can enable the server option below.
config :skeleton4, Skeleton4.Endpoint,
config :skeleton, Skeleton.Endpoint,
http: [port: 4001],
server: false

# Print only warnings and errors during test
config :logger, level: :warn

# Configure your database
config :skeleton4, Skeleton4.Repo,
config :skeleton, Skeleton.Repo,
adapter: Ecto.Adapters.Postgres,
username: "skeleton4_user",
password: "skeleton4_pass",
database: "skeleton4",
size: 1,
max_overflow: false
username: "postgres",
password: "postgres",
database: "skeleton_test",
pool: Ecto.Adapters.SQL.Sandbox, # Use a sandbox for transactional testing
size: 1
22 changes: 11 additions & 11 deletions lib/mix/tasks/skeleton.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ defmodule Mix.Tasks.Skeleton do

def run(_) do

Skeleton4.Repo.start_link
Skeleton.Repo.start_link

users = 1..1000
|> Enum.map fn( num ) ->
|> Enum.map fn( _num ) ->
username = "U-" <> Misc.Random.string
IO.puts username
user = %Skeleton4.User{ username: username }
Skeleton4.Repo.insert user
user = %Skeleton.User{ username: username }
Skeleton.Repo.insert user
end

roles = 1..100
|> Enum.map fn( num ) ->
|> Enum.map fn( _num ) ->
rolename = "R-" <> Misc.Random.string
IO.puts rolename
role = %Skeleton4.Userrole{ name: rolename }
Skeleton4.Repo.insert role
role = %Skeleton.Userrole{ name: rolename }
Skeleton.Repo.insert role
end

users
|> Enum.each fn( user ) ->
# link 1 to 10 roles to this user
0..(:random.uniform 10)
|> Enum.each fn( num ) ->
|> Enum.each fn( _num ) ->
role = roles |> Enum.at :random.uniform( length( roles ) - 1 )
try do
map = %Skeleton4.UserUserroleMap{ user_id: user.id, userrole_id: role.id }
Skeleton4.Repo.insert map
map = %Skeleton.UserUserroleMap{ user_id: user.id, userrole_id: role.id }
Skeleton.Repo.insert map
rescue
e in Postgrex.Error -> nil
_e in Postgrex.Error -> nil
end
end
end
Expand Down
Loading

0 comments on commit d6a41ed

Please sign in to comment.