maeku_core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Rakefile +36 -0
- data/app/assets/config/maeku_manifest.js +2 -0
- data/app/assets/javascripts/maeku/application.js +13 -0
- data/app/assets/javascripts/maeku/entries.js +2 -0
- data/app/assets/stylesheets/maeku/application.css +15 -0
- data/app/assets/stylesheets/maeku/entries.css +4 -0
- data/app/assets/stylesheets/scaffold.css +80 -0
- data/app/controllers/maeku/application_controller.rb +23 -0
- data/app/controllers/maeku/entries_controller.rb +71 -0
- data/app/jobs/maeku/application_job.rb +4 -0
- data/app/mailers/maeku/application_mailer.rb +6 -0
- data/app/models/concerns/maeku/author_methods.rb +11 -0
- data/app/models/maeku/application_record.rb +5 -0
- data/app/models/maeku/entry.rb +7 -0
- data/app/views/layouts/maeku/application.html.erb +17 -0
- data/app/views/maeku/entries/_form.html.erb +27 -0
- data/app/views/maeku/entries/edit.html.erb +9 -0
- data/app/views/maeku/entries/index.html.erb +24 -0
- data/app/views/maeku/entries/new.html.erb +5 -0
- data/app/views/maeku/entries/show.html.erb +7 -0
- data/config/locales/en.yml +23 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20180311204920_create_maeku_entries.rb +9 -0
- data/db/migrate/20180311212204_add_author_id_to_maeku_entries.rb +6 -0
- data/lib/maeku.rb +14 -0
- data/lib/maeku/engine.rb +5 -0
- data/lib/maeku/version.rb +3 -0
- data/lib/tasks/maeku_tasks.rake +4 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 90724e9c6d7fd1a4d118945dd92cf695686393668c9739dd5732d74184424f73
|
4
|
+
data.tar.gz: 03271eb8a95a7d29d1cdb960951bc5eb799c6ecbda2614be3c66419e8f583a75
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0d1e9a2aa8b4965760d12987181e4dff30e9b3fea1ccf748db4380c1f223ec402ae8f4f2eb92ebc11cee946afc5506145298e367cfed34dd4cfa887266931b05
|
7
|
+
data.tar.gz: 141715cea766e7f1b1e36cb1ff4b95e49ec4840953ebc0a4def5edced98a20a7028b8167a92f000f023ac6947feb12835001e92bbd7317a21e002b6581398095
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Maeku'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'test'
|
31
|
+
t.pattern = 'test/**/*_test.rb'
|
32
|
+
t.verbose = false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,80 @@
|
|
1
|
+
body {
|
2
|
+
background-color: #fff;
|
3
|
+
color: #333;
|
4
|
+
margin: 33px;
|
5
|
+
}
|
6
|
+
|
7
|
+
body, p, ol, ul, td {
|
8
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
9
|
+
font-size: 13px;
|
10
|
+
line-height: 18px;
|
11
|
+
}
|
12
|
+
|
13
|
+
pre {
|
14
|
+
background-color: #eee;
|
15
|
+
padding: 10px;
|
16
|
+
font-size: 11px;
|
17
|
+
}
|
18
|
+
|
19
|
+
a {
|
20
|
+
color: #000;
|
21
|
+
}
|
22
|
+
|
23
|
+
a:visited {
|
24
|
+
color: #666;
|
25
|
+
}
|
26
|
+
|
27
|
+
a:hover {
|
28
|
+
color: #fff;
|
29
|
+
background-color: #000;
|
30
|
+
}
|
31
|
+
|
32
|
+
th {
|
33
|
+
padding-bottom: 5px;
|
34
|
+
}
|
35
|
+
|
36
|
+
td {
|
37
|
+
padding: 0 5px 7px;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.field,
|
41
|
+
div.actions {
|
42
|
+
margin-bottom: 10px;
|
43
|
+
}
|
44
|
+
|
45
|
+
#notice {
|
46
|
+
color: green;
|
47
|
+
}
|
48
|
+
|
49
|
+
.field_with_errors {
|
50
|
+
padding: 2px;
|
51
|
+
background-color: red;
|
52
|
+
display: table;
|
53
|
+
}
|
54
|
+
|
55
|
+
#error_explanation {
|
56
|
+
width: 450px;
|
57
|
+
border: 2px solid red;
|
58
|
+
padding: 7px 7px 0;
|
59
|
+
margin-bottom: 20px;
|
60
|
+
background-color: #f0f0f0;
|
61
|
+
}
|
62
|
+
|
63
|
+
#error_explanation h2 {
|
64
|
+
text-align: left;
|
65
|
+
font-weight: bold;
|
66
|
+
padding: 5px 5px 5px 15px;
|
67
|
+
font-size: 12px;
|
68
|
+
margin: -7px -7px 0;
|
69
|
+
background-color: #c00;
|
70
|
+
color: #fff;
|
71
|
+
}
|
72
|
+
|
73
|
+
#error_explanation ul li {
|
74
|
+
font-size: 12px;
|
75
|
+
list-style: square;
|
76
|
+
}
|
77
|
+
|
78
|
+
label {
|
79
|
+
display: block;
|
80
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Maeku
|
2
|
+
class ApplicationController < ::ApplicationController
|
3
|
+
protect_from_forgery with: :exception
|
4
|
+
|
5
|
+
helper_method :current_author?
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def current_author
|
10
|
+
if respond_to? :current_user
|
11
|
+
current_user
|
12
|
+
elsif Maeku.current_author
|
13
|
+
Maeku.current_author
|
14
|
+
else
|
15
|
+
raise I18n.t 'controller.application.current_author.not_implemented'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def current_author?
|
20
|
+
@entry.author_id == current_author.id if @entry
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require_dependency "maeku/application_controller"
|
2
|
+
|
3
|
+
module Maeku
|
4
|
+
class EntriesController < ApplicationController
|
5
|
+
before_action :set_entry, only: [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
def index
|
8
|
+
@entries = current_author.entries
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@entry = Entry.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def edit
|
19
|
+
unless current_author?
|
20
|
+
flash[:error] = I18n.t 'controller.entries.edit.error'
|
21
|
+
redirect_to entries_url
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
26
|
+
@entry = Entry.new(entry_params)
|
27
|
+
@entry.author_id = current_author.id
|
28
|
+
|
29
|
+
if @entry.save
|
30
|
+
flash[:notice] = I18n.t 'controller.entries.create.success'
|
31
|
+
redirect_to @entry
|
32
|
+
else
|
33
|
+
flash[:error] = I18n.t 'controller.entries.create.error'
|
34
|
+
render :new
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def update
|
39
|
+
if @entry.update(entry_params) && current_author?
|
40
|
+
flash[:notice] = I18n.t 'controller.entries.update.success'
|
41
|
+
redirect_to @entry
|
42
|
+
else
|
43
|
+
flash[:error] = I18n.t 'controller.entries.update.error'
|
44
|
+
render :edit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def destroy
|
49
|
+
@entry = Entry.find(params[:id])
|
50
|
+
if current_author?
|
51
|
+
@entry.destroy
|
52
|
+
flash[:notice] = I18n.t 'controller.entries.destroy.success'
|
53
|
+
redirect_to entries_url
|
54
|
+
else
|
55
|
+
flash[:error] = I18n.t 'controller.entries.destroy.error'
|
56
|
+
redirect_to entries_url
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def entry_params
|
63
|
+
params.require(:entry).permit(:entry, :author_id)
|
64
|
+
end
|
65
|
+
|
66
|
+
def set_entry
|
67
|
+
@entry = Entry.find(params[:id])
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Maeku</title>
|
5
|
+
<%= stylesheet_link_tag "journal/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "journal/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<% if flash %>
|
11
|
+
<% flash.each do |key, value| %>
|
12
|
+
<div class="alert alert-<%= key %>"><%= value %></div>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
<%= yield %>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%= form_with(model: entry, local: true) do |form| %>
|
2
|
+
<% if entry.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2>
|
5
|
+
<%= concat(
|
6
|
+
pluralize(entry.errors.count, "error"),
|
7
|
+
I18n.t('view.before_error_list')
|
8
|
+
) %>
|
9
|
+
</h2>
|
10
|
+
|
11
|
+
<ul>
|
12
|
+
<% entry.errors.full_messages.each do |message| %>
|
13
|
+
<li><%= message %></li>
|
14
|
+
<% end %>
|
15
|
+
</ul>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<div class="field">
|
20
|
+
<%= form.label :entry %>
|
21
|
+
<%= form.text_area :entry, id: :entry_entry %>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div class="actions">
|
25
|
+
<%= form.submit %>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<h1>Entries</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<th>Entry</th>
|
7
|
+
<th colspan="3"></th>
|
8
|
+
</tr>
|
9
|
+
</thead>
|
10
|
+
|
11
|
+
<tbody>
|
12
|
+
<% @entries.each do |entry| %>
|
13
|
+
<tr>
|
14
|
+
<td><%= entry.entry %></td>
|
15
|
+
<td><%= link_to 'Show', entry %></td>
|
16
|
+
<td><%= link_to 'Edit', edit_entry_path(entry) if current_author? %></td>
|
17
|
+
</tr>
|
18
|
+
<% end %>
|
19
|
+
</tbody>
|
20
|
+
</table>
|
21
|
+
|
22
|
+
<br>
|
23
|
+
|
24
|
+
<%= link_to 'New Entry', new_entry_path %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
en:
|
2
|
+
controller:
|
3
|
+
application:
|
4
|
+
current_author:
|
5
|
+
not_implemented: >
|
6
|
+
Your application requires a 'current_user' method. If you use an
|
7
|
+
authentication gem like 'devise', this method is provided for you.
|
8
|
+
Your user model should also include the module `Maeku::AuthorMethods`
|
9
|
+
to be compatible with `maeku_core`.
|
10
|
+
entries:
|
11
|
+
create:
|
12
|
+
error: Entry could not be created. Contact the site administrator.
|
13
|
+
success: Entry was successfully created.
|
14
|
+
destroy:
|
15
|
+
error: Entry could not be destroyed. Contact the site administrator.
|
16
|
+
success: Entry was successfully destroyed.
|
17
|
+
edit:
|
18
|
+
error: You do not have permission to edit this entry.
|
19
|
+
update:
|
20
|
+
error: Entry could not be updated. Contact the site administrator.
|
21
|
+
success: Entry was successfully updated.
|
22
|
+
view:
|
23
|
+
before_error_list: prohibited this entry from being saved:
|
data/config/routes.rb
ADDED
data/lib/maeku.rb
ADDED
data/lib/maeku/engine.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maeku_core
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Benjamin Willems
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.3.11
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.3.11
|
41
|
+
description: A journal for all of your thoughts and feelings.
|
42
|
+
email:
|
43
|
+
- bw@benjaminwil.info
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- Rakefile
|
49
|
+
- app/assets/config/maeku_manifest.js
|
50
|
+
- app/assets/javascripts/maeku/application.js
|
51
|
+
- app/assets/javascripts/maeku/entries.js
|
52
|
+
- app/assets/stylesheets/maeku/application.css
|
53
|
+
- app/assets/stylesheets/maeku/entries.css
|
54
|
+
- app/assets/stylesheets/scaffold.css
|
55
|
+
- app/controllers/maeku/application_controller.rb
|
56
|
+
- app/controllers/maeku/entries_controller.rb
|
57
|
+
- app/jobs/maeku/application_job.rb
|
58
|
+
- app/mailers/maeku/application_mailer.rb
|
59
|
+
- app/models/concerns/maeku/author_methods.rb
|
60
|
+
- app/models/maeku/application_record.rb
|
61
|
+
- app/models/maeku/entry.rb
|
62
|
+
- app/views/layouts/maeku/application.html.erb
|
63
|
+
- app/views/maeku/entries/_form.html.erb
|
64
|
+
- app/views/maeku/entries/edit.html.erb
|
65
|
+
- app/views/maeku/entries/index.html.erb
|
66
|
+
- app/views/maeku/entries/new.html.erb
|
67
|
+
- app/views/maeku/entries/show.html.erb
|
68
|
+
- config/locales/en.yml
|
69
|
+
- config/routes.rb
|
70
|
+
- db/migrate/20180311204920_create_maeku_entries.rb
|
71
|
+
- db/migrate/20180311212204_add_author_id_to_maeku_entries.rb
|
72
|
+
- lib/maeku.rb
|
73
|
+
- lib/maeku/engine.rb
|
74
|
+
- lib/maeku/version.rb
|
75
|
+
- lib/tasks/maeku_tasks.rake
|
76
|
+
homepage: https://github.com/maeku/maeku
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.7.6
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: A Ruby on Rails-based journalling platform.
|
100
|
+
test_files: []
|