para 0.4.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/MIT-LICENSE +20 -0
- data/README.md +65 -0
- data/Rakefile +21 -0
- data/app/assets/images/para/admin/bg.png +0 -0
- data/app/assets/javascripts/admin/app.coffee +1 -0
- data/app/assets/javascripts/para/admin/table.coffee +46 -0
- data/app/assets/javascripts/para/admin/theme_actions.coffee +26 -0
- data/app/assets/javascripts/para/admin/tree.coffee +53 -0
- data/app/assets/javascripts/para/admin.coffee +18 -0
- data/app/assets/javascripts/para/application.js +13 -0
- data/app/assets/javascripts/para/inputs/nested_many.coffee +57 -0
- data/app/assets/javascripts/para/lib/ajax.coffee +11 -0
- data/app/assets/stylesheets/admin/app.sass +0 -0
- data/app/assets/stylesheets/admin/theme.sass +0 -0
- data/app/assets/stylesheets/para/admin/theme/_base.sass +170 -0
- data/app/assets/stylesheets/para/admin/theme/_breadcrumb.sass +29 -0
- data/app/assets/stylesheets/para/admin/theme/_buttons.sass +24 -0
- data/app/assets/stylesheets/para/admin/theme/_checkable.sass +107 -0
- data/app/assets/stylesheets/para/admin/theme/_commonds.sass +213 -0
- data/app/assets/stylesheets/para/admin/theme/_dropdown.sass +53 -0
- data/app/assets/stylesheets/para/admin/theme/_form.sass +141 -0
- data/app/assets/stylesheets/para/admin/theme/_list.sass +138 -0
- data/app/assets/stylesheets/para/admin/theme/_navigation.sass +287 -0
- data/app/assets/stylesheets/para/admin/theme/_navtabs.sass +127 -0
- data/app/assets/stylesheets/para/admin/theme/_orderable.sass +44 -0
- data/app/assets/stylesheets/para/admin/theme/_panel.sass +288 -0
- data/app/assets/stylesheets/para/admin/theme/_responsive.sass +123 -0
- data/app/assets/stylesheets/para/admin/theme/_sorting.sass +30 -0
- data/app/assets/stylesheets/para/admin/theme/_table.sass +24 -0
- data/app/assets/stylesheets/para/admin/theme/_tree.sass +74 -0
- data/app/assets/stylesheets/para/admin/theme/_variables.sass +31 -0
- data/app/assets/stylesheets/para/admin/theme.sass +22 -0
- data/app/assets/stylesheets/para/admin.sass +10 -0
- data/app/assets/stylesheets/para/application.css +15 -0
- data/app/assets/stylesheets/para/lib/_variables.scss +646 -0
- data/app/assets/stylesheets/para/overrides/datetimepicker.sass +17 -0
- data/app/assets/stylesheets/para/overrides/fuelux.sass +43 -0
- data/app/assets/stylesheets/para/overrides/jasny.bootstrap.sass +41 -0
- data/app/assets/stylesheets/para/overrides/redactor.sass +88 -0
- data/app/assets/stylesheets/para/overrides/responsive.sass +63 -0
- data/app/assets/stylesheets/para/overrides/selectize.sass +45 -0
- data/app/assets/stylesheets/para/overrides/slider.sass +13 -0
- data/app/assets/stylesheets/para/overrides/theme.sass +172 -0
- data/app/controllers/concerns/para/admin/resource_controller_concerns.rb +17 -0
- data/app/controllers/para/admin/base_controller.rb +46 -0
- data/app/controllers/para/admin/component_controller.rb +9 -0
- data/app/controllers/para/admin/crud_component_controller.rb +17 -0
- data/app/controllers/para/admin/crud_resources_controller.rb +71 -0
- data/app/controllers/para/admin/main_controller.rb +8 -0
- data/app/controllers/para/admin/resources_controller.rb +163 -0
- data/app/controllers/para/admin/settings_component_controller.rb +11 -0
- data/app/controllers/para/admin/settings_form_controller.rb +21 -0
- data/app/controllers/para/admin/singleton_resource_component_controller.rb +14 -0
- data/app/controllers/para/admin/singleton_resources_controller.rb +30 -0
- data/app/controllers/para/application_controller.rb +7 -0
- data/app/decorators/para/component/base_decorator.rb +48 -0
- data/app/decorators/para/component/crud_decorator.rb +32 -0
- data/app/decorators/para/component/settings_decorator.rb +11 -0
- data/app/decorators/para/component/singleton_resource_decorator.rb +11 -0
- data/app/decorators/para/component_section_decorator.rb +4 -0
- data/app/helpers/para/admin/base_helper.rb +57 -0
- data/app/helpers/para/admin/component_groups_helper.rb +4 -0
- data/app/helpers/para/admin/components_helper.rb +4 -0
- data/app/helpers/para/admin/resources_helper.rb +27 -0
- data/app/helpers/para/application_helper.rb +14 -0
- data/app/helpers/para/exports_helper.rb +11 -0
- data/app/helpers/para/flash_helper.rb +48 -0
- data/app/helpers/para/form_helper.rb +28 -0
- data/app/helpers/para/markup_helper.rb +15 -0
- data/app/helpers/para/model_helper.rb +38 -0
- data/app/helpers/para/navigation_helper.rb +8 -0
- data/app/helpers/para/ordering_helper.rb +20 -0
- data/app/helpers/para/search_helper.rb +22 -0
- data/app/helpers/para/tag_helper.rb +50 -0
- data/app/helpers/para/tree_helper.rb +41 -0
- data/app/models/para/component/base.rb +70 -0
- data/app/models/para/component/crud.rb +45 -0
- data/app/models/para/component/resource.rb +33 -0
- data/app/models/para/component/settings.rb +17 -0
- data/app/models/para/component/singleton_resource.rb +25 -0
- data/app/models/para/component_resource.rb +6 -0
- data/app/models/para/component_section.rb +18 -0
- data/app/views/layouts/para/admin.html.haml +32 -0
- data/app/views/layouts/para/application.html.erb +14 -0
- data/app/views/para/admin/component_sections/_form.html.haml +10 -0
- data/app/views/para/admin/component_sections/edit.html.haml +5 -0
- data/app/views/para/admin/component_sections/new.html.haml +5 -0
- data/app/views/para/admin/components/_form.html.haml +15 -0
- data/app/views/para/admin/components/new.html.haml +4 -0
- data/app/views/para/admin/crud_component/show.html.haml +4 -0
- data/app/views/para/admin/dashboard.html.haml +10 -0
- data/app/views/para/admin/main/index.html.haml +1 -0
- data/app/views/para/admin/resources/_exports_menu.html.haml +12 -0
- data/app/views/para/admin/resources/_fields.html.haml +5 -0
- data/app/views/para/admin/resources/_filters.html.haml +9 -0
- data/app/views/para/admin/resources/_form.html.haml +6 -0
- data/app/views/para/admin/resources/_list.html.haml +22 -0
- data/app/views/para/admin/resources/_table.html.haml +8 -0
- data/app/views/para/admin/resources/_tree.html.haml +15 -0
- data/app/views/para/admin/resources/_tree_item.html.haml +16 -0
- data/app/views/para/admin/resources/edit.html.haml +6 -0
- data/app/views/para/admin/resources/new.html.haml +6 -0
- data/app/views/para/admin/settings_component/show.html.haml +12 -0
- data/app/views/para/admin/shared/_breadcrumb.html.haml +3 -0
- data/app/views/para/admin/shared/_header.html.haml +27 -0
- data/app/views/para/admin/shared/_navigation.html.haml +21 -0
- data/app/views/para/admin/singleton_resource_component/show.html.haml +5 -0
- data/app/views/para/inputs/_nested_many.html.haml +10 -0
- data/app/views/para/inputs/_nested_many_container.html.haml +19 -0
- data/app/views/para/inputs/_nested_one.html.haml +3 -0
- data/config/locales/en.yml +86 -0
- data/config/locales/fr.yml +101 -0
- data/db/migrate/20140911091225_create_para_components.rb +19 -0
- data/db/migrate/20140911112150_add_slug_to_para_components.rb +6 -0
- data/db/migrate/20140929125733_create_para_component_sections.rb +8 -0
- data/db/migrate/20140929131111_add_identifier_to_para_component_sections.rb +5 -0
- data/db/migrate/20140930121822_add_position_to_para_component_section.rb +5 -0
- data/db/migrate/20150129170710_create_para_component_resources.rb +13 -0
- data/db/migrate/20150203173219_add_identifier_to_para_components.rb +5 -0
- data/lib/generators/para/admin_user/admin_user_generator.rb +16 -0
- data/lib/generators/para/component/component_generator.rb +59 -0
- data/lib/generators/para/component/templates/component.rb +3 -0
- data/lib/generators/para/component/templates/component_controller.rb +7 -0
- data/lib/generators/para/component/templates/show.html.haml +2 -0
- data/lib/generators/para/exporter/exporter_generator.rb +42 -0
- data/lib/generators/para/exporter/templates/base_exporter.rb +15 -0
- data/lib/generators/para/exporter/templates/csv_exporter.rb +13 -0
- data/lib/generators/para/form/form_generator.rb +15 -0
- data/lib/generators/para/form/templates/_form.html.haml +7 -0
- data/lib/generators/para/install/install_generator.rb +112 -0
- data/lib/generators/para/install/templates/components.rb +13 -0
- data/lib/generators/para/install/templates/initializer.rb +23 -0
- data/lib/generators/para/nested_fields/nested_fields_generator.rb +15 -0
- data/lib/generators/para/nested_fields/templates/_nested_fields.html.haml +3 -0
- data/lib/generators/para/orderable/orderable_generator.rb +53 -0
- data/lib/generators/para/orderable/templates/orderable_migration.rb +6 -0
- data/lib/generators/para/resource/resource_generator.rb +71 -0
- data/lib/generators/para/resource/templates/resource_controller.rb +5 -0
- data/lib/generators/para/table/table_generator.rb +34 -0
- data/lib/generators/para/table/templates/_table.html.haml +10 -0
- data/lib/para/attribute_field/base.rb +77 -0
- data/lib/para/attribute_field/belongs_to.rb +29 -0
- data/lib/para/attribute_field/boolean.rb +15 -0
- data/lib/para/attribute_field/datetime.rb +9 -0
- data/lib/para/attribute_field/file.rb +20 -0
- data/lib/para/attribute_field/has_many.rb +31 -0
- data/lib/para/attribute_field/image.rb +25 -0
- data/lib/para/attribute_field/nested_many.rb +26 -0
- data/lib/para/attribute_field/nested_one.rb +27 -0
- data/lib/para/attribute_field/password.rb +18 -0
- data/lib/para/attribute_field/redactor.rb +20 -0
- data/lib/para/attribute_field/relation.rb +52 -0
- data/lib/para/attribute_field/translation.rb +9 -0
- data/lib/para/attribute_field_mappings.rb +82 -0
- data/lib/para/cloneable.rb +20 -0
- data/lib/para/component/exportable.rb +25 -0
- data/lib/para/component.rb +27 -0
- data/lib/para/components_configuration.rb +156 -0
- data/lib/para/config.rb +21 -0
- data/lib/para/engine.rb +59 -0
- data/lib/para/errors.rb +15 -0
- data/lib/para/exporter/base.rb +27 -0
- data/lib/para/exporter/csv.rb +49 -0
- data/lib/para/exporter.rb +57 -0
- data/lib/para/ext/cancan.rb +26 -0
- data/lib/para/ext/paperclip.rb +67 -0
- data/lib/para/ext.rb +13 -0
- data/lib/para/form_builder/containers.rb +70 -0
- data/lib/para/form_builder/field_mappings.rb +9 -0
- data/lib/para/form_builder/nested_form.rb +80 -0
- data/lib/para/form_builder/ordering.rb +15 -0
- data/lib/para/form_builder/settings.rb +24 -0
- data/lib/para/form_builder.rb +22 -0
- data/lib/para/generators/field_helpers.rb +32 -0
- data/lib/para/generators/name_helpers.rb +9 -0
- data/lib/para/generators/named_base.rb +7 -0
- data/lib/para/generators.rb +11 -0
- data/lib/para/inputs/nested_many_input.rb +40 -0
- data/lib/para/inputs/nested_one_input.rb +24 -0
- data/lib/para/inputs.rb +11 -0
- data/lib/para/markup/alert.rb +37 -0
- data/lib/para/markup/component.rb +20 -0
- data/lib/para/markup/modal.rb +52 -0
- data/lib/para/markup/panel.rb +41 -0
- data/lib/para/markup/resources_table.rb +178 -0
- data/lib/para/markup.rb +10 -0
- data/lib/para/model_field_parsers/base.rb +20 -0
- data/lib/para/model_field_parsers/devise.rb +37 -0
- data/lib/para/model_field_parsers/globalize.rb +23 -0
- data/lib/para/model_field_parsers/orderable.rb +15 -0
- data/lib/para/model_field_parsers/paperclip.rb +51 -0
- data/lib/para/model_field_parsers/redactor.rb +19 -0
- data/lib/para/model_field_parsers/relations.rb +67 -0
- data/lib/para/model_field_parsers.rb +22 -0
- data/lib/para/orderable.rb +44 -0
- data/lib/para/routes.rb +49 -0
- data/lib/para/version.rb +3 -0
- data/lib/para.rb +65 -0
- data/lib/rails/relation_length_validator.rb +45 -0
- data/lib/rails/routing_mapper.rb +27 -0
- data/lib/tasks/para_tasks.rake +22 -0
- metadata +595 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
en:
|
|
2
|
+
para:
|
|
3
|
+
flash:
|
|
4
|
+
shared:
|
|
5
|
+
create:
|
|
6
|
+
success: "%{model} created"
|
|
7
|
+
error: "Could not create %{model}"
|
|
8
|
+
update:
|
|
9
|
+
success: "%{model} updated"
|
|
10
|
+
error: "Could not update %{model}"
|
|
11
|
+
destroy:
|
|
12
|
+
success: "%{model} deleted"
|
|
13
|
+
error: "Could not delete %{model}"
|
|
14
|
+
|
|
15
|
+
admin:
|
|
16
|
+
title: "Admin"
|
|
17
|
+
|
|
18
|
+
confirmation:
|
|
19
|
+
shared:
|
|
20
|
+
destroy: 'Are you sure that you want to delete %{model} ?'
|
|
21
|
+
|
|
22
|
+
component:
|
|
23
|
+
create: "Create a component"
|
|
24
|
+
add: "Add a component"
|
|
25
|
+
none_created: "No components created for now ..."
|
|
26
|
+
crud:
|
|
27
|
+
name: "Resources list"
|
|
28
|
+
singleton_resource:
|
|
29
|
+
name: "Resource form"
|
|
30
|
+
|
|
31
|
+
component_section:
|
|
32
|
+
add: "Add a component section"
|
|
33
|
+
edit: 'Edit section'
|
|
34
|
+
destroy: 'Delete section'
|
|
35
|
+
actions: "Actions"
|
|
36
|
+
|
|
37
|
+
form:
|
|
38
|
+
shared:
|
|
39
|
+
new:
|
|
40
|
+
title: "Create new %{model}"
|
|
41
|
+
nested:
|
|
42
|
+
name: "Name"
|
|
43
|
+
add: "Add"
|
|
44
|
+
remove: "Remove"
|
|
45
|
+
new: "New"
|
|
46
|
+
|
|
47
|
+
list:
|
|
48
|
+
search_title: "Search"
|
|
49
|
+
delete_confirmation: "Are you sure that you want to delete this item ?"
|
|
50
|
+
no_results: "No results found, please try with other criterions"
|
|
51
|
+
empty: "The list is empty"
|
|
52
|
+
|
|
53
|
+
shared:
|
|
54
|
+
save: "Save"
|
|
55
|
+
cancel: "Cancel"
|
|
56
|
+
add: "Create"
|
|
57
|
+
search: "Search"
|
|
58
|
+
save_and_edit: "Save and edit"
|
|
59
|
+
save_and_add_another_button: "Save and create a other"
|
|
60
|
+
|
|
61
|
+
types:
|
|
62
|
+
boolean:
|
|
63
|
+
"true": "Yes"
|
|
64
|
+
"false": "No"
|
|
65
|
+
|
|
66
|
+
activerecord:
|
|
67
|
+
errors:
|
|
68
|
+
relation_length_is_smaller: "must contain at least %{minimum} elements"
|
|
69
|
+
relation_length_is_greater: "must contain at most %{minimum} elements"
|
|
70
|
+
models:
|
|
71
|
+
para/component/base:
|
|
72
|
+
one: "Component"
|
|
73
|
+
other: "Components"
|
|
74
|
+
para/component/crud:
|
|
75
|
+
one: "Resource listing"
|
|
76
|
+
other: "Resource listings"
|
|
77
|
+
para/component/singleton_resource:
|
|
78
|
+
one: "Resource form"
|
|
79
|
+
other: "Resource forms"
|
|
80
|
+
attributes:
|
|
81
|
+
para/component/base:
|
|
82
|
+
name: "Title"
|
|
83
|
+
type: "Type"
|
|
84
|
+
model_type: "Resource"
|
|
85
|
+
namespaced: "Only list component's resources"
|
|
86
|
+
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
fr:
|
|
2
|
+
para:
|
|
3
|
+
flash:
|
|
4
|
+
shared:
|
|
5
|
+
create:
|
|
6
|
+
success: "%{model} créé(e)"
|
|
7
|
+
error: "Impossible de créer le(a) %{model}"
|
|
8
|
+
update:
|
|
9
|
+
success: "%{model} mis(e) à jour avec succès."
|
|
10
|
+
error: "Impossible de mettre à jour le(a) %{model}"
|
|
11
|
+
destroy:
|
|
12
|
+
success: "%{model} supprimé(e)"
|
|
13
|
+
error: "Impossible de supprimer le(a) %{model}"
|
|
14
|
+
clone:
|
|
15
|
+
success: "%{model} cloné(e)"
|
|
16
|
+
error: "Impossible de cloner le(a) %{model}"
|
|
17
|
+
|
|
18
|
+
admin:
|
|
19
|
+
title: "Administration"
|
|
20
|
+
toggle_navigation: "Open navigation"
|
|
21
|
+
back_to_app: "Retour à l'application"
|
|
22
|
+
sign_out: "Se déconnecter"
|
|
23
|
+
|
|
24
|
+
confirmation:
|
|
25
|
+
shared:
|
|
26
|
+
destroy: 'Etes-vous sure de vouloir supprimer %{model} ?'
|
|
27
|
+
|
|
28
|
+
component:
|
|
29
|
+
create: "Créer un(e) Composant"
|
|
30
|
+
add: "Ajouter un composant"
|
|
31
|
+
none_created: "Aucune page pour le moment ..."
|
|
32
|
+
crud:
|
|
33
|
+
name: "Listing de ressources"
|
|
34
|
+
singleton_resource:
|
|
35
|
+
name: "Formulaire de ressource"
|
|
36
|
+
|
|
37
|
+
component_section:
|
|
38
|
+
add: "Ajouter une section"
|
|
39
|
+
edit: 'Modifier la section'
|
|
40
|
+
destroy: 'Supprimer la section'
|
|
41
|
+
actions: "Actions"
|
|
42
|
+
|
|
43
|
+
form:
|
|
44
|
+
shared:
|
|
45
|
+
new:
|
|
46
|
+
title: "Créer un(e) %{model}"
|
|
47
|
+
nested:
|
|
48
|
+
name: "Nom"
|
|
49
|
+
add: "Ajouter"
|
|
50
|
+
remove: "Supprimer"
|
|
51
|
+
new: "Nouveau"
|
|
52
|
+
|
|
53
|
+
list:
|
|
54
|
+
search_title: "Recherche"
|
|
55
|
+
delete_confirmation: "Êtes vous sûr de bien vouloir supprimer cette entrée ?"
|
|
56
|
+
no_results: "Aucun résultat pour cette recherche, merci d'essayer avec d'autres critères"
|
|
57
|
+
empty: "Aucune entrée créée pour le moment"
|
|
58
|
+
|
|
59
|
+
export:
|
|
60
|
+
name: "Export %{name}"
|
|
61
|
+
as: "Exporter (.%{extension})"
|
|
62
|
+
|
|
63
|
+
shared:
|
|
64
|
+
save: "Enregistrer"
|
|
65
|
+
cancel: "Annuler"
|
|
66
|
+
add: "Créer"
|
|
67
|
+
search: "Rechercher"
|
|
68
|
+
save_and_edit: "Enregistrer et éditer"
|
|
69
|
+
save_and_add_another_button: "Enregistrer et créer un(e) autre"
|
|
70
|
+
|
|
71
|
+
types:
|
|
72
|
+
boolean:
|
|
73
|
+
"true": "Oui"
|
|
74
|
+
"false": "Non"
|
|
75
|
+
|
|
76
|
+
activerecord:
|
|
77
|
+
errors:
|
|
78
|
+
relation_length_is_smaller: "doit contenir au moins %{minimum} éléments"
|
|
79
|
+
relation_length_is_greater: "doit contenir au maximum %{minimum} éléments"
|
|
80
|
+
models:
|
|
81
|
+
para/component/base:
|
|
82
|
+
one: "Composant"
|
|
83
|
+
other: "Composants"
|
|
84
|
+
para/component/crud:
|
|
85
|
+
one: "Listing de ressources"
|
|
86
|
+
other: "Listings de ressources"
|
|
87
|
+
para/component/singleton_resource:
|
|
88
|
+
one: "Formulaire de ressource"
|
|
89
|
+
other: "Formulaires de ressource"
|
|
90
|
+
attributes:
|
|
91
|
+
para/component/base:
|
|
92
|
+
name: "Titre"
|
|
93
|
+
type: "Type"
|
|
94
|
+
model_type: "Ressource"
|
|
95
|
+
namespaced: "Ne lister que les ressources du componsant ?"
|
|
96
|
+
|
|
97
|
+
activemodel:
|
|
98
|
+
models:
|
|
99
|
+
settings_rails/form:
|
|
100
|
+
one: "Configuration"
|
|
101
|
+
other: "Configuration"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class CreateParaComponents < ActiveRecord::Migration
|
|
2
|
+
def up
|
|
3
|
+
execute 'CREATE EXTENSION IF NOT EXISTS hstore'
|
|
4
|
+
|
|
5
|
+
create_table :para_components do |t|
|
|
6
|
+
t.string :type
|
|
7
|
+
t.string :name
|
|
8
|
+
t.hstore :configuration, default: '', null: false
|
|
9
|
+
t.integer :position, default: 0
|
|
10
|
+
t.integer :component_section_id
|
|
11
|
+
|
|
12
|
+
t.timestamps
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def down
|
|
17
|
+
drop_table :para_components
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class CreateParaComponentResources < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :para_component_resources do |t|
|
|
4
|
+
t.references :component, index: true
|
|
5
|
+
t.references :resource, index: true, polymorphic: true
|
|
6
|
+
|
|
7
|
+
t.timestamps null: false
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
add_foreign_key :para_component_resources, :para_components,
|
|
11
|
+
column: :component_id
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Para
|
|
2
|
+
class AdminUserGenerator < Rails::Generators::Base
|
|
3
|
+
source_root File.expand_path("../templates", __FILE__)
|
|
4
|
+
|
|
5
|
+
def create_admin_user
|
|
6
|
+
say 'Creating default admin...'
|
|
7
|
+
|
|
8
|
+
email = ask('Email [admin@example.com] : ').presence || 'admin@example.com'
|
|
9
|
+
password = ask('Password [password] : ').presence || 'password'
|
|
10
|
+
|
|
11
|
+
AdminUser.create! email: email, password: password
|
|
12
|
+
|
|
13
|
+
say 'Created AdminUser'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Para
|
|
2
|
+
class ComponentGenerator < Rails::Generators::NamedBase
|
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
4
|
+
|
|
5
|
+
desc 'Para component generator'
|
|
6
|
+
|
|
7
|
+
def welcome
|
|
8
|
+
say 'Creating component...'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def copy_component
|
|
12
|
+
template 'component.rb', "app/components/#{ component_file_name }.rb"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def copy_component_controller
|
|
16
|
+
template 'component_controller.rb', "app/controllers/admin/#{ component_file_name }_controller.rb"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def add_require_to_application_controller
|
|
20
|
+
prepend_to_file 'app/controllers/application_controller.rb' do
|
|
21
|
+
"require '#{ component_file_name }'\n"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def create_show_component_view
|
|
26
|
+
template 'show.html.haml', "app/views/admin/#{ component_file_name }/show.html.haml"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def add_route
|
|
30
|
+
route_file = File.read(Rails.root.join('config/routes.rb'))
|
|
31
|
+
|
|
32
|
+
unless route_file.match /^\s+namespace :admin do/
|
|
33
|
+
route "namespace :admin do\n end\n"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
inject_into_file 'config/routes.rb', after: ' namespace :admin do' do
|
|
37
|
+
"\n component :#{ file_name } do\n end"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def component_name
|
|
44
|
+
if class_name.match(/Component/i)
|
|
45
|
+
class_name
|
|
46
|
+
else
|
|
47
|
+
"#{ class_name }Component"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def component_file_name
|
|
52
|
+
if file_name.match(/component/i)
|
|
53
|
+
file_name
|
|
54
|
+
else
|
|
55
|
+
"#{ file_name }_component"
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Para
|
|
2
|
+
class ExporterGenerator < Rails::Generators::NamedBase
|
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
4
|
+
|
|
5
|
+
argument :formats, type: :array
|
|
6
|
+
|
|
7
|
+
desc 'Para exporter generator'
|
|
8
|
+
|
|
9
|
+
def copy_resource_exporter
|
|
10
|
+
formats.each do |format|
|
|
11
|
+
# Set the format to be accessible by the template to define its
|
|
12
|
+
# class name
|
|
13
|
+
@format = format
|
|
14
|
+
|
|
15
|
+
template(
|
|
16
|
+
"#{ base_exporter_template_name_for(format) }_exporter.rb",
|
|
17
|
+
"app/exporters/#{ format }/#{ plural_file_name }_exporter.rb"
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def model_exporter_name
|
|
25
|
+
Para::Exporter.model_exporter_name(class_name)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def format_module_name_for(format)
|
|
29
|
+
Para::Exporter.format_exporter_name(format)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def base_exporter_template_name_for(format)
|
|
33
|
+
format_specific_template = "../templates/#{ format }_exporter.rb"
|
|
34
|
+
|
|
35
|
+
if File.exists?(File.expand_path(format_specific_template, __FILE__))
|
|
36
|
+
format
|
|
37
|
+
else
|
|
38
|
+
'base'
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Para
|
|
2
|
+
class FormGenerator < Para::Generators::NamedBase
|
|
3
|
+
include Para::Admin::BaseHelper
|
|
4
|
+
include Para::Generators::FieldHelpers
|
|
5
|
+
|
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
|
7
|
+
|
|
8
|
+
def generate_form
|
|
9
|
+
template(
|
|
10
|
+
"_form.html.haml",
|
|
11
|
+
"app/views/admin/#{ plural_namespaced_path }/_form.html.haml"
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
module Para
|
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
4
|
+
|
|
5
|
+
desc 'Para install generator'
|
|
6
|
+
|
|
7
|
+
def welcome
|
|
8
|
+
say 'Installing para engine ...'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def copy_initializer_file
|
|
12
|
+
copy_file 'initializer.rb', 'config/initializers/para.rb'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def copy_components_config
|
|
16
|
+
copy_file 'components.rb', 'config/components.rb'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def copy_migrations
|
|
20
|
+
rake 'para_engine:install:migrations'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def install_gems
|
|
24
|
+
gemfile_contents = File.read(Rails.root.join('Gemfile'))
|
|
25
|
+
|
|
26
|
+
[
|
|
27
|
+
['devise', '~> 3.0'],
|
|
28
|
+
['simple_form'],
|
|
29
|
+
['simple_form_extension'],
|
|
30
|
+
# Pull requests are pending, and I don't want to release the gem
|
|
31
|
+
# under another name to be able to depend on it
|
|
32
|
+
['active_decorator', github: 'glyph-fr/active_decorator', branch: 'dev'],
|
|
33
|
+
['paperclip', '~> 4.2'],
|
|
34
|
+
['cancancan', '~> 1.9'],
|
|
35
|
+
['friendly_id', '~> 5.0'],
|
|
36
|
+
['rolify', '~> 3.4'],
|
|
37
|
+
['kaminari', '>= 0.16.1'],
|
|
38
|
+
['ransack', '>= 1.4.1'],
|
|
39
|
+
['bootstrap-kaminari-views', '>= 0.0.5']
|
|
40
|
+
].each do |name, *args|
|
|
41
|
+
unless gemfile_contents.match(/gem ['"]#{ name }['"]/)
|
|
42
|
+
gem name, *args
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def bundle_install
|
|
48
|
+
Bundler.with_clean_env do
|
|
49
|
+
run 'bundle install'
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def friendly_id_install
|
|
54
|
+
generate 'friendly_id'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def simple_form_install
|
|
58
|
+
generate 'simple_form:install', '--bootstrap'
|
|
59
|
+
generate 'simple_form_extension:install'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def cancan_install
|
|
63
|
+
generate 'cancan:ability'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def devise_install
|
|
67
|
+
generate 'devise:install'
|
|
68
|
+
generate 'devise', 'AdminUser'
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def rolify_install
|
|
72
|
+
generate 'rolify Role AdminUser'
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def migrate
|
|
76
|
+
rake 'db:migrate'
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def add_admin_user_to_ability
|
|
80
|
+
inject_into_file 'app/models/ability.rb', after: '# Define abilities for the passed in user here. For example:' do
|
|
81
|
+
"\n\n if user.is_a?(AdminUser)\n can :manage, :all\n end\n"
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def create_default_admin
|
|
86
|
+
generate 'para:admin_user'
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def mount_engine
|
|
90
|
+
say "Mounting Para engine in routes"
|
|
91
|
+
gsub_file 'config/routes.rb', /para_at.+\n/, ''
|
|
92
|
+
route "para_at '/'"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def final_message
|
|
96
|
+
say <<-MESSAGE
|
|
97
|
+
|
|
98
|
+
*******************************************************************************
|
|
99
|
+
|
|
100
|
+
Para was successfully installed in your app.
|
|
101
|
+
|
|
102
|
+
Please not that your should define your root path in your application routes.rb
|
|
103
|
+
for the Para admin panel to work :
|
|
104
|
+
|
|
105
|
+
e.g.: root to: 'home#index'
|
|
106
|
+
|
|
107
|
+
*******************************************************************************
|
|
108
|
+
|
|
109
|
+
MESSAGE
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Para.components.draw do
|
|
2
|
+
# Create a components section in the menu with a :menu identifier
|
|
3
|
+
# You can translate the section title at: components.section.menu
|
|
4
|
+
#
|
|
5
|
+
# section :menu do
|
|
6
|
+
#
|
|
7
|
+
# # Create a component of type :crud in the the section :menu, with the
|
|
8
|
+
# # identifier :pages, with the model 'Page' as the target type and
|
|
9
|
+
# # namespacing it's managed to resources to the component
|
|
10
|
+
# #
|
|
11
|
+
# component :pages, :crud, model_type: 'Page', namespaced: true
|
|
12
|
+
# end
|
|
13
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Para.config do |config|
|
|
2
|
+
# Configure authentication method to be called when accessing the admin panel
|
|
3
|
+
# config.authenticate_admin_method = :authenticate_admin!
|
|
4
|
+
|
|
5
|
+
# Configure the method to retrieve current admin user from
|
|
6
|
+
# config.current_admin_method = :current_admin_user
|
|
7
|
+
|
|
8
|
+
# Configure the default Kaminari pagination theme to use
|
|
9
|
+
# config.pagination_theme = 'twitter-bootstrap-3'
|
|
10
|
+
|
|
11
|
+
# Configure the default admin HTML page <title>
|
|
12
|
+
# config.admin_title = I18n.t('para.admin.title')
|
|
13
|
+
|
|
14
|
+
# Configure the default max depth for trees
|
|
15
|
+
# config.default_tree_max_depth = 3
|
|
16
|
+
|
|
17
|
+
# Configure the methods which Para will try to call on resources to fetch
|
|
18
|
+
# their name.
|
|
19
|
+
#
|
|
20
|
+
# Default is [:name, :title]
|
|
21
|
+
#
|
|
22
|
+
# config.resource_name_methods += [:full_name]
|
|
23
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Para
|
|
2
|
+
class NestedFieldsGenerator < Para::Generators::NamedBase
|
|
3
|
+
include Para::Admin::BaseHelper
|
|
4
|
+
include Para::Generators::FieldHelpers
|
|
5
|
+
|
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
|
7
|
+
|
|
8
|
+
def generate_fields
|
|
9
|
+
template(
|
|
10
|
+
"_nested_fields.html.haml",
|
|
11
|
+
"app/views/admin/#{ plural_namespaced_path }/_fields.html.haml"
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|