How can I parse a string to HTML in confluence? - confluence

I need to add some html code that is generated by a function through a browser page.
Basically I have the following function:
http://www.example.com/?.convert.HTML[]
that returns the following HTML code:
"<table><tbody><tr><th>functionView</th><th>cnt</th><th>lastRun</th><th>testVenue</th><th>status</th></tr><tr><td>venue_team</td><td>200</td><td>2020.04.03D10:29:33.998438000</td><td>venue_name</td><td style = \"color:#00b300; background-color: #ccffcc;\">PASS</td></tr><tr><td>venue_team</td><td>200</td><td>2020.04.03D10:29:33.998438000</td><td>venue_name</td><td style = \"color:#00b300; background-color: #ccffcc;\">PASS</td></tr></tbody></table>"
I need this to be parse in a HTML table in confluence.

Depending on your requirements, this can either be somewhat easy, or quite difficult.
The easy way to do it, it to create a user macro, that calls the function and inserts it via javascript into a div. This will lead to the page populating after load.
If you need to have it in the actual page source (statically), I'd suggest that you run a job to query the data and change the existing page using the REST api. Which will take more development effort.

Related

How to add dynamic Facebook meta tags in GAE/GWT application

I've seen some techniques for doing this with other platforms but wonder if anyone has a clean way to do this.
My app has a single host HTML file and uses standard MVP/Places/Activities to parse a hash fragment. It displays a variety of like buttons for different elements. FB (confirmed using lint tool) will only read the static HTML of the host page so I need to manipulate that before it is returned to the requester (there is no point in messing around in GWT with this problem).
I use the Guice-y com.google.inject.servlet.ServletModule so I could create something like:
serve("/fb/*").with(MetaTagAdder.class);
And I could use /fb/* for the Like button urls. So spew out the HTML of the hosting page (adding in dynamic meta tags as needed). Then the *.nocache.js files just jump into the EntryPoint.OnModuleLoad().
This seems sort of clunky. Anyone have a more better idea?
So I ended up going this way and it works fine. Create a servlet whose doPost/doGet methods write out your host html and pass the parameters into it. So the url looks something like:
http://example.com/fb/mypage.html?foo=baz#place:foo=baz
Then you have the parameters available to create meta tags and so forth:
// the first chunk of the static html
resp.getWriter().println("<html><head><script type=\"text/javascript\" language=\"javascript\" src=\"/myMoodule/myModule.nocache.js\"></script>");
// the dynamic meta tags
resp.getWriter().println("<meta property=\"og:title\" content=\"" + req.getParameter("foo") + "\" />");
// the rest of the static html
resp.getWriter().println("</head><body></body></html>");
Then when you are setting up the data-href attribute on your fb-like div, use the url above. Also works for SEO. Considerations for production systems:
Navigation elements in the site should drive the user back to the straight hosted version. This can be tricky. Understand that you will have the query strings in the HTTP request remaining static while the hash fragment evolves to react to the user.
If you have a limited range of parameters and do processing on the parameters, use memcache in the HttpServlet to cache semi-static copies of the html returned to clients.
Don't be putting stuff in the body trying to get jazzy with your SEO. Heartache lies in that direction.
I'm still fooling around with tuning this but don't see any drop dead show stoppers at this point.

HTML in UIWebView

I have created HTML code that creates a layout for information that my iPhone app gathers from the user. I would like to be able to take the html string and place the right values in the right location, but cannot think of a good way to accomplish this.
Example.
<html>
<body>Name:</body>
</html>
And I am wanting to put "Eric" after "Name:".
Because my html file is much larger than this I am just trying to think of the most efficient way to basically add NSStrings into my long html NSString...
Thanks,
Eric
You can do: NSString *html = [NSString stringWithFormat:#"<html><body>Name: %#</body></html>", #"Eric"];
While unknown about it's efficiency, you can use UIWebview's stringByEvaluatingJavaScriptFromString to execute javascript to replace values inside your HTML page using javascript.
There are two ways to do this:
Dynamically create the javascript method, then invoke it
Invoke a statically created javascript method that is already part of your html file.
You should be able to invoke jQuery, in which case it would be painfully easy to modify the dom.
Check out this link for an example of js injection.
http://iphoneincubator.com/blog/windows-views/how-to-inject-javascript-functions-into-a-uiwebview

gwt; mixing html pages with java code

I really like the approach in GWT where you can define "divs", "spans" etc in a regular html page, then in the GWT entry point simply push a button or some other component inside the div.
So small example, here is a snippet of a gwt html page:
<body class='page'>
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position: absolute; width: 0; height: 0; border: 0"></iframe>
<div>
Query Terms: <span id="txtQuery"></span>
<span id="btnQuery"></span><br>
...
</div>
</body>
And here is a small java snippet contained in the gwt entry point:
ClickHandler clickHandler = ...
TextBox txtQuery = new TextBox();
Button btnQuery = new Button("Query", clickHandler);
RootPanel.get("txtQuery").add(txtQuery);
RootPanel.get("btnQuery").add(btnQuery);
One of the reasons I like this approach is that it allows non java coders to design / write the html stuff, and I also like the separation between GWT / java code and the html code.
However... this may work well for a simple web page, but how do you scale this approach up into many webpages? From what I understand, the "GWT way" of doing things is to have one webpage and use history to hide and show various GWT components. I have built 2 projects in GWT using this standard technique, but recently discovered that you can do the sort of thing I showed above.
Is there any way of scaling the above 2 snippets into multiple html pages, where GWT injects its components into standard html pages?
here is no GWT way. At least not in GWT mission statement. If you want to pursue your aproach there are multiple ways how you can do it.
GWT app per page. (e.g. on each page a gwt app specific for this page is included). You simply compile a new GWT module for each page where you need some GWT functionality. You can use few of them together on one page, or none. This approach is good if you GWT apps are going to be really simple, and you don't need to use stuff like GXT Grid on every single page with different settings, otherwise you will waste user browser will have to download large chunks of JS code over and over, and this will be a big problem if you have a lot of pages.
One big GWT app for all pages. Just put everything into single GWT app, create some kind of switch (some js variable) so the app knows what it has to create. Some code splitting might be used, so on each page only things which are really required will be downloaded. Since the same JS will be used on each page, caching should solve the problem with downloading application code over and over (but you still have the problem with actually parsing/running the code very time user changes the page)
There is also a third approach, the most effective of all, but the hardest as well. As soon as the user loads one of the pages, there is no more navigation, gwt module simply takes template for page to which user wants to navigate, and replaces current html code with newly generated template. This is quite easy to achieve, if you will use TextResource from ClientBundle and HTMLPanel. The problem is with navigation in address field (GWT app will have to be responsible for changing the address, so the users can create bookmarks or send the link to their friends). You will use one single GWT script for this and some code splitting is recommended.
All three approaches are totally valid, depending on your requirements you can pick any of them. Also if all you want is to provide people ability to use HTML to layout GWT screens, you might want consider using combination of HtmlPanel and ClientBundle's TextResource.
If the goal is to have designers work on HTML rather than Java, then how about UiBinder? It'd give you what you want (separate HTML –or rather, XHTML-like– code from Java code) inside a GWT project.

Node/Express/Mongo: How do I render HTML attributes from dynamic content?

I have made a simple blog using Node/Express/Mongo/Jade (and/or HAML.js). I used (and slightly updated) the blog app from this tutorial, which itself an update of one from howtonode.org
I can render attributes such as links, etc., with the template engine just fine, but when I pass data from the db, none of the html renders. I get plain text print-outs of the HTML. I figure I need some other node packages/modules to render the 'dynamic' content, but I don't know where to start.
In jade, when you're passing content you DON'T want to be escaped, be sure you pass it along as != instead of =
BE EXTREMELY CAREFUL THOUGH! If you don't manually parse out the bad stuff, you could make your website extremely vulnerable.
You can read some more jade documentation here

Why do we use HTML helper in ASP.NET MVC?

Are there any good thing, best practice or profit we have after using the HTML helper in an ASP.NET MVC project?
When I am trying to use them I found that I lose the speed I have with HTML and many difficulties I have whenever I use an HTML helper.
Other [non-techie] persons can't understand what I write using Helper if I want to show them or they want to do something they need to spent more time on, even if they have working knowledge of HTML.
If I use an HTML helper I lose the speed. When I use HTML I just type and of course I am not aware of it. But using helper, it is hard to understand.
What thing do we get when I use HTML helper? I think it is nothing I get because I lose the speeed. Others can't understand what I do using helper and can't customize the code if they want.
Why do we use HTML helpers?
You use HTML helpers to encapsulate some small HTML fragments which are repeated all over your pages. And to avoid writing those HTML snippets all over again you use helpers.
They are very useful, especially when dealing with things like URLs because instead of hardcoding your links helpers take advantage of routing the definition on your server and by simply changing those routes the whole site URLs' change without ever touching any single HTML page.
Another scenario where HTML helpers are useful is for generating form input fields. In this case they automatically could handle values when posting back and show associated validation messages. Can you imagine the spaghetti code you would have to write in your views if there weren't HTML helpers?
The biggest advantage I find is with the editor and display templates.
If your editor for a field is more than just a simple input box, you can put that into a template and replace the several tags with a call to
<%:Html.EditorFor(m=>m.Property)%>
This means that your page is a lot easier to edit as you aren't wading through a lot of fluff HTML to find what you want.