photoswipe: passing HTML file instead of image - photoswipe

I would like to use the same set up as Photoswipe, only pass a div or index.html through instead of an image.
Here is the link to the photoswipe package:
http://www.photoswipe.com
Please let me know if this isn't possible! Thank you!

Since you use get method to load more images you can get html instead of images.
Just you need to print html as you require in your ajax request. And then you can display the html by using javascript i.e when you get html in your data variable.

Related

Posting to a web form and catching results from JavaScript code

How would I go about achieving the following
I have some HTML data triggered from an Evernote new note action
I need to pass this HTML string to a website via an http post with form variables
I then need to catch the resulting web page text in a variable to use in my next action.
For clarity the website simply takes some HTML and converts it to markdown passing it back out as the body of the resulting page
Regards in advance
Dan
Sweet! So I've got this working. In my example, text is some html I pulled out of a dummy previous step:
The output is:
Which has the markdown as a key. If you want to tweak other data based on the api params, you can do that as GET params below html
​Let me know if you've got any other questions!

Mercury Editor save images

I used Mercury Editor for my Rails 3 website, but i have a litte problem with the uploaded images.
I have a image tag with data-mercury="image":
<img id="page_image" data-mercury="image" >
Then I set Mercury to send the data via a form to my controller. What I want to do is to store the image's url in the database.
How do I get the data sent by Mercury Editor ?
Normally when I have a div with data-mercury="full", I get the content in my controller like that:
params[:content][:page_content][:value]
Thanks for your help.
as I check the mercury demo , it saved the pictures url. So ,probably you can parse the content and capture the image url by using regular expression. Maybe you can use nokogiri as well to parse the html.
Rails Cast Source
Official Mercury docmentation
I resoved the problem with the following code:
#body
<img id="mercury_image" data-mercury="image" src="">
<div id="article_image" data-mercury="full"></div>
#jQuery
$(function() {
$('#article_image').hide() ;
$("#mercury_image").load(function(){
$('#article_image').html($('#mercury_image').attr('src'));
});
});

Print web page with original look

I want to achieve print functionality such that user can print out the web form and use it as paper form for the same purpose. Of course I do not need all the web page header and footer to be printed, just content of a div which take most of the page. I did play around with media print css and menage print result to look almost as original page. But the I tried to print it in another browser(Chrome) and it is all messed. (before I tried Mozilla).
For the web form I user css framework Twitter Bootstrap and I had to override its css (in print media) for almost each element individually to get some normal look in the print result.
My question is is there some way (framework/plugin) to print just what you see on the page, maybe as an image or something?
Any other suggestions are welcome.
Thanks.
If you are familiar with PHP you can try the PHP class files of TCPDF or those of FPDF.
Or there is also dompdf which renders HTML to PDF, but this will include more than just the information of one div.
And for further info here is a post on Stack where users are discussing which they think is best.

Embedded HTML code being displayed rather than HTML being rendered

I am trying to use the calendar gem in my project (https://github.com/elevation/event_calendar). But when I open the calendar page, it renders the page by showing the html code of the calendar rather than rendering the html. Basically the source for the page generate is like
<div class="ec-calendar">
instead of
.
Can anyone let me know what is going on and how to resolve it.
I assume you are using Rails 3? As a security measure against XSS (Cross Site Scripting), Rails 3 renders html inside of strings as text. If you know the html in your string is safe, call html_safe on it, like
'<div class="ec-calendar">'.html_safe
or
raw '<div class="ec-calendar">'
html_safe I believe, is preferred over raw. Not sure what's different behind the scenes, if anything.

Capture HTML output from the view in RAILS and save to DB

Is there a way to capture the output of my view file after it is rendered?
I basically want to save the full HTML output into a database after the page renders.
You could use render_to_string, then stick it in the db and send the string containing the rendering to the browser. See RoR render_to_string doc.
What I ended up using is the following:
after_filter :save_if_necessary
and what I stored was
self.response.body

Resources