txtblx 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +11 -1
- data/config/locales/activerecord.de.yml +1 -1
- data/lib/txtblx/ability_mixin.rb +8 -2
- data/lib/txtblx/admin/textblocks.rb +20 -9
- data/lib/txtblx/version.rb +1 -1
- data/spec/dummy/log/test.log +80 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 664e6521e2b4b82dffadfcaff363f8b37fc0e857
|
4
|
+
data.tar.gz: cd91629c4b1a4731ba055c4363bc1124b7fecefd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96807fff6a9eea234586f6647a764f4f3a5a74aae0ad95442e3b96fd7c5c519c5b8169cedf40a78d391c3fecd36e9b3bad1c60795fa88813d147e2c946169d3d
|
7
|
+
data.tar.gz: 782d695e11ce867657f81c017b6e2f8231f15c2e85ccddb9513a21f1076ce502a8ff52af3923e547d05f5ab0342d168f0b11e511544aeb7cfa9d465aeccc129f
|
data/README.md
CHANGED
@@ -34,6 +34,12 @@ Txtblx comes with an ActiveAdmin page to manage Textblocks
|
|
34
34
|
### CanCan Integration
|
35
35
|
|
36
36
|
Txtblx provides default CanCan Abilities for its model.
|
37
|
+
|
38
|
+
There are two sets of abilities:
|
39
|
+
|
40
|
+
* Full
|
41
|
+
* Editor can only change text and may not create or delete textblocks.
|
42
|
+
|
37
43
|
Use the AbilityMixin to grant them to your user model inside your Ability-class.
|
38
44
|
|
39
45
|
# app/models/ability.rb
|
@@ -42,7 +48,11 @@ Use the AbilityMixin to grant them to your user model inside your Ability-class.
|
|
42
48
|
include Txtblx::AbilityMixin
|
43
49
|
|
44
50
|
def initialize(user)
|
45
|
-
|
51
|
+
txtblx_editor_abilities(user)
|
52
|
+
|
53
|
+
if user.admin?
|
54
|
+
txtblx_full_abilities(user)
|
55
|
+
end
|
46
56
|
end
|
47
57
|
end
|
48
58
|
|
data/lib/txtblx/ability_mixin.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
module Txtblx
|
2
2
|
module AbilityMixin
|
3
3
|
# Call this in the ability initializer of the host app
|
4
|
-
def
|
4
|
+
def txtblx_full_abilities(user)
|
5
5
|
return if user.nil?
|
6
6
|
|
7
7
|
can(:manage, Textblock)
|
8
8
|
end
|
9
|
+
|
10
|
+
def txtblx_editor_abilities(user)
|
11
|
+
return if user.nil?
|
12
|
+
|
13
|
+
can(:read, Textblock)
|
14
|
+
can(:update, Textblock)
|
15
|
+
end
|
9
16
|
end
|
10
17
|
end
|
11
|
-
|
@@ -1,27 +1,38 @@
|
|
1
1
|
module Txtblx
|
2
2
|
if defined?(ActiveAdmin)
|
3
3
|
ActiveAdmin.register Textblock, as: 'Textblock' do
|
4
|
-
actions :all
|
4
|
+
actions :all
|
5
|
+
filter :description
|
6
|
+
filter :text
|
5
7
|
|
6
8
|
index do
|
7
|
-
column :key
|
8
|
-
|
9
|
+
column :key if authorized?(:manage, Textblock)
|
10
|
+
column :description do |textblock|
|
11
|
+
link_to(textblock.description, admin_textblock_path(textblock))
|
9
12
|
end
|
10
|
-
column :description
|
11
13
|
end
|
12
14
|
|
13
|
-
show do |textblock|
|
15
|
+
show title: :description do |textblock|
|
14
16
|
div :class => :columns do
|
15
17
|
attributes_table_for textblock do
|
16
|
-
row :key
|
18
|
+
row :key if authorized?(:manage, textblock)
|
17
19
|
row :description
|
18
|
-
row :text
|
20
|
+
row :text do
|
21
|
+
textblock.text_html
|
22
|
+
end
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
23
|
-
form do |f|
|
24
|
-
|
27
|
+
form title: :description do |f|
|
28
|
+
if authorized?(:manage, f.object)
|
29
|
+
f.inputs :key, :description, :text
|
30
|
+
else
|
31
|
+
f.inputs do
|
32
|
+
li("<label>Beschreibung</label> <b>#{f.object.description}</b>".html_safe)
|
33
|
+
f.input :text
|
34
|
+
end
|
35
|
+
end
|
25
36
|
f.actions do
|
26
37
|
f.action :submit
|
27
38
|
f.action :cancel, as: :link, button_html: {class: 'button'}
|
data/lib/txtblx/version.rb
CHANGED
data/spec/dummy/log/test.log
CHANGED
@@ -2645,3 +2645,83 @@ Completed 200 OK in 16ms (Views: 15.0ms | ActiveRecord: 0.2ms)
|
|
2645
2645
|
AND t_published.record_type = 'Txtblx::Textblock'
|
2646
2646
|
AND t_published.tag = 'published' WHERE (t_published.superseded_at IS NULL) AND "txtblx_textblocks"."key" = ? LIMIT 1 [["key", "homepage.welcome"]]
|
2647
2647
|
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
2648
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
2649
|
+
[1m[35mTxtblx::Textblock Load (0.3ms)[0m SELECT "txtblx_textblocks".* FROM "txtblx_textblocks" INNER JOIN snaps_tags t_published
|
2650
|
+
ON txtblx_textblocks.id = t_published.record_id
|
2651
|
+
AND t_published.record_type = 'Txtblx::Textblock'
|
2652
|
+
AND t_published.tag = 'published' WHERE (t_published.superseded_at IS NULL) AND "txtblx_textblocks"."key" = ? LIMIT 1 [["key", "homepage.welcome"]]
|
2653
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
2654
|
+
[1m[35m (0.0ms)[0m begin transaction
|
2655
|
+
[1m[36m (0.1ms)[0m [1mSAVEPOINT active_record_1[0m
|
2656
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "txtblx_textblocks" ("perma_id", "key", "description", "text", "text_html", "path", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["perma_id", 1], ["key", "homepage.welcome"], ["description", ""], ["text", ""], ["text_html", "Welcome to Dummy App"], ["path", "MyString"], ["created_at", "2015-04-09 14:19:19.799075"], ["updated_at", "2015-04-09 14:19:19.799075"]]
|
2657
|
+
[1m[36mSQL (0.2ms)[0m [1mUPDATE "snaps_tags" SET "superseded_at" = '2015-04-09 14:19:19.814796' WHERE "snaps_tags"."id" IN (SELECT "snaps_tags"."id" FROM "snaps_tags" INNER JOIN txtblx_textblocks
|
2658
|
+
ON txtblx_textblocks.id = snaps_tags.record_id
|
2659
|
+
AND snaps_tags.record_type = 'Txtblx::Textblock'
|
2660
|
+
AND perma_id = 1 WHERE "snaps_tags"."tag" = ? AND "snaps_tags"."superseded_at" IS NULL)[0m [["tag", "draft"]]
|
2661
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO "snaps_tags" ("record_id", "record_type", "tag", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["record_id", 1], ["record_type", "Txtblx::Textblock"], ["tag", "draft"], ["created_at", "2015-04-09 14:19:19.815809"], ["updated_at", "2015-04-09 14:19:19.815809"]]
|
2662
|
+
[1m[36m (0.0ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
2663
|
+
[1m[35m (0.0ms)[0m SAVEPOINT active_record_1
|
2664
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "txtblx_textblocks" ("perma_id", "key", "description", "text", "text_html", "path", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?)[0m [["perma_id", 1], ["key", "homepage.welcome"], ["description", ""], ["text", ""], ["text_html", "Welcome to Dummy App"], ["path", "MyString"], ["created_at", "2015-04-09 14:19:19.799075"], ["updated_at", "2015-04-09 14:19:19.818111"]]
|
2665
|
+
[1m[35m (0.0ms)[0m RELEASE SAVEPOINT active_record_1
|
2666
|
+
[1m[36m (0.0ms)[0m [1mSAVEPOINT active_record_1[0m
|
2667
|
+
[1m[35mSQL (0.1ms)[0m UPDATE "snaps_tags" SET "superseded_at" = '2015-04-09 14:19:19.820326' WHERE "snaps_tags"."id" IN (SELECT "snaps_tags"."id" FROM "snaps_tags" INNER JOIN txtblx_textblocks
|
2668
|
+
ON txtblx_textblocks.id = snaps_tags.record_id
|
2669
|
+
AND snaps_tags.record_type = 'Txtblx::Textblock'
|
2670
|
+
AND perma_id = 1 WHERE "snaps_tags"."tag" = ? AND "snaps_tags"."superseded_at" IS NULL) [["tag", "published"]]
|
2671
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "snaps_tags" ("record_id", "record_type", "tag", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?)[0m [["record_id", 2], ["record_type", "Txtblx::Textblock"], ["tag", "published"], ["created_at", "2015-04-09 14:19:19.820928"], ["updated_at", "2015-04-09 14:19:19.820928"]]
|
2672
|
+
[1m[35m (0.0ms)[0m RELEASE SAVEPOINT active_record_1
|
2673
|
+
[1m[36mTxtblx::Textblock Load (0.1ms)[0m [1mSELECT "txtblx_textblocks".* FROM "txtblx_textblocks" INNER JOIN snaps_tags t_published
|
2674
|
+
ON txtblx_textblocks.id = t_published.record_id
|
2675
|
+
AND t_published.record_type = 'Txtblx::Textblock'
|
2676
|
+
AND t_published.tag = 'published' WHERE (t_published.superseded_at IS NULL) AND "txtblx_textblocks"."key" = ? LIMIT 1[0m [["key", "homepage.welcome"]]
|
2677
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
2678
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
2679
|
+
[1m[35m (0.1ms)[0m SAVEPOINT active_record_1
|
2680
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "txtblx_textblocks" ("perma_id", "key", "description", "text", "text_html", "path", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?)[0m [["perma_id", 1], ["key", "homepage.welcome"], ["description", ""], ["text", ""], ["text_html", "Welcome to Dummy App"], ["path", "MyString"], ["created_at", "2015-04-09 14:19:19.827632"], ["updated_at", "2015-04-09 14:19:19.827632"]]
|
2681
|
+
[1m[35mSQL (0.1ms)[0m UPDATE "snaps_tags" SET "superseded_at" = '2015-04-09 14:19:19.830000' WHERE "snaps_tags"."id" IN (SELECT "snaps_tags"."id" FROM "snaps_tags" INNER JOIN txtblx_textblocks
|
2682
|
+
ON txtblx_textblocks.id = snaps_tags.record_id
|
2683
|
+
AND snaps_tags.record_type = 'Txtblx::Textblock'
|
2684
|
+
AND perma_id = 1 WHERE "snaps_tags"."tag" = ? AND "snaps_tags"."superseded_at" IS NULL) [["tag", "draft"]]
|
2685
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "snaps_tags" ("record_id", "record_type", "tag", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?)[0m [["record_id", 1], ["record_type", "Txtblx::Textblock"], ["tag", "draft"], ["created_at", "2015-04-09 14:19:19.830719"], ["updated_at", "2015-04-09 14:19:19.830719"]]
|
2686
|
+
[1m[35m (0.0ms)[0m RELEASE SAVEPOINT active_record_1
|
2687
|
+
[1m[36m (0.0ms)[0m [1mSAVEPOINT active_record_1[0m
|
2688
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO "txtblx_textblocks" ("perma_id", "key", "description", "text", "text_html", "path", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["perma_id", 1], ["key", "homepage.welcome"], ["description", ""], ["text", ""], ["text_html", "Welcome to Dummy App"], ["path", "MyString"], ["created_at", "2015-04-09 14:19:19.827632"], ["updated_at", "2015-04-09 14:19:19.832566"]]
|
2689
|
+
[1m[36m (0.0ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
2690
|
+
[1m[35m (0.0ms)[0m SAVEPOINT active_record_1
|
2691
|
+
[1m[36mSQL (0.1ms)[0m [1mUPDATE "snaps_tags" SET "superseded_at" = '2015-04-09 14:19:19.834603' WHERE "snaps_tags"."id" IN (SELECT "snaps_tags"."id" FROM "snaps_tags" INNER JOIN txtblx_textblocks
|
2692
|
+
ON txtblx_textblocks.id = snaps_tags.record_id
|
2693
|
+
AND snaps_tags.record_type = 'Txtblx::Textblock'
|
2694
|
+
AND perma_id = 1 WHERE "snaps_tags"."tag" = ? AND "snaps_tags"."superseded_at" IS NULL)[0m [["tag", "published"]]
|
2695
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO "snaps_tags" ("record_id", "record_type", "tag", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["record_id", 2], ["record_type", "Txtblx::Textblock"], ["tag", "published"], ["created_at", "2015-04-09 14:19:19.835201"], ["updated_at", "2015-04-09 14:19:19.835201"]]
|
2696
|
+
[1m[36m (0.0ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
2697
|
+
Started GET "/" for 127.0.0.1 at 2015-04-09 16:19:19 +0200
|
2698
|
+
Processing by DummiesController#index as HTML
|
2699
|
+
[1m[35mTxtblx::Textblock Load (0.1ms)[0m SELECT "txtblx_textblocks".* FROM "txtblx_textblocks" INNER JOIN snaps_tags t_published
|
2700
|
+
ON txtblx_textblocks.id = t_published.record_id
|
2701
|
+
AND t_published.record_type = 'Txtblx::Textblock'
|
2702
|
+
AND t_published.tag = 'published' WHERE (t_published.superseded_at IS NULL) AND "txtblx_textblocks"."key" = ? LIMIT 1 [["key", "homepage.welcome"]]
|
2703
|
+
Rendered dummies/index.html.erb within layouts/application (2.8ms)
|
2704
|
+
Completed 200 OK in 14ms (Views: 13.3ms | ActiveRecord: 0.1ms)
|
2705
|
+
[1m[36m (0.3ms)[0m [1mrollback transaction[0m
|
2706
|
+
[1m[35m (0.1ms)[0m begin transaction
|
2707
|
+
[1m[36m (0.1ms)[0m [1mSAVEPOINT active_record_1[0m
|
2708
|
+
[1m[35m (0.1ms)[0m SELECT MAX("txtblx_textblocks"."perma_id") FROM "txtblx_textblocks"
|
2709
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "txtblx_textblocks" ("key", "text", "text_html", "perma_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?)[0m [["key", "some key"], ["text", "some text inlcuding http://example.com"], ["text_html", "<p>some text inlcuding <a href=\"http://example.com\" target=\"_blank\" rel=\"nofollow\">http://example.com</a></p>"], ["perma_id", 1], ["created_at", "2015-04-09 14:19:19.969315"], ["updated_at", "2015-04-09 14:19:19.969315"]]
|
2710
|
+
[1m[35mSQL (0.1ms)[0m UPDATE "snaps_tags" SET "superseded_at" = '2015-04-09 14:19:19.971289' WHERE "snaps_tags"."id" IN (SELECT "snaps_tags"."id" FROM "snaps_tags" INNER JOIN txtblx_textblocks
|
2711
|
+
ON txtblx_textblocks.id = snaps_tags.record_id
|
2712
|
+
AND snaps_tags.record_type = 'Txtblx::Textblock'
|
2713
|
+
AND perma_id = 1 WHERE "snaps_tags"."tag" = ? AND "snaps_tags"."superseded_at" IS NULL) [["tag", "draft"]]
|
2714
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "snaps_tags" ("record_id", "record_type", "tag", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?)[0m [["record_id", 1], ["record_type", "Txtblx::Textblock"], ["tag", "draft"], ["created_at", "2015-04-09 14:19:19.971990"], ["updated_at", "2015-04-09 14:19:19.971990"]]
|
2715
|
+
[1m[35m (0.0ms)[0m RELEASE SAVEPOINT active_record_1
|
2716
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
2717
|
+
[1m[35m (0.0ms)[0m begin transaction
|
2718
|
+
[1m[36m (0.0ms)[0m [1mSAVEPOINT active_record_1[0m
|
2719
|
+
[1m[35m (0.1ms)[0m SELECT MAX("txtblx_textblocks"."perma_id") FROM "txtblx_textblocks"
|
2720
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "txtblx_textblocks" ("key", "text", "text_html", "perma_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?)[0m [["key", "some key"], ["text", "some text"], ["text_html", "<p>some text</p>"], ["perma_id", 1], ["created_at", "2015-04-09 14:19:19.975534"], ["updated_at", "2015-04-09 14:19:19.975534"]]
|
2721
|
+
[1m[35mSQL (0.1ms)[0m UPDATE "snaps_tags" SET "superseded_at" = '2015-04-09 14:19:19.976940' WHERE "snaps_tags"."id" IN (SELECT "snaps_tags"."id" FROM "snaps_tags" INNER JOIN txtblx_textblocks
|
2722
|
+
ON txtblx_textblocks.id = snaps_tags.record_id
|
2723
|
+
AND snaps_tags.record_type = 'Txtblx::Textblock'
|
2724
|
+
AND perma_id = 1 WHERE "snaps_tags"."tag" = ? AND "snaps_tags"."superseded_at" IS NULL) [["tag", "draft"]]
|
2725
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "snaps_tags" ("record_id", "record_type", "tag", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?)[0m [["record_id", 1], ["record_type", "Txtblx::Textblock"], ["tag", "draft"], ["created_at", "2015-04-09 14:19:19.977601"], ["updated_at", "2015-04-09 14:19:19.977601"]]
|
2726
|
+
[1m[35m (0.1ms)[0m RELEASE SAVEPOINT active_record_1
|
2727
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: txtblx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Codevise Solutions Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|