Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ramansah committed Sep 28, 2018
0 parents commit a6ec9ca
Show file tree
Hide file tree
Showing 89 changed files with 10,154 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .formatter.exs
@@ -0,0 +1,18 @@
[
inputs: [
"lib/*/{lib,unicode,test}/**/*.{ex,exs}",
"lib/*/mix.exs",
"test/**/*.{ex,exs}",
],

locals_without_parens: [
# Formatter tests
assert_format: 2,
assert_format: 3,
assert_same: 1,
assert_same: 2,

# Errors tests
assert_eval_raise: 3
]
]
29 changes: 29 additions & 0 deletions .gitignore
@@ -0,0 +1,29 @@
# App artifacts
/_build
/db
/docs
/deps
/uploads
/*.ez

# Generated on crash by the VM
erl_crash.dump

# Generated on crash by NPM
npm-debug.log

# Static artifacts
/assets/node_modules

# Since we are building assets from assets/,
# we ignore priv/static. You may want to comment
# this depending on your deployment strategy.
/priv/static/

# Files matching config/*.secret.exs pattern contain sensitive
# data and you should not commit them into version control.
#
# Alternatively, you may comment the line below and commit the
# secrets files as long as you replace their contents by environment
# variables.
/config/*.secret.exs
1 change: 1 addition & 0 deletions Procfile
@@ -0,0 +1 @@
web: MIX_ENV=prod mix phx.server
18 changes: 18 additions & 0 deletions README.md
@@ -0,0 +1,18 @@
# Content Management System

Simple and Extensible Blog App built on Phoenix framework in Elixir.

## Features

* Ready to use blog engine
* Customizable templates
* Slug based routes
* Cover image for post

## Get Started

* Clone repository `git clone https://github.com/ramansah/cms.git`
* Fetch dependencies with `cd cms && mix deps.get`
* Setup database and seed data `mix ecto.setup`
* Install Node.js dependencies with `cd assets && npm install`
* Start Phoenix server `mix phx.server`
75 changes: 75 additions & 0 deletions assets/brunch-config.js
@@ -0,0 +1,75 @@
exports.config = {
// See http://brunch.io/#documentation for docs.
files: {
javascripts: {
joinTo: "js/app.js"

// To use a separate vendor.js bundle, specify two files path
// http://brunch.io/docs/config#-files-
// joinTo: {
// "js/app.js": /^js/,
// "js/vendor.js": /^(?!js)/
// }
//
// To change the order of concatenation of files, explicitly mention here
// order: {
// before: [
// "vendor/js/jquery-2.1.1.js",
// "vendor/js/bootstrap.min.js"
// ]
// }
},
stylesheets: {
joinTo: "css/app.css"
},
templates: {
joinTo: "js/app.js"
}
},

conventions: {
// This option sets where we should place non-css and non-js assets in.
// By default, we set this to "/assets/static". Files in this directory
// will be copied to `paths.public`, which is "priv/static" by default.
assets: [
/^(static)/
]
},

// Phoenix paths configuration
paths: {
// Dependencies and current project directories to watch
watched: [
"static", "css", "js", "vendor"
],
// Where to compile files to
public: "../priv/static"
},

// Configure your plugins
plugins: {
babel: {
// Do not use ES6 compiler in vendor code
ignore: [/vendor/]
},
sass: {
options: {
includePaths: [
"node_modules/bootstrap/scss",
"node_modules/font-awesome/scss"
],
precision: 8
}
}
},

modules: {
autoRequire: {
"js/app.js": ["js/app"]
}
},

npm: {
enabled: true
}
};
4 changes: 4 additions & 0 deletions assets/css/alert.scss
@@ -0,0 +1,4 @@
.alert {
position: fixed;
right: 20px;
}
10 changes: 10 additions & 0 deletions assets/css/app.scss
@@ -0,0 +1,10 @@
@import "bootstrap";
@import "font-awesome";
@import "sidebar";
@import "alert";
@import "home";
@import "navbar";

body {
font-family: 'Ubuntu', sans-serif;
}
30 changes: 30 additions & 0 deletions assets/css/home.scss
@@ -0,0 +1,30 @@

.card-columns {
column-count: 4;
}

.card-img-top {
object-fit: cover;
height: 200px;
}

.card {
font-size: 14px;
}

main, table, ul {
margin-top: 20px;
}

p {
margin-bottom: 0;
}

a {
text-decoration: none;
color: inherit;

&:hover {
color: inherit;
}
}
14 changes: 14 additions & 0 deletions assets/css/navbar.scss
@@ -0,0 +1,14 @@

.navbar {
z-index: 10;
border-bottom: solid 1px #555;
}

.navbar-dark {

.nav-link {
color: #eee !important;
font-size: 14px;
}

}
15 changes: 15 additions & 0 deletions assets/css/phoenix.scss
@@ -0,0 +1,15 @@

/* Phoenix flash messages */
.alert:empty { display: none; }

.logo {
width: 519px;
height: 71px;
display: inline-block;
margin-bottom: 1em;
background-image: url("/images/phoenix.png");
background-size: 519px 71px;
}



46 changes: 46 additions & 0 deletions assets/css/sidebar.scss
@@ -0,0 +1,46 @@
.sidenav {
height: 100%;
width: 160px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
overflow-x: hidden;
padding-top: 65px;

a {
padding: 10px 10px 10px 16px;
font-size: 14px;
color: #eee;
display: block;

i {
color: #9ca1a6;
font-size: 18px;
width: 25px;
text-align: center;
padding-right: 10px;
}

&:hover {
color: white;
text-decoration: none;
background: #191e23;
}

}

}

.main {
margin-left: 160px;
}

@media screen and (max-height: 450px) {
.sidenav {
padding-top: 65px;

a {font-size: 14px;}

}
}
21 changes: 21 additions & 0 deletions assets/js/app.js
@@ -0,0 +1,21 @@
// Brunch automatically concatenates all files in your
// watched paths. Those paths can be configured at
// config.paths.watched in "brunch-config.js".
//
// However, those files will only be executed if
// explicitly imported. The only exception are files
// in vendor, which are never wrapped in imports and
// therefore are always executed.

// Import dependencies
//
// If you no longer want to use a dependency, remember
// to also remove its path from "config.paths.watched".
import "phoenix_html"

// Import local files
//
// Local files can be imported directly using relative
// paths "./socket" or full ones "web/static/js/socket".

// import socket from "./socket"
62 changes: 62 additions & 0 deletions assets/js/socket.js
@@ -0,0 +1,62 @@
// NOTE: The contents of this file will only be executed if
// you uncomment its entry in "assets/js/app.js".

// To use Phoenix channels, the first step is to import Socket
// and connect at the socket path in "lib/web/endpoint.ex":
import {Socket} from "phoenix"

let socket = new Socket("/socket", {params: {token: window.userToken}})

// When you connect, you'll often need to authenticate the client.
// For example, imagine you have an authentication plug, `MyAuth`,
// which authenticates the session and assigns a `:current_user`.
// If the current user exists you can assign the user's token in
// the connection for use in the layout.
//
// In your "lib/web/router.ex":
//
// pipeline :browser do
// ...
// plug MyAuth
// plug :put_user_token
// end
//
// defp put_user_token(conn, _) do
// if current_user = conn.assigns[:current_user] do
// token = Phoenix.Token.sign(conn, "user socket", current_user.id)
// assign(conn, :user_token, token)
// else
// conn
// end
// end
//
// Now you need to pass this token to JavaScript. You can do so
// inside a script tag in "lib/web/templates/layout/app.html.eex":
//
// <script>window.userToken = "<%= assigns[:user_token] %>";</script>
//
// You will need to verify the user token in the "connect/2" function
// in "lib/web/channels/user_socket.ex":
//
// def connect(%{"token" => token}, socket) do
// # max_age: 1209600 is equivalent to two weeks in seconds
// case Phoenix.Token.verify(socket, "user socket", token, max_age: 1209600) do
// {:ok, user_id} ->
// {:ok, assign(socket, :user, user_id)}
// {:error, reason} ->
// :error
// end
// end
//
// Finally, pass the token on connect as below. Or remove it
// from connect if you don't care about authentication.

socket.connect()

// Now that you are connected, you can join channels with a topic:
let channel = socket.channel("topic:subtopic", {})
channel.join()
.receive("ok", resp => { console.log("Joined successfully", resp) })
.receive("error", resp => { console.log("Unable to join", resp) })

export default socket

0 comments on commit a6ec9ca

Please sign in to comment.