django Download Link(filefield) - django

i am trying to create a Software download website, and each software has some file and download link (mac,windows,linux,..).
Can anyone tell me how to use 'filefield' for download links(not one).
(Sorry, my English is so weak).

You just need to put download attribute in the anchor tag . and the anchor tag will allow the user to get the file from the href location. A small example is give below
<a download href="/media/{{friend.picture}}"><img height="100%" width="100%" class="img-fluid d-block mx-auto" src="/media/{{friend.picture}}"></a>

Related

How can I make gifs show up on Github Pages posts?

I've found that I can make a gif show up on the README.md page like so:
![gif](https://github.com/jss367/antools/blob/gh-pages-2.3.4/assets/images/cat.gif)
or like so:
<img src='https://github.com/jss367/antools/blob/gh-pages-2.3.4/assets/images/cat.gif' />
However, those same lines of code don't work when I add them to a blog post. Do I need to add something to the layout? Or is it turned off in Github Pages?
I've found that they show up on the blog post when the gif is hosted on gifs.com but not when hosted on Github. For example, this works:
<iframe src='//gifs.com/embed/k8A5jN' frameborder='0' scrolling='no' width='1280px' height='720px' style='-webkit-backface-visibility: hidden;-webkit-transform: scale(1);' ></iframe>
but this doesn't:
<iframe src='https://github.com/jss367/antools/blob/gh-pages-2.3.4/assets/images/cat.gif' frameborder='0' scrolling='no' width='1280px' height='720px' style='-webkit-backface-visibility: hidden;-webkit-transform: scale(1);' ></iframe>
I'd like to host it directly on github.com.
Your link goes to a webpage. Use a direct link or proper directory
Try this:
<img src='https://github.com/jss367/antools/blob/gh-pages-2.3.4/assets/images/cat.gif?raw=true' />

Add Facebook share button to Django application

I am using Facebook's share button on my Django app.
I'm using Facebook's SKD instructions which tell me to place this code wherever you want the plugin to appear on your page:
<div class="fb-share-button"
data-href="https://my-website-full-url"
data-layout="button" data-size="small" data-mobile-iframe="false">
<a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&src=sdkpreparse">Share
</a>
</div>
So I placed that code in my template but how do I add the full URL of the web page with the FB share button in the data-href attribute?
As long as you have django.template.context_processors.request enabled you should be able to use request.build_absolute_uri() in your template:
data-href="{{ request.build_absolute_uri }}"
This should work out of the box if you're using a fairly recent version of Django.

display static html asset in jekyll + github pages

I want to add a link to a static html page (which I have created, not hosted anywhere). I added the html file to my images folder (contains the images which are being rendered in my jekyll blog). Then I make a hyperlink to the html files which I just added in the images folder, like this:
<a href=https://raw.githubusercontent.com/USERNAME/USERNAME.github.io/master/images/time.vs.score.html>View plots here</a>
Where username is my github username. This does not open a new html page, instead I just see the plain text of the html file. How can I add static html files are part of the assets? Thanks!
Thats what raw.githubusercontent.com is made returning raw file.Files are returned with Content-Type:text/plain; and then displayed as text by your browser.
You'd better link to github pages published content at https://USERNAME.github.io/images/time.vs.score.html
I found an easy solution using this tool: https://rawgit.com/
just replace:
<a href=https://raw.githubusercontent.com/USERNAME/USERNAME.github.io/master/images/time.vs.score.html>View plots here</a>
with:
<a href=https://cdn.rawgit.com/USERNAME/USERNAME.github.io/master/images/time.vs.score.html>View plots here</a>

Generate PDF based on Particular Div id in Rails

Is there a way to generate pdf in rails based on div id.
Sample code:
<div id="pdf_download">
<h1>Hello Welcome to PDF
</div>
<div id="seconf_pdf">
<h2>Second PDF</h2>
</div>
Now i want to download only the div id "pdf_download" as pdf, Is it possible? Can anyone explain how to achieve it?
There seems to be a gem that does that - wicked_pdf. Internally it seems to depend on wkhtmltopdf, so you should be able to install this on your production environment.

Regex help for Page monitor

I want to check for the particular text below in a webpage
<img class="highlights" src="http://www.carsportal.com/images/highlights/green.jpg">
Using this regex for doing so,
<img class="highlights" src="[^]*green.jpg">
I am trying to monitoring the changes on this webpage using Page Monitor(Chrome extension). I tested it here.
But its not working on this extension.
Somethings like this:
<img class="highlights" src="[^\"]*green\.jpg">