tramway 0.5.1 → 0.5.1.1
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 +65 -0
- data/app/components/tailwinds/table/row_component.html.haml +1 -1
- data/app/controllers/tramway/entities_controller.rb +4 -0
- data/app/views/tramway/entities/index.html.haml +7 -7
- data/app/views/tramway/layouts/application.html.haml +26 -0
- data/config/tailwind.config.js +52 -0
- data/lib/tramway/base_decorator.rb +19 -0
- data/lib/tramway/version.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4ba049579087665a532f06011144ca74a591cb7704769c8a2c69c99aca81aad
|
4
|
+
data.tar.gz: 44b743f0aa80d9d6b074a325505b66a8c7a019f1c59103fd6ea79e5faf567ed8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88a6ba5eda48febc6aec0c5c15915ee276161ddedbaa281fed6a65e68b0dc55e4d04e53a6505d68fb9e9a5871249ea2b565ac9d828dbf2b186d8bd11368b663c
|
7
|
+
data.tar.gz: 25ae018d2242c6adc460e1058489109c2fae3d151243b8240d925ed1a63e0d1e19beef90d3c23cf036d34d207816c316051c8db5d681628ea2bedb0743e1a33f
|
data/README.md
CHANGED
@@ -17,6 +17,8 @@ Add this line to your application's Gemfile:
|
|
17
17
|
|
18
18
|
```ruby
|
19
19
|
gem "tramway"
|
20
|
+
gem "haml-rails"
|
21
|
+
gem "kaminari"
|
20
22
|
gem "view_component"
|
21
23
|
```
|
22
24
|
|
@@ -26,8 +28,71 @@ OR
|
|
26
28
|
bundle add tramway view_component
|
27
29
|
```
|
28
30
|
|
31
|
+
## Getting Started
|
32
|
+
|
33
|
+
**Step 1**
|
34
|
+
|
35
|
+
*config/initializers/tramway.rb*
|
36
|
+
```ruby
|
37
|
+
Tramway.configure do |config|
|
38
|
+
config.entities = [
|
39
|
+
{
|
40
|
+
name: :user,
|
41
|
+
pages: [:index],
|
42
|
+
}
|
43
|
+
]
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
**Step 2**
|
48
|
+
|
49
|
+
*config/routes.rb*
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
Rails.application.routes.draw do
|
53
|
+
mount Tramway::Engine, at: '/'
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
**Step 3**
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
class UserDecorator < Tramway::BaseDecorator
|
61
|
+
def self.list_attributes
|
62
|
+
[:id, :email, :created_at]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
**Step 4**
|
68
|
+
|
69
|
+
Copy this [file](https://github.com/Purple-Magic/tramway/blob/main/config/tailwind.config.js) to config/tailwind.config.js
|
70
|
+
|
71
|
+
|
72
|
+
**Step 5**
|
73
|
+
|
74
|
+
Run tailwincss-rails compiler
|
75
|
+
|
76
|
+
|
77
|
+
```bash
|
78
|
+
bin/rails tailwindcss:build
|
79
|
+
```
|
80
|
+
|
81
|
+
**Step 6**
|
82
|
+
|
83
|
+
Run your server
|
84
|
+
|
85
|
+
```bash
|
86
|
+
bundle exec rails s
|
87
|
+
```
|
88
|
+
|
89
|
+
**Step 7**
|
90
|
+
|
91
|
+
Open [http://localhost:3000/users](http://localhost:3000/users)
|
92
|
+
|
29
93
|
## Usage
|
30
94
|
|
95
|
+
|
31
96
|
### Tramway Entities
|
32
97
|
|
33
98
|
Tramway is an entity-based framework. **Entity** is the class on whose objects actions be applied: _index, show, create, update, and destroy_. Tramway will support numerous classes as entities. For now, Entity could be only **ActiveRecord::Base** class.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
- cols = cells.count.times.map { |item| "1fr" }.join(",")
|
4
4
|
|
5
5
|
-# desktop view
|
6
|
-
= row_tag class: "div-table-row block grid gap-4 bg-white border-b dark:bg-gray-800 dark:border-gray-700 grid-cols-[#{cols}]" do
|
6
|
+
= row_tag class: "div-table-row block grid gap-4 bg-white border-b dark:bg-gray-800 dark:border-gray-700 cursor-pointer hover:bg-purple-100 grid-cols-[#{cols}]" do
|
7
7
|
- cells.each do |(_, value)|
|
8
8
|
.div-table-cell.px-6.py-4.font-medium.text-gray-900.whitespace-nowrap.dark:text-white.sm:text-xs.text-base
|
9
9
|
= value
|
@@ -3,6 +3,10 @@
|
|
3
3
|
module Tramway
|
4
4
|
# Main controller for entities pages
|
5
5
|
class EntitiesController < Tramway.config.application_controller.constantize
|
6
|
+
prepend_view_path "#{Gem::Specification.find_by_name('tramway').gem_dir}/app/views"
|
7
|
+
|
8
|
+
layout 'tramway/layouts/application'
|
9
|
+
|
6
10
|
helper Tramway::ApplicationHelper
|
7
11
|
include Rails.application.routes.url_helpers
|
8
12
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
- decorator = Tramway::Decorators::NameBuilder.default_decorator_class_name(@model_class)
|
2
2
|
- list_attributes = decorator.constantize.list_attributes
|
3
3
|
|
4
|
-
.w-
|
4
|
+
.mt-8{ class: 'w-2/3' }
|
5
5
|
- content_for :title, page_title
|
6
6
|
|
7
7
|
.flex.justify-between.items-center.md:mt-4.mt-2
|
@@ -16,10 +16,10 @@
|
|
16
16
|
You should fill class-level method `self.list_attributes` inside your
|
17
17
|
= decorator
|
18
18
|
|
19
|
-
= component 'tailwinds/table' do
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
= component 'tailwinds/table' do
|
20
|
+
= component 'tailwinds/table/header', headers: list_attributes.map { |attribute| @model_class.human_attribute_name(attribute) }
|
21
|
+
- @entities.each do |item|
|
22
|
+
= render 'entity', entity: item
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
.flex.mt-4
|
25
|
+
= paginate @entities
|
@@ -0,0 +1,26 @@
|
|
1
|
+
%html
|
2
|
+
%head
|
3
|
+
%title= content_for(:title) || "Tramway"
|
4
|
+
%meta{name: "viewport", content: "width=device-width,initial-scale=1"}
|
5
|
+
%meta{name: "apple-mobile-web-app-capable", content: "yes"}
|
6
|
+
%meta{name: "mobile-web-app-capable", content: "yes"}
|
7
|
+
= csrf_meta_tags
|
8
|
+
= csp_meta_tag
|
9
|
+
|
10
|
+
= yield :head
|
11
|
+
|
12
|
+
/ Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!)
|
13
|
+
/ = tag.link rel: "manifest", href: pwa_manifest_path(format: :json)
|
14
|
+
|
15
|
+
%link{rel: "icon", href: "/icon.png", type: "image/png"}
|
16
|
+
%link{rel: "icon", href: "/icon.svg", type: "image/svg+xml"}
|
17
|
+
%link{rel: "apple-touch-icon", href: "/icon.png"}
|
18
|
+
|
19
|
+
/ Includes all stylesheet files in app/assets/stylesheets
|
20
|
+
= stylesheet_link_tag "tailwind", "data-turbo-track": "reload"
|
21
|
+
|
22
|
+
%body.bg-gray-100
|
23
|
+
= tramway_navbar title: 'Tramway'
|
24
|
+
|
25
|
+
.container.mx-auto.p-4.flex.align-center.justify-center
|
26
|
+
= yield
|
@@ -0,0 +1,52 @@
|
|
1
|
+
const defaultTheme = require('tailwindcss/defaultTheme');
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
darkMode: 'class',
|
5
|
+
content: [
|
6
|
+
'./public/*.html',
|
7
|
+
'./app/components/**/*.html.haml',
|
8
|
+
'./app/helpers/**/*.rb',
|
9
|
+
'./app/javascript/**/*.js',
|
10
|
+
'./app/views/**/*.{erb,haml,html,slim}'
|
11
|
+
],
|
12
|
+
theme: {
|
13
|
+
extend: {
|
14
|
+
screens: {
|
15
|
+
...defaultTheme.screens,
|
16
|
+
},
|
17
|
+
},
|
18
|
+
},
|
19
|
+
safelist: [
|
20
|
+
'div-table',
|
21
|
+
'div-table-row',
|
22
|
+
'div-table-cell',
|
23
|
+
'hidden',
|
24
|
+
'text-xl',
|
25
|
+
'text-4xl',
|
26
|
+
'font-bold',
|
27
|
+
'xl:hidden',
|
28
|
+
'grid-cols-[1fr,1fr,1fr]',
|
29
|
+
'text-right',
|
30
|
+
'w-2/3',
|
31
|
+
'flex',
|
32
|
+
// multiselect styles
|
33
|
+
'absolute', 'shadow', 'top-100', 'z-40', 'w-full', 'lef-0', 'rounded', 'max-h-select', 'overflow-y-auto', 'cursor-pointer', 'rounded-t', 'border-b', 'hover:bg-teal-100', 'items-center', 'border-transparent', 'border-l-2,', 'relative', 'hover:border-teal-100', 'leading-6', 'bg-transparent', 'appearance-none', 'outline-none', 'h-full' , 'justify-center', 'm-1', 'font-medium', 'rounded-full', 'text-teal-700', 'bg-teal-100', 'border', 'border-teal-300', 'text-xs', 'font-normal', 'leading-none', 'max-w-full', 'flex-initial', 'flex-auto', 'flex-row-reverse',, 'flex-col', 'min-w-96', 'w-fit', 'flex-wrap', 'w-8', 'border-l',
|
34
|
+
{
|
35
|
+
pattern: /(text|bg|border)-(purple|blue|gray|yellow|red|white|green)-\d+/,
|
36
|
+
variants: ['dark', 'focus', 'hover', 'dark:hover'],
|
37
|
+
},
|
38
|
+
{
|
39
|
+
pattern: /(text|bg)-(purple|blue|gray|yellow|red|white)/,
|
40
|
+
variants: ['dark', 'focus', 'hover', 'dark:hover'],
|
41
|
+
},
|
42
|
+
{
|
43
|
+
pattern: /(m|p)(l|r|b|t|x|y)-\d+/
|
44
|
+
},
|
45
|
+
],
|
46
|
+
plugins: [
|
47
|
+
require('@tailwindcss/forms'),
|
48
|
+
require('@tailwindcss/aspect-ratio'),
|
49
|
+
require('@tailwindcss/typography'),
|
50
|
+
require('@tailwindcss/container-queries'),
|
51
|
+
],
|
52
|
+
};
|
@@ -57,5 +57,24 @@ module Tramway
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def show_path = nil
|
60
|
+
|
61
|
+
# :reek:ManualDispatch { enabled: false } because there is the idea to manual dispatch
|
62
|
+
def method_missing(method_name, *, &)
|
63
|
+
url_helpers = Rails.application.routes.url_helpers
|
64
|
+
|
65
|
+
if method_name.to_s.end_with?('_path', '_url')
|
66
|
+
return url_helpers.public_send(method_name, *, &) if url_helpers.respond_to?(method_name)
|
67
|
+
|
68
|
+
raise NoMethodError, "undefined method `#{method_name}` for #{self}" unless respond_to_missing?(method_name)
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
super
|
73
|
+
end
|
74
|
+
|
75
|
+
# :reek:BooleanParameter { enabled: false } because it's a part of the duck-typing
|
76
|
+
def respond_to_missing?(method_name, include_private = false)
|
77
|
+
method_name.to_s.end_with?('_path', '_url') || super
|
78
|
+
end
|
60
79
|
end
|
61
80
|
end
|
data/lib/tramway/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tramway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.1
|
4
|
+
version: 0.5.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kalashnikovisme
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-01-
|
12
|
+
date: 2025-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: anyway_config
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: kaminari
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: rails
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,7 +191,9 @@ files:
|
|
177
191
|
- app/views/kaminari/_prev_page.html.haml
|
178
192
|
- app/views/tramway/entities/_entity.html.haml
|
179
193
|
- app/views/tramway/entities/index.html.haml
|
194
|
+
- app/views/tramway/layouts/application.html.haml
|
180
195
|
- config/routes.rb
|
196
|
+
- config/tailwind.config.js
|
181
197
|
- lib/rules/turbo_html_attributes_rules.rb
|
182
198
|
- lib/tasks/tramway_tasks.rake
|
183
199
|
- lib/tramway.rb
|