Commit 58d89d2c authored by Bat's avatar Bat
Browse files

Basic blog setup

parent e75ace6a
require "json"
require "./initializers/**"
require "amber"
require "../src/models/**"
require "../src/activity_pub"
require "../src/controllers/application_controller"
require "../src/controllers/**"
......
......@@ -22,7 +22,7 @@ process_count: 1
# ssl_key_file:
# ssl_cert_file:
redis_url: "redis://localhost:6379"
database_url: postgres://postgres:@localhost:5432/plume_development
database_url: postgres://amber:amber@localhost:5432/plume_development
session:
key: amber.session
store: signed_cookie
......
......@@ -12,4 +12,4 @@ module Repo
end
end
Crecto::DbLogger.set_handler(Amber.settings.logger.dup)
Crecto::DbLogger.set_handler(Logger.new(STDOUT))
......@@ -29,5 +29,8 @@ Amber::Server.configure do |app|
routes :web do
get "/", HomeController, :index
post "/configure", HomeController, :configure
get "/blog", ActivityPub::BlogController, :show
end
end
-- +micrate Up
CREATE TABLE blogs (
id BIGSERIAL PRIMARY KEY,
title VARCHAR,
subtitle VARCHAR,
description VARCHAR,
default_license VARCHAR,
created_at TIMESTAMP,
updated_at TIMESTAMP
);
-- +micrate Down
DROP TABLE IF EXISTS blogs;
-- +micrate Up
ALTER TABLE blogs ADD COLUMN actor_id VARCHAR;
-- +micrate Down
ALTER TABLE blogs DROP COLUMN actor_id;
\ No newline at end of file
/*
* 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=*/
font-family: sans-serif; }
main {
max-width: 1280px;
margin: auto; }
input:not([type="submit"]) {
border: none;
border-bottom: 1px solid gray;
width: 100%; }
input[type="submit"] {
padding: 10px 25px;
border: none;
border-radius: 100px;
margin: auto;
cursor: pointer;
background: green;
color: white; }
input, textarea {
display: block;
margin-bottom: 50px;
margin-top: 20px; }
textarea {
width: 100%;
min-height: 150px;
resize: none;
font-family: sans-serif; }
label {
display: block;
color: gray; }
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJtYWluLmJ1bmRsZS5jc3MiLCJzb3VyY2VSb290IjoiIn0=*/
\ No newline at end of file
......@@ -68,133 +68,9 @@
/***/ (function(module, exports, __webpack_require__) {
"use strict";
//import Amber from 'amber'
var _amber = __webpack_require__(1);
var _amber2 = _interopRequireDefault(_amber);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var EVENTS = {
join: 'join',
leave: 'leave',
message: 'message'
};
var Channel = exports.Channel = function () {
function Channel(topic, socket) {
_classCallCheck(this, Channel);
this.topic = topic;
this.socket = socket;
this.onMessageHandlers = [];
}
_createClass(Channel, [{
key: 'join',
value: function join() {
this.socket.ws.send(JSON.stringify({ event: EVENTS.join, topic: this.topic }));
}
}, {
key: 'leave',
value: function leave() {
this.socket.ws.send(JSON.stringify({ event: EVENTS.leave, topic: this.topic }));
}
}, {
key: 'handleMessage',
value: function handleMessage(msg) {
this.onMessageHandlers.forEach(function (handler) {
if (handler.subject === msg.subject) handler.callback(msg.payload);
});
}
}, {
key: 'on',
value: function on(subject, callback) {
this.onMessageHandlers.push({ subject: subject, callback: callback });
}
}, {
key: 'push',
value: function push(subject, payload) {
this.socket.ws.send(JSON.stringify({ event: EVENTS.message, topic: this.topic, subject: subject, payload: payload }));
}
}]);
return Channel;
}();
var Socket = exports.Socket = function () {
function Socket(endpoint) {
_classCallCheck(this, Socket);
this.endpoint = endpoint;
this.ws = null;
this.channels = [];
}
_createClass(Socket, [{
key: 'connect',
value: function connect(params) {
var _this = this;
var opts = {
location: window.location.hostname,
port: window.location.port,
protocol: window.location.protocol === 'https:' ? 'wss:' : 'ws:'
};
if (params) Object.assign(opts, params);
if (opts.port) opts.location += ':' + opts.port;
return new Promise(function (resolve, reject) {
_this.ws = new WebSocket(opts.protocol + '//' + opts.location + _this.endpoint);
_this.ws.onmessage = function (msg) {
_this.handleMessage(msg);
};
_this.ws.onopen = function () {
return resolve();
};
});
}
}, {
key: 'channel',
value: function channel(topic) {
var channel = new Channel(topic, this);
this.channels.push(channel);
return channel;
}
}, {
key: 'handleMessage',
value: function handleMessage(msg) {
msg = JSON.parse(msg.data);
this.channels.forEach(function (channel) {
if (channel.topic === msg.topic) channel.handleMessage(msg);
});
}
}]);
return Socket;
}();
module.exports = {
Socket: Socket
};
/***/ })
/******/ ]);
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgYjA1NTZlYWIwOGQ5NTllYzM1ODAiLCJ3ZWJwYWNrOi8vLy4vc3JjL2Fzc2V0cy9qYXZhc2NyaXB0cy9tYWluLmpzIiwid2VicGFjazovLy8uL2xpYi9hbWJlci9hc3NldHMvanMvYW1iZXIuanMiXSwibmFtZXMiOlsiRVZFTlRTIiwiam9pbiIsImxlYXZlIiwibWVzc2FnZSIsIkNoYW5uZWwiLCJ0b3BpYyIsInNvY2tldCIsIm9uTWVzc2FnZUhhbmRsZXJzIiwid3MiLCJzZW5kIiwiSlNPTiIsInN0cmluZ2lmeSIsImV2ZW50IiwibXNnIiwiZm9yRWFjaCIsImhhbmRsZXIiLCJzdWJqZWN0IiwiY2FsbGJhY2siLCJwYXlsb2FkIiwicHVzaCIsIlNvY2tldCIsImVuZHBvaW50IiwiY2hhbm5lbHMiLCJwYXJhbXMiLCJvcHRzIiwibG9jYXRpb24iLCJ3aW5kb3ciLCJob3N0bmFtZSIsInBvcnQiLCJwcm90b2NvbCIsIk9iamVjdCIsImFzc2lnbiIsIlByb21pc2UiLCJyZXNvbHZlIiwicmVqZWN0IiwiV2ViU29ja2V0Iiwib25tZXNzYWdlIiwiaGFuZGxlTWVzc2FnZSIsIm9ub3BlbiIsImNoYW5uZWwiLCJwYXJzZSIsImRhdGEiLCJtb2R1bGUiLCJleHBvcnRzIl0sIm1hcHBpb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cm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbFxuIFx0X193ZWJwYWNrX3JlcXVpcmVfXy5vID0gZnVuY3Rpb24ob2JqZWN0LCBwcm9wZXJ0eSkgeyByZXR1cm4gT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKG9iamVjdCwgcHJvcGVydHkpOyB9O1xuXG4gXHQvLyBfX3dlYnBhY2tfcHVibGljX3BhdGhfX1xuIFx0X193ZWJwYWNrX3JlcXVpcmVfXy5wID0gXCIvZGlzdFwiO1xuXG4gXHQvLyBMb2FkIGVudHJ5IG1vZHVsZSBhbmQgcmV0dXJuIGV4cG9ydHNcbiBcdHJldHVybiBfX3dlYnBhY2tfcmVxdWlyZV9fKF9fd2VicGFja19yZXF1aXJlX18ucyA9IDApO1xuXG5cblxuLy8gV0VCUEFDSyBGT09URVIgLy9cbi8vIHdlYnBhY2svYm9vdHN0cmFwIGY1ODljNDQ5ZjJmM2Y4ODYzNmY5IiwiLy9pbXBvcnQgQW1iZXIgZnJvbSAnYW1iZXInXG5cblxuXG4vLyBXRUJQQUNLIEZPT1RFUiAvL1xuLy8gLi9zcmMvYXNzZXRzL2phdmFzY3JpcHRzL21haW4uanMiXSwic291cmNlUm9vdCI6IiJ9
\ No newline at end of file
version: 1.0
shards:
amber:
github: amberframework/amber
version: 0.6.7
callback:
github: mosop/callback
version: 0.6.3
cli:
github: amberframework/cli
version: 0.7.0
crecto:
github: Crecto/crecto
version: 0.8.4
db:
github: crystal-lang/crystal-db
version: 0.5.0
email:
github: arcage/crystal-email
version: 0.2.5
garnet_spec:
github: amberframework/garnet-spec
version: 0.1.1
jasper_helpers:
github: amberframework/jasper-helpers
version: 0.1.8
kilt:
github: jeromegn/kilt
version: 0.4.0
micrate:
github: juanedi/micrate
version: 0.3.0
mysql:
github: crystal-lang/crystal-mysql
version: 0.4.0
optarg:
github: mosop/optarg
version: 0.5.8
pg:
github: will/crystal-pg
version: 0.14.1
quartz_mailer:
github: amberframework/quartz-mailer
version: 0.5.1
radix:
github: luislavena/radix
version: 0.3.8
redis:
github: stefanwille/crystal-redis
version: 1.9.0
selenium:
github: ysbaddaden/selenium-webdriver-crystal
version: 0.3.0
shell-table:
github: jwaldrip/shell-table.cr
version: 0.9.2
slang:
github: jeromegn/slang
version: 1.7.1
spinner:
github: askn/spinner
version: 0.1.1
sqlite3:
github: crystal-lang/crystal-sqlite3
version: 0.9.0
string_inflection:
github: mosop/string_inflection
version: 0.2.1
teeplate:
github: amberframework/teeplate
version: 0.5.0
require "./utils"
require "./blog_object"
\ No newline at end of file
class ActivityPub::BlogObject
include Utils
def initialize (blog : Blog)
@blog = blog
end
def to_json
JSON.build do |json|
json.object do
json.field "@context", "https://www.w3.org/ns/activitystreams"
json.field "type", "Blog"
json.field "id", url "blog"
json.field "followers", url "blog/followers"
json.field "inbox", url "blog/inbox"
json.field "outbox", url "blog/outbox"
json.field "preferredUsername", @blog.actor_id
json.field "name", @blog.title
json.field "summary", @blog.description
end
end
end
end
\ No newline at end of file
module Utils
def url(path)
"https://#{Amber.settings.host}:#{Amber.settings.port}/#{path}/"
end
end
\ No newline at end of file
import Amber from 'amber'
//import Amber from 'amber'
$font-stack: "Helvetica Neue", Helvetica, Arial, sans-serif;
$background-color: #f4994b;
$nav-item-color: #ffe4cd;
/*
* Globals
*/
body {
font-family: $font-stack;
color: #555;
}
h1, .h1,
h2, .h2,
h3, .h3,
h4, .h4,
h5, .h5,
h6, .h6 {
margin-top: 0;
font-family: $font-stack;
font-weight: normal;
color: #333;
}
/*
* Override Bootstrap's default container.
*/
@media (min-width: 1200px) {
.container {
width: 970px;
}
font-family: sans-serif;
}
/*
* Masthead for nav
*/
.masthead {
background-color: $background-color;
-webkit-box-shadow: inset 0 -2px 5px rgba(0,0,0,.1);
box-shadow: inset 0 -2px 5px rgba(0,0,0,.1);
main {
max-width: 1280px;
margin: auto;
}
/* Nav links */
.nav-item {
position: relative;
display: inline-block;
padding: 10px;
font-weight: 500;
color: $nav-item-color;
}
.nav-item:hover,
.nav-item:focus {
color: #fff;
text-decoration: none;
input:not([type="submit"]) {
border: none;
border-bottom: 1px solid gray;
width: 100%;
}
/* 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;
input[type="submit"] {
padding: 10px 25px;
border: none;
border-radius: 100px;
margin: auto;
cursor: pointer;
background: green;
color: white;
}
.main {
padding-top: 20px;
input, textarea {
display: block;
margin-bottom: 50px;
margin-top: 20px;
}
#logo {
background-color: $background-color;
background-image: url("../images/logo.png");
background-size:contain;
width: 200px;
height:278px;
textarea {
width: 100%;
min-height: 150px;
resize: none;
font-family: sans-serif;
}
/* Hide logo in small screens */
@media (max-width: 767px) {
#logo {
display: none;
}
}
label {
display: block;
color: gray;
}
\ No newline at end of file
class ActivityPub::BlogController < ApplicationController
def show
blog = Repo.all(Blog, Query.limit(1))[0]
blog_object = BlogObject.new(blog)
respond_with { json blog_object.to_json }
end
end
\ No newline at end of file
......@@ -3,4 +3,12 @@ require "jasper_helpers"
class ApplicationController < Amber::Controller::Base
include JasperHelpers
LAYOUT = "application.ecr"
macro template (file, layout = true, partial = nil, path = "src/views", folder = __FILE__)
if Repo.all(Blog).size == 0
render("initial_config.ecr", folder: "home")
else
render({{file}}, layout: {{layout}}, partial: {{partial}}, path: {{path}}, folder: {{folder}})
end
end
end
class HomeController < ApplicationController
def index
render("index.ecr")
blog = Blog.get
template("index.ecr")
end
def configure
blog = Blog.new
blog.actor_id = "blog"
blog.title = params["title"]
blog.subtitle = params["subtitle"]
blog.description = params["description"]
blog.default_license = "CC-0"
Repo.insert(blog)
redirect_to(controller: :home, action: :index, status: 302)
end