Skip to content

Commit

Permalink
Jfb/2023 10 07 v0.5.24 (#130)
Browse files Browse the repository at this point in the history
* v0.5.24

* removing error
  • Loading branch information
jasonfb authored Oct 8, 2023
1 parent 72a1132 commit 627ee6a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
hot-glue (0.5.23.1)
hot-glue (0.5.24)
ffaker (~> 2.16)
kaminari (~> 1.2)
rails (> 5.1)
Expand Down Expand Up @@ -139,7 +139,7 @@ GEM
mini_mime (1.1.2)
mini_portile2 (2.8.4)
minitest (5.16.3)
net-imap (0.3.7)
net-imap (0.4.0)
date
net-protocol
net-pop (0.1.2)
Expand Down
63 changes: 34 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -664,13 +664,16 @@ For booleans shown as checkboxes or switches, it affects only the view output as

You will need to separately specify them as show-only if you want them to be non-editable.

The available modifiers are:
Notice that each modifiers can be used with specific field types.

| modifier | what it does | can be used on | | |
|---------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------|---|---|
| $ | wraps output in `number_to_currency()` | float, integer | | |
| truthy label\|falsy label | specify a binary switch with a pipe (\|) character if the value is truthy, it will display as "truthy label" if the value is falsy, it will display as "falsy label" | boolean, datetime, date, time | | |
| | | | | |
| user modifier | what it does | Field types | | |
|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|---|---|
| $ | wraps output in `number_to_currency()` | floats and integers | | |
| (truthy label)\|(falsy label) | specify a binary switch with a pipe (\|) character if the value is truthy, it will display as "truthy label" if the value is falsy, it will display as "falsy label" | booleans, datetimes, dates, times | | |
| partials | applies to enums only, you must have a partial whose name matches each enum type | enums only | | |
| tinymce | applies to text fields only, be sure to setup TineMCE globally | text fields only | | |

Except for "(truthy label)" and "(falsy label)" which represent the labels you should specify separated by the pipe character (|), use the modifier exactly as shown.

### `--pundit`
If you enable Pundit, your controllers will look for a Policy that matches the name of the thing being built.
Expand Down Expand Up @@ -1412,7 +1415,7 @@ end
```
3. Then, also inside of your `<head>` tag, add this:
```
<script>
<script>
TinyMCERails.configuration.default = {
selector: "textarea.tinymce",
cache_suffix: "?v=6.7.0",
Expand All @@ -1421,56 +1424,58 @@ end
plugins: "table,fullscreen,image,code,searchreplace,wordcount,visualblocks,visualchars,link,charmap,directionality,nonbreaking,media,advlist,autolink,lists",
images_upload_url: "/uploader/image"
};
</script>
```

(Note that the `tinymce_assets` helper method provided by the Gem method generates its own script tags so don't try to put that helper inside the other code.)

Then to `application.js` add

Generate a stimulus controller
```
rails generate stimulus TinyMceController
import "./tinymce_init"
```

create a file `tinymce_init.js` with this content

Replace the boilerplate with:
```
import { Controller } from "@hotwired/stimulus"
// Connects to data-controller="tiny-mce"
export default class extends Controller {
connect() {
TinyMCERails.initialize('default', {
convert_urls: true,
uploadimage: true
});
}
const reinitTiny = () => {
tinymce.init({
selector: 'textarea.tinymce', // Add the appropriate selector for your textareas
// Other TinyMCE configuration options
});
}
window.addEventListener('turbo:before-fetch-response', () => {
tinymce.remove();
tinymce.init({selector:'textarea.tinymce'});
})
window.addEventListener('turbo:frame-render', reinitTiny)
window.addEventListener('turbo:render', reinitTiny)
```

When generating text_area fields only, you may now use `--modify` with the modifier `tinymce`.
Once you have completed this setup, you can now use `--modify` with the modifier `tinymce`.

For example, to display the field `my_story` on the object `Thing`, you'd generate with:

```
bin/rails generate Thing --include=my_story --modify='my_story{tinymce}'
```



# VERSION HISTORY

#### TBR -
#### 2023-10-07 - v0.5.24

• TinyMCE implementation. See 'TinyMCE' above.

TinyMCE implementation
Note: I plan to also implement ActionText as an alternative in the future. However, because TinyMCE is implemented with a `text` field type an ActionText is implemented with a Rails-specific `rich_text` field type, the two mechanisms will be incompatible with one another. TinyMCE has an annoying drawback in how it works with Turbo refreshes (not very consistently), and style of loading Javascript is discordant with Rails moving forward. So I am leaving this implementation as experimental.

• In the behavior specs, there is a code marker (start & end) where you can insert custom code that gets saved between
Spec Savestart code: In the behavior specs, there is a code marker (start & end) where you can insert custom code that gets saved between
build. The start code maker has changed from `#HOTGLUE-SAVESTART` to `# HOTGLUE-SAVESTART`
and the end code marker has changed from `#HOTGLUE-END` to `# HOTGLUE-END`. This now conforms to Rubocop.
Be sure to do find & replace in your existing projects to keep your custom code.

• Fix for specs for attachment fields. If you have attachments fields, you must have a sample file at `spec/fixtures/glass_button.png`


#### 2023-10-01 - v0.5.23
Expand Down
2 changes: 1 addition & 1 deletion lib/hotglue/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module HotGlue
class Version
CURRENT = '0.5.23.1'
CURRENT = '0.5.24'
end
end

0 comments on commit 627ee6a

Please sign in to comment.