How to hide content in jinja that is displaying on page before execution? - python-3.x

I'm using Flask and trying to create a form that user will fill and when user will hit on submit then the output render on the same page but I'm facing a problem that content of jinja is also displayed before execution in the following way.
Is there any possible way to hide those content or any other efficient method to render the content on the same page ?

Related

How to only get the "title" and "main content" of a page using puppeteer?

I'm trying to create a clone of getpocket.com for learning. On that app, every saved link gets converted into a markdown; and it seems like the it's a filtered content with only the page title and body without headers, footers, etc.
I could get the page's title using puppeteer api thru different means:
using page.title()
or get the page's opengraph "og:title"
But how do i get like the summarized version containing only the main content of the page.
Note that i don't know beforehand the "css class" of the main content since i'm planning on just entering a url in a textbox and scrape that site from there.
I have found what i've needed for this scenario.
I used the Readability.js library for making webpages readable by removing some certain html tags. Here's the library.
This library is what mozilla uses behind the scenes when rendering their reader view

Customized search on web and displaying result

On my lotus domino web application, I have customized search form where user can enter criteria (around 10 criteria ) is there, now what I would like to do is that I would like to throw the result to another page/form using html.
But my concern is that I would like to access div elements on the output form/page and I am not sure if I can do it Web query save agent of search form.
Basically what I wanted to do is I will compose html in the WQS agent and assign that HTML to div of the output search form. but I am not sure how to access div element of the another form using WQS agent of the current form.
I can display result in the same form but question would remain again how to access div element in the WQS agent of Lotusscript.
using document context we can access the field of the currrent document submitted but not sure about div element.
Please asssist
You could use some REST here. Basically submit the search form to a REST service, collect the results and render them as needed.
In short, all you can do in a WQS is to spit out a stream of text (which may or may not be HTML) from the server to the browser. So I think you have a couple of options:
In your template HTML, add a placeholder where your <div> is and do a replace() (replace the placeholder with the HTML you want to appear in that div) before sending out the HTML to the browser, or
Output enough JavaScript and/or JQuery and/or whatever so that the div is updated by the client after the document is loaded. Of course there's no guarantee that will happen though.
Another approach is just to create a Notes document with computed fields and/or computed text. In this case you don't think of updating the "div" as updating an HTML div, you're updating computed text on a Notes form. When you return the document to the browser as a document instead of messing with a WQS agent.
I suppose your WQS agent could also potentially send out just JavaScript to update another page, but to me that smacks of a cross-site scripting attack.

Rendering a user modified page using PhantomJS

My use case is: a user goes onto a webpage and modifies it by either filling in a form, populating the page with data from the database, or dragging around some draggables on the page. He can then download the page he modified as pdf. I was thinking of using PhantomJS to do the conversion from html to pdf.
I understand the basic functionality of PhantomJS and got the basic example working but in all the examples I've seen, either a local file or a url is passed in. Example:
page.open('./test.html', function () { ... }
How would I render the page that is getting modified by a user using PhantomJS? I have 2 ideas:
Have the url change as the user modifies the page, and simply pass in the url. For example, the url contains the position of a draggable div.
Send the modified html to back-end, save it, and run PhantomJS
Do these solutions make sense? I'm hoping there would be a simpler way.

Orchard - access a content type through different URLs so they use different views

I'm trying to create a CSS documentation library in Orchard. I want to save a description, CSS snippet and HTML snippet against each content type. The first view would show the description and CSS and HTML code written out. The second view would show a preview of what the CSS and HTML look like rendered.
cssdocumentation.com/content/item1
cssdocumentation.com/content/item1/live-preview
I've created the content type and the first view. But I'm not sure how to create the second view. I can see if I can create the alternative URL I can use the Url Alternates module to create an overriding .cshtml
To create an alternative URL I've looked at the autoroute module but this only allows you to adapt a single URL (unless I'm missing something?) and I've looked at Alias UI but this forces me to manually create an alternative URL everytime I create a content item.
Is this possible in Orchard without writting too much C#? (I'm a frontend developer so I only dabble in the behind the scenes stuff)
Thanks for any help
Best solution is to do this within your own module. But as a secondary option instead of having a second page, combine this content with your first page and hide it with CSS. When the user clicks a button to navigate to the next step render the CSS/HTML result on the same page. You can do this in many ways, here are a few ideas:
Render the CSS/HTML result out straight away on the same page but hide it. Show it when the user clicks a button
using jQuery to render the result on the client side. More dynamic if you allow editing of the HTML and CSS.
Redirecting the user to the same page with specific url parameters which you can pick up in your alternate to modify the output.

Preventing javascript running in a HREF

I have a problem with the following HTML:
<a href="javascript:document.formName.submit();" target="iframe">
Where formName is the name of a form inside the iframe. I would like the browser to navigate to the page "javascript:..." in the iframe, so it executes the javascript on the current page in the iframe. My problem is that the browser will attempt to execute the function and use the returned result as the url. Of course there is no form to submit on the current page, so I just get an error.
Cross domain iframes are no fly zones, you won't be able to do anything with or to the DOM inside of a frame on a different domain. Even if the user clicked the submit button inside the frame, your page would not be able to get the new url back out of the frame.
In this case, you can do it by reaching inside the iframe:
<a href="javascript:window.frames[N].contentDocument.FORMNAME.submit()">
(that may not be exactly the right incantation). In general, you should do this with an onclick handler for the hyperlink, that invokes a function defined by the iframe's document.
EDIT: There is NO WAY to make this work cross-domain. It's a violation of the browser's security policies.

Resources