This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WIDTH=32; | |
| DEPTH=8192; | |
| ADDRESS_RADIX=HEX; | |
| DATA_RADIX=HEX; | |
| CONTENT BEGIN | |
| [00000000..0000000f] : DEAD; | |
| -- @ 0x00000040 : XOR ZERO,ZERO,ZERO | |
| 00000010 : 00000011; | |
| -- @ 0x00000044 : LW SP,STACKTOPVAL(ZERO) | |
| 00000011 : a0c001a4; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| validate :all_sources_have_title_and_url | |
| def all_sources_have_title_and_url | |
| if sources.any? {|source| !source['title'].present? || !source['url'].present? } | |
| errors.add(:base, 'All sources must have a title and url') | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DEFAULT_PARAMS = { :sources => [] } | |
| def post_params | |
| DEFAULT_PARAMS.merge( | |
| params.require(:post).permit( | |
| :title, | |
| :body, | |
| sources: [ | |
| :title, | |
| :url, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= text_field_tag 'post[sources][][title]', item[‘title’] %> | |
| <%= text_field_tag 'post[sources][][url]', item[‘url’], placeholder: 'https://example.com' %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| post[sources][][title]: "Example One" | |
| post[sources][][url]: "https://one.example.com" | |
| post[sources][][title]: "Example Two" | |
| post[sources][][url]: "https://two.example.com" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DEFAULT_PARAMS = { :sources => [] } | |
| def post_params | |
| DEFAULT_PARAMS.merge( | |
| params.require(:post).permit( | |
| :title, | |
| :body, | |
| sources: [], | |
| ) | |
| ) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function () { | |
| $('form').on('click', '.remove-section', function(event) { | |
| event.preventDefault() | |
| const removalTarget = $(this).data('target') | |
| $(this).closest(removalTarget).remove() | |
| }) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function () { | |
| $('form').on('click', '.add-fields', function(event) { | |
| event.preventDefault() | |
| const time = new Date().getTime() | |
| const regexp = new RegExp($(this).data('id'), 'g') | |
| $(this).before( | |
| $(this).data('fields').replace(regexp, time), | |
| ) | |
| }) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def add_source_button | |
| fields = render('posts/fields/source', source: '', id: :new_source_field) | |
| button_tag "Add Source", class: "add-fields", data: { id: :new_source_field, fields: fields } | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <% @post.sources.each do |source| %> | |
| <%= render("posts/fields/source", source: source) %> | |
| <% end %> | |
| <%= add_source_button %> |
NewerOlder