administrate 0.1.2 → 0.1.3

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.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/administrate/search.svg +2 -2
  3. data/app/assets/images/administrate/sort_arrow.svg +1 -1
  4. data/app/assets/javascripts/administrate/components/has_many_form.js +1 -1
  5. data/app/assets/stylesheets/administrate/application.scss +3 -8
  6. data/app/assets/stylesheets/administrate/base/_forms.scss +56 -44
  7. data/app/assets/stylesheets/administrate/base/_layout.scss +20 -0
  8. data/app/assets/stylesheets/administrate/base/_lists.scss +9 -21
  9. data/app/assets/stylesheets/administrate/base/_tables.scss +9 -6
  10. data/app/assets/stylesheets/administrate/base/_typography.scss +12 -57
  11. data/app/assets/stylesheets/administrate/components/_app-container.scss +7 -0
  12. data/app/assets/stylesheets/administrate/components/_attributes.scss +1 -1
  13. data/app/assets/stylesheets/administrate/components/_buttons.scss +36 -0
  14. data/app/assets/stylesheets/administrate/components/_cells.scss +31 -37
  15. data/app/assets/stylesheets/administrate/components/_field-unit.scss +17 -0
  16. data/app/assets/stylesheets/administrate/components/_flashes.scss +16 -0
  17. data/app/assets/stylesheets/administrate/components/_form-actions.scss +3 -0
  18. data/app/assets/stylesheets/administrate/components/_header.scss +9 -8
  19. data/app/assets/stylesheets/administrate/components/_main-content.scss +6 -0
  20. data/app/assets/stylesheets/administrate/components/_pagination.scss +3 -2
  21. data/app/assets/stylesheets/administrate/components/_search.scss +9 -10
  22. data/app/assets/stylesheets/administrate/components/_sidebar.scss +22 -0
  23. data/app/assets/stylesheets/administrate/components/_table.scss +7 -3
  24. data/app/assets/stylesheets/administrate/{mixins → library}/_data_label.scss +2 -2
  25. data/app/assets/stylesheets/administrate/library/_variables.scss +57 -0
  26. data/app/assets/stylesheets/docs.scss +92 -0
  27. data/app/controllers/administrate/application_controller.rb +4 -3
  28. data/app/controllers/docs_controller.rb +9 -0
  29. data/app/helpers/administrate/application_helper.rb +16 -0
  30. data/app/views/administrate/application/_collection.html.erb +17 -12
  31. data/app/views/administrate/application/_flashes.html.erb +1 -1
  32. data/app/views/administrate/application/_form.html.erb +6 -8
  33. data/app/views/administrate/application/_sidebar.html.erb +1 -1
  34. data/app/views/administrate/application/edit.html.erb +3 -3
  35. data/app/views/administrate/application/index.html.erb +7 -6
  36. data/app/views/administrate/application/new.html.erb +2 -2
  37. data/app/views/administrate/application/show.html.erb +3 -3
  38. data/app/views/fields/belongs_to/_form.html.erb +8 -4
  39. data/app/views/fields/belongs_to/_index.html.erb +1 -1
  40. data/app/views/fields/belongs_to/_show.html.erb +1 -1
  41. data/app/views/fields/boolean/_form.html.erb +6 -2
  42. data/app/views/fields/date_time/_form.html.erb +6 -2
  43. data/app/views/fields/email/_form.html.erb +6 -2
  44. data/app/views/fields/has_many/_form.html.erb +8 -5
  45. data/app/views/fields/has_one/_form.html.erb +3 -1
  46. data/app/views/fields/has_one/_index.html.erb +1 -1
  47. data/app/views/fields/has_one/_show.html.erb +1 -1
  48. data/app/views/fields/image/_form.html.erb +6 -2
  49. data/app/views/fields/number/_form.html.erb +6 -2
  50. data/app/views/fields/polymorphic/_form.html.erb +3 -1
  51. data/app/views/fields/polymorphic/_index.html.erb +1 -1
  52. data/app/views/fields/polymorphic/_show.html.erb +1 -1
  53. data/app/views/fields/string/_form.html.erb +6 -2
  54. data/app/views/fields/text/_form.html.erb +6 -2
  55. data/app/views/layouts/administrate/application.html.erb +11 -11
  56. data/app/views/layouts/docs.html.erb +39 -0
  57. data/config/locales/administrate.de.yml +2 -2
  58. data/config/locales/administrate.it.yml +23 -0
  59. data/config/locales/administrate.uk.yml +23 -0
  60. data/lib/administrate/engine.rb +2 -2
  61. data/lib/administrate/fields/deferred.rb +3 -1
  62. data/lib/administrate/generator_helpers.rb +13 -0
  63. data/lib/administrate/resource_resolver.rb +5 -3
  64. data/lib/administrate/search.rb +3 -0
  65. data/lib/administrate/version.rb +1 -1
  66. data/lib/administrate/view_generator.rb +3 -0
  67. data/lib/generators/administrate/assets/assets_generator.rb +13 -0
  68. data/lib/generators/administrate/assets/images_generator.rb +17 -0
  69. data/lib/generators/administrate/assets/javascripts_generator.rb +17 -0
  70. data/lib/generators/administrate/assets/stylesheets_generator.rb +17 -0
  71. data/lib/generators/administrate/dashboard/USAGE +1 -1
  72. data/lib/generators/administrate/dashboard/dashboard_generator.rb +23 -4
  73. data/lib/generators/administrate/dashboard/templates/dashboard.rb.erb +7 -1
  74. data/lib/generators/administrate/install/install_generator.rb +17 -51
  75. data/lib/generators/administrate/manifest/manifest_generator.rb +65 -0
  76. data/lib/generators/administrate/{install → manifest}/templates/dashboard_manifest.rb.erb +0 -0
  77. data/lib/generators/administrate/views/layout_generator.rb +22 -0
  78. data/lib/generators/administrate/views/sidebar_generator.rb +15 -0
  79. data/lib/generators/administrate/views/views_generator.rb +4 -4
  80. metadata +28 -37
  81. data/app/assets/stylesheets/administrate/_sidebar.scss +0 -27
  82. data/app/assets/stylesheets/administrate/base/_base.scss +0 -24
  83. data/app/assets/stylesheets/administrate/base/_buttons.scss +0 -11
  84. data/app/assets/stylesheets/administrate/base/_grid-settings.scss +0 -15
  85. data/app/assets/stylesheets/administrate/base/_variables.scss +0 -106
  86. data/app/assets/stylesheets/administrate/base/extends/_button.scss +0 -23
  87. data/app/assets/stylesheets/administrate/base/extends/_clearfix.scss +0 -3
  88. data/app/assets/stylesheets/administrate/base/extends/_errors.scss +0 -11
  89. data/app/assets/stylesheets/administrate/base/extends/_flashes.scss +0 -34
  90. data/app/assets/stylesheets/administrate/base/extends/_hide-text.scss +0 -3
  91. data/app/assets/stylesheets/administrate/components/_components.scss +0 -8
  92. data/app/assets/stylesheets/administrate/components/_date_time_picker.scss +0 -3
  93. data/app/assets/stylesheets/administrate/components/_form.scss +0 -41
  94. data/app/assets/stylesheets/administrate/layout.scss +0 -29
  95. data/app/assets/stylesheets/administrate/mixins/_mixins.scss +0 -2
  96. data/app/assets/stylesheets/administrate/mixins/_shadow.scss +0 -35
  97. data/lib/administrate/namespace.rb +0 -3
@@ -0,0 +1,17 @@
1
+ .field-unit {
2
+ @include clearfix;
3
+ @include fill-parent;
4
+ align-items: center;
5
+ display: flex;
6
+ margin-bottom: $base-spacing;
7
+ position: relative;
8
+ }
9
+
10
+ .field-unit__label {
11
+ @include span-columns(2 of 12);
12
+ text-align: right;
13
+ }
14
+
15
+ .field-unit__field {
16
+ @include span-columns(5 of 12);
17
+ }
@@ -0,0 +1,16 @@
1
+ @each $flash-type, $flash-color in $flash-colors {
2
+ .flash--#{$flash-type} {
3
+ background-color: $flash-color;
4
+ color: darken($flash-color, 60%);
5
+ padding: $small-spacing $base-spacing;
6
+
7
+ a {
8
+ color: darken($flash-color, 70%);
9
+
10
+ &:focus,
11
+ &:hover {
12
+ color: darken($flash-color, 90%);
13
+ }
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,3 @@
1
+ .form-actions {
2
+ @include shift(2);
3
+ }
@@ -1,14 +1,15 @@
1
1
  .header {
2
- align-items: baseline;
2
+ align-items: flex-start;
3
3
  display: flex;
4
4
  justify-content: space-between;
5
- margin-bottom: $base-spacing * 2;
5
+ padding: $base-spacing;
6
+ }
6
7
 
7
- &-heading {
8
- margin-top: 0;
9
- }
8
+ .header__heading {
9
+ font-size: modular-scale(3);
10
+ margin-top: 0;
11
+ }
10
12
 
11
- &-actions {
12
- margin-left: $base-spacing;
13
- }
13
+ .header__actions {
14
+ margin-left: $base-spacing;
14
15
  }
@@ -0,0 +1,6 @@
1
+ .main-content {
2
+ background-color: $white;
3
+ box-shadow: 0 2px 4px rgba($grey-7, 0.24), 0 2px 6px rgba($grey-7, 0.12);
4
+ flex: 1;
5
+ overflow-y: auto;
6
+ }
@@ -1,5 +1,6 @@
1
1
  .pagination {
2
- margin: $base-spacing 0;
2
+ @include margin($base-spacing null ($base-spacing * 4));
3
+ @include padding(null $base-spacing);
3
4
  text-align: center;
4
5
 
5
6
  .first,
@@ -11,6 +12,6 @@
11
12
  }
12
13
 
13
14
  .current {
14
- font-weight: bold;
15
+ font-weight: $bold-font-weight;
15
16
  }
16
17
  }
@@ -1,10 +1,10 @@
1
1
  .search {
2
+ @include padding(null $base-spacing);
2
3
  align-items: center;
3
4
  border-bottom: $base-border;
4
5
  display: flex;
5
6
  flex-direction: row;
6
7
  justify-content: flex-start;
7
- padding: 0 $base-spacing;
8
8
  position: relative;
9
9
  width: 100%;
10
10
  }
@@ -12,21 +12,20 @@
12
12
  .search__icon {
13
13
  svg {
14
14
  @include size(1em);
15
- }
16
-
17
- path {
18
- @include transition($base-transition);
19
15
  fill: $hint-grey;
16
+ transition: fill $base-duration $base-timing;
20
17
  }
21
18
 
22
- &--active path {
23
- fill: $base-accent-color;
19
+ &--active {
20
+ svg {
21
+ fill: $action-color;
22
+ }
24
23
  }
25
24
  }
26
25
 
27
26
  .search__input {
28
27
  appearance: none;
29
- border: none;
28
+ border: 0;
30
29
  box-shadow: none;
31
30
  flex-grow: 1;
32
31
  margin: 0;
@@ -39,9 +38,9 @@
39
38
 
40
39
  .search__hint {
41
40
  @include position(absolute, 1em 0 null null);
42
- @include transition($base-transition);
43
41
  color: $hint-grey;
44
42
  opacity: 0;
43
+ transition: opacity $base-duration $base-timing;
45
44
 
46
45
  svg {
47
46
  @include size(100%);
@@ -49,7 +48,7 @@
49
48
 
50
49
  path,
51
50
  rect {
52
- fill: $base-accent-color;
51
+ fill: $action-color;
53
52
  }
54
53
 
55
54
  &--active {
@@ -0,0 +1,22 @@
1
+ .sidebar {
2
+ flex: 0 0 auto;
3
+ max-width: 12em;
4
+ overflow-y: auto;
5
+ padding: 0 $base-spacing $base-spacing;
6
+ }
7
+
8
+ .sidebar__link {
9
+ color: $base-font-color;
10
+ display: block;
11
+ padding-top: $base-spacing;
12
+ transition: color 0.05s linear;
13
+
14
+ &:hover {
15
+ color: $blue;
16
+ }
17
+ }
18
+
19
+ .sidebar__link--active {
20
+ color: $blue;
21
+ font-weight: $bold-font-weight;
22
+ }
@@ -1,7 +1,11 @@
1
+ .collection-data {
2
+ @include padding(null $base-spacing);
3
+ }
4
+
1
5
  .table__row {
2
6
  background-color: $white;
3
7
  border-left: 2px solid transparent;
4
- transition: $base-transition;
8
+ transition: background-color $base-duration $base-timing;
5
9
 
6
10
  &:hover {
7
11
  background-color: $base-background-color;
@@ -10,10 +14,10 @@
10
14
  }
11
15
 
12
16
  img {
13
- max-height: $table-image-height;
17
+ max-height: 2em;
14
18
  }
15
19
  }
16
20
 
17
21
  .table__action--destroy {
18
- color: $error-color;
22
+ color: $light-red;
19
23
  }
@@ -1,7 +1,7 @@
1
1
  @mixin data-label {
2
2
  color: $hint-grey;
3
- font-size: $small-font-size;
4
- font-weight: $normal-font-weight;
3
+ font-size: modular-scale(-1);
4
+ font-weight: 400;
5
5
  letter-spacing: 0.0357em;
6
6
  position: relative;
7
7
  text-transform: uppercase;
@@ -0,0 +1,57 @@
1
+ // Typography
2
+ $base-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
3
+ "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
4
+ sans-serif;
5
+ $heading-font-family: $base-font-family;
6
+
7
+ $base-font-size: 1em;
8
+
9
+ $bold-font-weight: 600;
10
+
11
+ $base-line-height: 1.5;
12
+ $heading-line-height: 1.2;
13
+
14
+ // Other Sizes
15
+ $modular-scale-ratio: $minor-third;
16
+ $base-border-radius: 3px;
17
+ $base-spacing: $base-line-height * 1em;
18
+ $small-spacing: $base-spacing / 2;
19
+
20
+ // Colors
21
+ $white: #fff;
22
+ $black: #000;
23
+
24
+ $blue: #2a94d6;
25
+ $light-red: #c77067;
26
+ $light-yellow: #f0cd66;
27
+ $light-green: #4ab471;
28
+
29
+ $grey-0: #f6f7f7;
30
+ $grey-1: #dfe0e1;
31
+ $grey-2: #cfd8dc;
32
+ $grey-7: #293f54;
33
+
34
+ $hint-grey: #7b808c;
35
+
36
+ // Font Colors
37
+ $base-font-color: $grey-7;
38
+ $action-color: $blue;
39
+
40
+ // Background Colors
41
+ $base-background-color: $grey-0;
42
+
43
+ // Flash Colors
44
+ $flash-colors: (
45
+ alert: $light-yellow,
46
+ error: $light-red,
47
+ notice: tint($blue, 50%),
48
+ success: $light-green
49
+ );
50
+
51
+ // Border
52
+ $base-border-color: $grey-1;
53
+ $base-border: 1px solid $base-border-color;
54
+
55
+ // Transitions
56
+ $base-duration: 250ms;
57
+ $base-timing: $ease-out-cubic;
@@ -0,0 +1,92 @@
1
+ $blue: #53adc6;
2
+ $red: #cf726e;
3
+ $green: #5bc89e;
4
+ $white: #f0f0f0;
5
+
6
+ $code-black: #202020;
7
+ $code-white: #e0e0dc;
8
+ $code-green: #b0bf82;
9
+ $code-blue: #8fbdcc;
10
+ $code-yellow: #f8d29d;
11
+ $code-red: #b95c56;
12
+
13
+ html,
14
+ body {
15
+ font-family: 'Lato', serif;
16
+ font-size: 18px;
17
+ line-height: 1.62em;
18
+ margin: 0;
19
+ }
20
+
21
+ img {
22
+ max-width: 100%;
23
+ }
24
+
25
+ h1,
26
+ h2,
27
+ h3 {
28
+ font-family: 'Fjalla One', sans-serif;
29
+ margin-top: 2em;
30
+ }
31
+
32
+ a {
33
+ color: $blue;
34
+ text-decoration: none;
35
+ }
36
+
37
+ .content {
38
+ margin-bottom: 2em;
39
+ margin-left: auto;
40
+ margin-right: auto;
41
+ margin-top: 2em;
42
+ width: 60em;
43
+
44
+ .sidebar {
45
+ float: left;
46
+ width: 20em;
47
+
48
+ &-links {
49
+ list-style: none;
50
+ padding-left: 0;
51
+ }
52
+ }
53
+
54
+ .main {
55
+ float: right;
56
+ width: 40em;
57
+ }
58
+ }
59
+
60
+ .flash-wrapper {
61
+ background-color: $red;
62
+ color: $white;
63
+ padding: 1em;
64
+
65
+ .flash {
66
+ margin-left: auto;
67
+ margin-right: auto;
68
+ width: 40em;
69
+ }
70
+ }
71
+
72
+ code {
73
+ font-family: "Source Code Pro";
74
+ font-size: 0.8rem;
75
+ padding: 0.4em 0.2em 0;
76
+
77
+ &.hljs {
78
+ background-color: $code-black;
79
+ color: $code-white;
80
+ padding-left: 1rem;
81
+
82
+ .hljs-string { color: $code-green; }
83
+ .hljs-constant { color: $code-blue; }
84
+ .hljs-symbol { color: $code-red; }
85
+ .hljs-keyword { color: $code-yellow; }
86
+
87
+ .hljs-title,
88
+ .hljs-parent { color: $code-blue; }
89
+
90
+ .hljs-tag { color: $code-yellow; }
91
+ }
92
+ }
@@ -37,7 +37,7 @@ module Administrate
37
37
 
38
38
  if resource.save
39
39
  redirect_to(
40
- [Administrate::NAMESPACE, resource],
40
+ [namespace, resource],
41
41
  notice: translate_with_resource("create.success"),
42
42
  )
43
43
  else
@@ -50,7 +50,7 @@ module Administrate
50
50
  def update
51
51
  if requested_resource.update(resource_params)
52
52
  redirect_to(
53
- [Administrate::NAMESPACE, requested_resource],
53
+ [namespace, requested_resource],
54
54
  notice: translate_with_resource("update.success"),
55
55
  )
56
56
  else
@@ -105,7 +105,8 @@ module Administrate
105
105
  dashboard.permitted_attributes
106
106
  end
107
107
 
108
- delegate :resource_class, :resource_name, to: :resource_resolver
108
+ delegate :resource_class, :resource_name, :namespace, to: :resource_resolver
109
+ helper_method :namespace
109
110
 
110
111
  def resource_resolver
111
112
  @_resource_resolver ||=
@@ -0,0 +1,9 @@
1
+ class DocsController < ApplicationController
2
+ def index
3
+ render file: "README"
4
+ end
5
+
6
+ def show
7
+ render file: "docs/#{params[:page]}"
8
+ end
9
+ end
@@ -16,5 +16,21 @@ module Administrate
16
16
  default: resource_name.to_s.pluralize.titleize,
17
17
  )
18
18
  end
19
+
20
+ def svg_tag(asset, svg_id, options = {})
21
+ svg_attributes = {
22
+ "xlink:href".freeze => "#{asset_url(asset)}##{svg_id}",
23
+ height: options[:height],
24
+ width: options[:width],
25
+ }.delete_if { |_key, value| value.nil? }
26
+ xml_attributes = {
27
+ "xmlns".freeze => "http://www.w3.org/2000/svg".freeze,
28
+ "xmlns:xlink".freeze => "http://www.w3.org/1999/xlink".freeze,
29
+ }
30
+
31
+ content_tag :svg, xml_attributes do
32
+ content_tag :use, nil, svg_attributes
33
+ end
34
+ end
19
35
  end
20
36
  end
@@ -1,30 +1,30 @@
1
1
  <%#
2
- # Table
2
+ # Collection
3
3
 
4
4
  This partial is used on the `index` and `show` pages
5
5
  to display a collection of resources in an HTML table.
6
6
 
7
7
  ## Local variables:
8
8
 
9
- - `table_presenter`:
10
- An instance of [Administrate::Page::Table][1].
11
- The table presenter uses `ResourceDashboard::TABLE_ATTRIBUTES` to determine
9
+ - `collection_presenter`:
10
+ An instance of [Administrate::Page::Collection][1].
11
+ The table presenter uses `ResourceDashboard::COLLECTION_ATTRIBUTES` to determine
12
12
  the columns displayed in the table
13
13
  - `resources`:
14
14
  An ActiveModel::Relation collection of resources to be displayed in the table.
15
15
  By default, the number of resources is limited by pagination
16
16
  or by a hard limit to prevent excessive page load times
17
17
 
18
- [1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Table
18
+ [1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
19
19
  %>
20
20
 
21
- <table>
21
+ <table class="collection-data" aria-labelledby="page-title">
22
22
  <thead>
23
23
  <tr>
24
24
  <% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
25
25
  <th class="cell-label cell-label--<%= attr_type.html_class %>
26
26
  cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
27
- ">
27
+ " scope="col">
28
28
  <%= link_to(params.merge(
29
29
  collection_presenter.order_params_for(attr_name)
30
30
  )) do %>
@@ -32,13 +32,18 @@ to display a collection of resources in an HTML table.
32
32
 
33
33
  <% if collection_presenter.ordered_by?(attr_name) %>
34
34
  <span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
35
- <%= inline_svg("administrate/sort_arrow.svg") %>
35
+ <%= svg_tag(
36
+ "administrate/sort_arrow.svg",
37
+ "sort_arrow",
38
+ width: "13",
39
+ height: "13"
40
+ ) %>
36
41
  </span>
37
42
  <% end %>
38
43
  <% end %>
39
44
  </th>
40
45
  <% end %>
41
- <th colspan="2"></th>
46
+ <th colspan="2" scope="col"></th>
42
47
  </tr>
43
48
  </thead>
44
49
 
@@ -47,7 +52,7 @@ to display a collection of resources in an HTML table.
47
52
  <tr class="table__row"
48
53
  role="link"
49
54
  tabindex="0"
50
- data-url="<%= polymorphic_path([Administrate::NAMESPACE, resource]) -%>"
55
+ data-url="<%= polymorphic_path([namespace, resource]) -%>"
51
56
  >
52
57
  <% collection_presenter.attributes_for(resource).each do |attribute| %>
53
58
  <td class="cell-data cell-data--<%= attribute.html_class %>">
@@ -57,13 +62,13 @@ to display a collection of resources in an HTML table.
57
62
 
58
63
  <td><%= link_to(
59
64
  t("administrate.actions.edit"),
60
- [:edit, Administrate::NAMESPACE, resource],
65
+ [:edit, namespace, resource],
61
66
  class: "action-edit",
62
67
  ) %></td>
63
68
 
64
69
  <td><%= link_to(
65
70
  t("administrate.actions.destroy"),
66
- [Administrate::NAMESPACE, resource],
71
+ [namespace, resource],
67
72
  class: "table__action--destroy",
68
73
  method: :delete,
69
74
  data: { confirm: t("administrate.actions.confirm") }