repolho 0.1.3 → 0.1.5
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
- checksums.yaml.gz.sig +4 -3
- data/README.md +23 -5
- data/lib/repolho/main.rb +32 -0
- data/lib/repolho/version.rb +1 -1
- data/lib/repolho.rb +5 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +1 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 60d2951254acb9e8431cbda5c6710c74959759ddbeadff1b2d2f1e60fe4d9da6
|
|
4
|
+
data.tar.gz: 8b98f398503e47af413bfc9d4d5dc5a32c287946920b9be75cfd8db7f8f1cef2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5b1f71c5f938aac694b6788d025e6965acea778c06f83c99f0159b093c562a2c10977f3987236b39f8c93918d780fe5500f04e34d5b88da484eccda7f931fe5
|
|
7
|
+
data.tar.gz: 76d0fabef7c98d14940ae9e9c0cbd1e9a5d5cbe396cc12412ed12d5748a2944c81b2c52db26df8801f653ab3ae7e761bb48f0596a85a0befa721dced04b0f17e
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
w
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
��o�.�n��-w-��{�a��2�#귗��W�\�)�G��y�U"�cy��C�ׁ���#������D�c���1�
|
|
2
|
+
�IY�qsͼS���= ��K���tT��L����S�5tA�ک�nl������=VI�լu�g��� �*[��b�
|
|
3
|
+
w����-&�>�
|
|
4
|
+
|
data/README.md
CHANGED
|
@@ -58,7 +58,7 @@ sections). Everything inside the custom elements is processed as ERB.
|
|
|
58
58
|
|
|
59
59
|
| Element | Purpose | Attributes |
|
|
60
60
|
|---------|---------|------------|
|
|
61
|
-
| `<report>` | Root container of the report | `pagination` (optional, `"true"`): enables client-side page navigation. Also accepts `pagination-first`, `pagination-prev`, `pagination-next`, `pagination-last` for custom labels. |
|
|
61
|
+
| `<report>` | Root container of the report | `pagination` (optional, `"true"`): enables client-side page navigation. Also accepts `pagination-first`, `pagination-prev`, `pagination-next`, `pagination-last` for custom labels.<br>`orientation` (optional, `"portrait"` or `"landscape"`): page orientation for print.<br>`paper` (optional, e.g. `"A4"`, `"Letter"`): paper size for print. If either is present, a `@media print` style is injected at the end of `<body>`. |
|
|
62
62
|
| `<report-page>` | Defines a page (required, only one) | `rows` (required): max data rows per page |
|
|
63
63
|
| `<report-group>` | Nested grouping | `id` (required), `attr` (required), `reprint-header-on-page-break` (optional, `"true"`) |
|
|
64
64
|
| `<report-header>` | Header of the current container | — |
|
|
@@ -262,18 +262,35 @@ Repolho.include_rails_helpers!(
|
|
|
262
262
|
|
|
263
263
|
### Outside Rails
|
|
264
264
|
|
|
265
|
-
You need the corresponding gems
|
|
265
|
+
You need the corresponding gems. Directly requiring the individual helper file
|
|
266
|
+
triggers an autoload problem in recent Rails versions, so load the helpers
|
|
267
|
+
framework first:
|
|
266
268
|
|
|
267
269
|
```ruby
|
|
268
270
|
# Gemfile
|
|
269
271
|
gem "actionview"
|
|
270
|
-
# or, if you prefer the lower-level helpers:
|
|
271
|
-
# gem "activesupport"
|
|
272
272
|
|
|
273
|
-
require "action_view
|
|
273
|
+
require "action_view"
|
|
274
|
+
require "action_view/helpers" # loads NumberHelper and the rest
|
|
274
275
|
Repolho.include_rails_helpers!
|
|
275
276
|
```
|
|
276
277
|
|
|
278
|
+
Alternatively (and often simpler), use `ActiveSupport::NumberHelper`, which is
|
|
279
|
+
designed to be used outside of a view context. The method names are almost the
|
|
280
|
+
same (`number_to_currency`, `number_to_rounded`, etc.):
|
|
281
|
+
|
|
282
|
+
```ruby
|
|
283
|
+
# Gemfile
|
|
284
|
+
gem "activesupport"
|
|
285
|
+
|
|
286
|
+
require "active_support/number_helper"
|
|
287
|
+
Repolho.include_rails_helpers!(ActiveSupport::NumberHelper)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Note: some method names differ slightly between the two modules
|
|
291
|
+
(`number_with_delimiter` vs `number_to_delimited`). Prefer the ActiveSupport
|
|
292
|
+
version when you are not inside Rails.
|
|
293
|
+
|
|
277
294
|
Instance variables from the Rails view (such as `@current_template`) are not
|
|
278
295
|
automatically copied. Pass them explicitly through the `locals` hash:
|
|
279
296
|
|
|
@@ -283,6 +300,7 @@ Repolho::Main.new(path, data, current_template: @current_template, user: current
|
|
|
283
300
|
|
|
284
301
|
They become `@current_template` and `@user` inside the templates.
|
|
285
302
|
|
|
303
|
+
|
|
286
304
|
## Signing
|
|
287
305
|
|
|
288
306
|
|
data/lib/repolho/main.rb
CHANGED
|
@@ -77,6 +77,8 @@ module Repolho
|
|
|
77
77
|
@after = ""
|
|
78
78
|
@body = ""
|
|
79
79
|
@pagination = false
|
|
80
|
+
@orientation = nil
|
|
81
|
+
@paper = nil
|
|
80
82
|
@pagination_labels = {
|
|
81
83
|
first: "First",
|
|
82
84
|
prev: "<",
|
|
@@ -124,6 +126,15 @@ module Repolho
|
|
|
124
126
|
end
|
|
125
127
|
end
|
|
126
128
|
|
|
129
|
+
css = print_css
|
|
130
|
+
if css
|
|
131
|
+
if after_content =~ /<\/body>/i
|
|
132
|
+
after_content = after_content.sub(/<\/body>/i, "#{css}</body>")
|
|
133
|
+
else
|
|
134
|
+
after_content += css
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
127
138
|
@page.append_raw(after_content)
|
|
128
139
|
end
|
|
129
140
|
|
|
@@ -136,6 +147,25 @@ module Repolho
|
|
|
136
147
|
@page.instance_variable_set(:@pagination_last, @pagination_labels[:last])
|
|
137
148
|
end
|
|
138
149
|
|
|
150
|
+
def print_css
|
|
151
|
+
return nil unless @orientation || @paper
|
|
152
|
+
|
|
153
|
+
size_parts = []
|
|
154
|
+
size_parts << @paper if @paper
|
|
155
|
+
size_parts << @orientation if @orientation
|
|
156
|
+
size = size_parts.join(" ")
|
|
157
|
+
|
|
158
|
+
<<~HTML
|
|
159
|
+
<style>
|
|
160
|
+
@media print {
|
|
161
|
+
@page {
|
|
162
|
+
size: #{size};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
</style>
|
|
166
|
+
HTML
|
|
167
|
+
end
|
|
168
|
+
|
|
139
169
|
def make_columns
|
|
140
170
|
return [] if @data.empty?
|
|
141
171
|
|
|
@@ -199,6 +229,8 @@ module Repolho
|
|
|
199
229
|
|
|
200
230
|
report_node = report.first
|
|
201
231
|
@pagination = report_node["pagination"] == "true"
|
|
232
|
+
@orientation = report_node["orientation"]&.downcase
|
|
233
|
+
@paper = report_node["paper"]
|
|
202
234
|
|
|
203
235
|
if @pagination
|
|
204
236
|
@pagination_labels[:first] = report_node["pagination-first"] if report_node["pagination-first"]
|
data/lib/repolho/version.rb
CHANGED
data/lib/repolho.rb
CHANGED
|
@@ -19,6 +19,10 @@ module Repolho
|
|
|
19
19
|
# Repolho.include_rails_helpers!(ActionView::Helpers::NumberHelper, ActionView::Helpers::TextHelper)
|
|
20
20
|
def self.include_rails_helpers!(*modules)
|
|
21
21
|
modules = [ActionView::Helpers::NumberHelper] if modules.empty?
|
|
22
|
-
modules.each
|
|
22
|
+
modules.each do |mod|
|
|
23
|
+
next if Container.include?(mod)
|
|
24
|
+
|
|
25
|
+
Container.include(mod)
|
|
26
|
+
end
|
|
23
27
|
end
|
|
24
28
|
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
G�X�]���Rr��Ʒݠ�<O�"�>.g<��2�hd�@U?W�B^!c��K�a��[/"�+� V�C�/KY0ջ�L�a�S�=9��5䰿�,+nl�
|
|
3
|
-
���Q���52���m'�_q.�x"<(�ySb��80hBQUT�3�E��!~f��?���F��Ϸ�]uَ�t�3��G����D��U�,�,;MY@�Q�V�"�e�@���;��)�5�w�m��vQ�9� R���m��~
|
|
1
|
+
�i��tٗ.U�ג���Έ+{��Ws�����N���pX��U�s\̴ڈa�@s|.����%���LT$|�\��J�[+3�\A����MV��(�����y��۫�uv����-�2��(�:��KdKRZf��hʹ���8[�ό���'����q6��� �Wt#'!5���E��,I.Zo_7����vO�A��B�h��e���u�.ȟ��*%�zɳ��O I�#^��Ӥ(~Fӗ�.�:[F�L���:�`��Ld�!θ���y��\hø�(�[}G�?���p��eST�2��?���E�t�T�^�2v?����������G`M ������/�}Ce�a��fz���<>]��_�����{���je�����/AH�7*
|