txtblx 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33f2917fbd7f77fa2bcda630ce92bbb4505633ff
4
- data.tar.gz: 4bebfa38134daa57ca32a98441d96ff983920888
3
+ metadata.gz: 664e6521e2b4b82dffadfcaff363f8b37fc0e857
4
+ data.tar.gz: cd91629c4b1a4731ba055c4363bc1124b7fecefd
5
5
  SHA512:
6
- metadata.gz: f397e5d7da4a75b36127d8b2fb3818a983bb65218de7478dd202f33c4ea9e4fb0fb1516de5c7a6f3d085202eb3b25473d6f747a791a9ea00936e743ed144574e
7
- data.tar.gz: f0967e9be2405f8072424eef2a63a6b18170552c25c23c37ffc34111b625257b668557521dedac6d90552f73ae8d5d102206079c3383e6e7ee6c4c5113f2d8ff
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
- txtblx_abilities(user)
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
 
@@ -5,7 +5,7 @@ de:
5
5
  one: "Textblock"
6
6
  other: "Textblöcke"
7
7
  attributes:
8
- textblock:
8
+ "txtblx/textblock":
9
9
  key: "Schlüssel"
10
10
  description: "Beschreibung"
11
11
  text: "Text"
@@ -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 txtblx_abilities(user)
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, except: [:destroy]
4
+ actions :all
5
+ filter :description
6
+ filter :text
5
7
 
6
8
  index do
7
- column :key do |textblock|
8
- link_to(textblock.key, admin_textblock_path(textblock))
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
- f.inputs :key, :description, :text
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'}
@@ -1,3 +1,3 @@
1
1
  module Txtblx
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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
   (0.1ms) rollback transaction
2648
+  (0.1ms) begin transaction
2649
+ Txtblx::Textblock Load (0.3ms) 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
+  (0.1ms) rollback transaction
2654
+  (0.0ms) begin transaction
2655
+  (0.1ms) SAVEPOINT active_record_1
2656
+ SQL (0.3ms) 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
+ SQL (0.2ms) UPDATE "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) [["tag", "draft"]]
2661
+ SQL (0.1ms) 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
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2663
+  (0.0ms) SAVEPOINT active_record_1
2664
+ SQL (0.1ms) 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.818111"]]
2665
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2666
+  (0.0ms) SAVEPOINT active_record_1
2667
+ SQL (0.1ms) 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
+ SQL (0.1ms) 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.820928"], ["updated_at", "2015-04-09 14:19:19.820928"]]
2672
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2673
+ Txtblx::Textblock Load (0.1ms) SELECT "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 [["key", "homepage.welcome"]]
2677
+  (0.1ms) rollback transaction
2678
+  (0.1ms) begin transaction
2679
+  (0.1ms) SAVEPOINT active_record_1
2680
+ SQL (0.2ms) 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.827632"]]
2681
+ SQL (0.1ms) 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
+ SQL (0.1ms) 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.830719"], ["updated_at", "2015-04-09 14:19:19.830719"]]
2686
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2687
+  (0.0ms) SAVEPOINT active_record_1
2688
+ SQL (0.1ms) 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
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2690
+  (0.0ms) SAVEPOINT active_record_1
2691
+ SQL (0.1ms) UPDATE "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) [["tag", "published"]]
2695
+ SQL (0.1ms) 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
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2697
+ Started GET "/" for 127.0.0.1 at 2015-04-09 16:19:19 +0200
2698
+ Processing by DummiesController#index as HTML
2699
+ Txtblx::Textblock Load (0.1ms) 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
+  (0.3ms) rollback transaction
2706
+  (0.1ms) begin transaction
2707
+  (0.1ms) SAVEPOINT active_record_1
2708
+  (0.1ms) SELECT MAX("txtblx_textblocks"."perma_id") FROM "txtblx_textblocks"
2709
+ SQL (0.2ms) INSERT INTO "txtblx_textblocks" ("key", "text", "text_html", "perma_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["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
+ SQL (0.1ms) 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
+ SQL (0.1ms) 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.971990"], ["updated_at", "2015-04-09 14:19:19.971990"]]
2715
+  (0.0ms) RELEASE SAVEPOINT active_record_1
2716
+  (0.1ms) rollback transaction
2717
+  (0.0ms) begin transaction
2718
+  (0.0ms) SAVEPOINT active_record_1
2719
+  (0.1ms) SELECT MAX("txtblx_textblocks"."perma_id") FROM "txtblx_textblocks"
2720
+ SQL (0.1ms) INSERT INTO "txtblx_textblocks" ("key", "text", "text_html", "perma_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["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
+ SQL (0.1ms) 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
+ SQL (0.1ms) 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.977601"], ["updated_at", "2015-04-09 14:19:19.977601"]]
2726
+  (0.1ms) RELEASE SAVEPOINT active_record_1
2727
+  (0.1ms) rollback transaction
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.1
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-08 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails