ActiveAdmin - has_many and arbitrary html with the newer (1.0.0) dsl - activeadmin

Due to dependency complications from today's Rails and Sprockets vulnerability updates, I had to update ActiveAdmin to HEAD today, and the upgrade has done a number on one of my more complicated forms. See here for a much-simplified example: http://pastebin.com/Gt19TtYW
This markup rendered fine in the last version we were using (ref 8299dee5bd0) - the arbitrary html in the innermost inputs blocks rendered and each item.input as expected. However, in the newest version, only the last method invoked in the block is respected (so only <p>More static html</p> renders for each item). Even if I remove those static html containers and leave only item.input calls, I only get markup for the last method call in the block. This leaves me with two questions:
Is there a new preferred way to include arbitrary html under the new DSL? I tried div as per https://github.com/activeadmin/activeadmin/blob/master/docs/5-forms.md but that just made things worse (the arbitrary html ended up floating orphaned above the has_many markup).
Is there some new trick for the syntax inside has_many to get all of my item.input and other markup to render, instead of just the last thing called?

yes please do open issue(s) on GitHub for this. Our intention was that you use Arbre inside the inputs, so "para some static html" rather than "<p> ... <p>".html_safe However, so far this works inside inputs but not has_many. Also a fix was just added to has_many for the missing input so pull the latest and see if that helps.

Related

Simple tag helper "suddenly" no longer renders properly (only in production, only for one page)

As the title states, I'm having a finicky issue with .NET Core 2.2. I'm using tag helpers all over, but on the specific page that I'm having trouble with, it's actually the most simple use-case of all:
<a class="logout" asp-page="/Admin/Logout">Logout</a>
Some relevant notes:
As of yesterday, it worked in all environments without any issues.
This morning I made some changes seemingly unrelated to this page, and published again.
In the published version (on Azure), the tag helpers for this page only don't render, but instead appear in the source code as literals. (e.g. <a asp-page="..."></a>)
Still works without issue locally.
Here is the directory structure. The page in question is /Admin/Index.cshtml:
And my _ViewImports.cshtml (which again, I haven't changed in months):
#using redacted
#namespace redacted.Pages
#addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Explicitly adding the taghelper to the .chshtml file has solved this for me in the past. Unfortunately I am not aware of why this issue occurs randomly. In my specific use case,we were using custom and third party tag helpers which we suspect was causing the issues.
Try adding this line to the /Admin/Index.cshtml file:
#addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Nested input disappears when upgrading to activeadmin 1.0

I have a form that, when maximally simplified, looks like this.
ActiveAdmin.register Foo do
form do |f1|
f1.inputs 'DeepFoos' do
f1.has_many :deep_foos do |f2|
f2.input :name
f2.inputs "DeeperFoos for #{f2.object.name}" do
f2.has_many :deeper_foos do |f3|
f3.input :color
end
end
end
end
end
end
When I was using activeadmin 0.6.6, this rendered fine, with the double-nested resource. After updating to 1.0.0.pre5, the DeeperFoos input part of the form disappeared. There's no exception, and it's not in the html source code of the page. It's simply gone.
Weirdly, if I remove the line that says f2.input :name, the DeeperFoos input rendered again.
I tried putting a debugger in it, and the debugger is hit, but the gem is so indirect and metaprogrammed that I don't know how I could possibly gain insight from it.
I can't find anything relevant in the activeadmin upgrade docs or the formtastic upgrade docs (which, as a dependency, got upgraded from 2.2.1 to 3.1.5).
This is probably due to the rewrite to integrate Arbre into forms. You are welcome to open a forms issue but I've given up for now on patching together Arbre, Formtasic and ActionView: as you have discovered it's ugly as they don't always share the same output buffers. ASFAIK relatively few try to use nested has_many. Can you move the input below inputs? Remove the blank line? It may just be a case of fiddling around and taking the best compromise.

How to identify a section in an Evernote's note to update it later

I am making an App that automatically creates Notes into Evernote based on a Government API and I need to update these notes if this Government API change something.
But the thing is, Evernote uses a superset of XHTML called ENML and it doesn't allows me to use "id" or "data" attributes in any tag.
My question is how can I identify one tag or section in a Note that I've created to change/update it later.
We had the same issue, so we wrapped the inner HTML with a traceable span like this:
<span style="x-your-business-name:section;">Here put the inner HTML content</span>
At this point it's just XHTML traversing and updating.
The span doesn't influence in any way the display of the Evernote note.

Inner tags not parsing with Expression Engine 2 custom plugin

I've written a simple plugin that basically loops through a bunch of entries. The plugin is used to only display entries that contain a feature image, amongst some other minor logical conditions. The use of my tag looks something like this:
{exp:myentries:withimages channel="mychannel"}
<!-- This works fine -->
<h1>{title}</h1>
<!-- But nested exp:... tags don't seem to parse? -->
<p>{exp:ce_img:single src="feature_image"}</p>
{/exp:myentries:withimages}
I am calling
return $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $data);
from my custom EE plugin, the data is there, but only the nested {exp:... tags don't want to parse.
I've followed the online User Guide for creating plugins as close as I possibly could, but I need some help getting the other tags to parse? If I simply output {feature_image}, the field renders the src value for the image as expected.
Can anyone possibly shed some light on what I'm doing wrong?
You want to put parse="inward" parameter in your {exp:myentries:withimages tag, otherwise the template will try to parse the exp:ce_img call before {feature_image} is set.
{exp:myentries:withimages parse="inward" channel="mychannel"}
The parse="inward" will tell EE to run this tag first before parsing any other tags within the tag pair.
There are two important typos in your code.
{exp:ce_img:singe src="feature_image"}
Should read:
{exp:ce_img:single src="{feature_image}"}
If those differences are actually present in your template, then that would be it I believe.

Inserting a news-feed widget to a page

I have a page I'd like to embed a news-feed widget into (so that the feed from some remote site will be displayed in my site).
While there are quite a few free news-feed widgets available out there (a partial list is here: http://allwebco-templates.com/support/S_script_newsfeed.htm), They all require insertion of complex code into the html page, while all the parameters are hard-coded into the generated code, which looks something like this:
insertedWidgetText = "<script id=\"scrnewsblock10795953\" type=\"text/javascript\">...script specific parameters go here...</script>"
let feedWidget = toWidgetBody [hamlet|#{preEscapedText insertedWidgetText}|]
This doesn't integrate well with Yesod's approach as it requires specifying to Hamlet that the content is preEscapedText, which in turn disables the ability to use Hamlet's processing to alter parameters of the widget dynamically (So in case I want the widget to use a different source, for example, I need to statically change the quoted text and cannot use Hamlet's variable substitution).
Of course I could do some text manipulation myself, tailor built for the widget I'm using, but that doesn't seem like the "right" solution (especially if I want to have the embedded text in some external file and not in the middle of my code as in the example above).
Can the above mentioned issue have a better solution than the one I thought about?
Is there an implementation of a news-feed widget in Haskell/Yesod that I can use as a plugin?
Note: I'm a very poor javascript programmer, but solutions in that direction are also welcomed.
Thanks,

Resources