QR Code Generator in Rails [closed] - ruby-on-rails

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am looking for help to implement a QR Code generator on my site. The site is built in Ruby on Rails. I have tried to use rqrcode but could not seem to get it to work. I would like to use the google chart API.
OVERVIEW:
A simple QR code generator. In the view, a user can pass in a string, the string is then stored, and then sent to the QR code generator script, at this point the resulting QR Code image should be displayed back to the user.

Just released a gem that makes this very easy if you're using rails 3.
Follow the installation documentation at:
https://github.com/samvincent/rqrcode-rails3

See: http://code.google.com/apis/chart/infographics/docs/qr_codes.html.
QR codes are a popular type of two-dimensional barcode. They are also known as hardlinks or physical world hyperlinks. QR Codes store up to 4,296 alphanumeric characters of arbitrary text. This text can be anything, for example URL, contact information, a telephone number, even a poem! QR codes can be read by an optical device with the appropriate software. Such devices range from dedicated QR code readers to mobile phones...

I've both used google and the gem.
define #url in controller. Use google API.
<img src=<%="https://chart.googleapis.com/chart?chs=545x545&cht=qr&chl=#{#url}&choe=UTF-8"%> alt="QR code">
If for some reason you want to have a gem do it on your server the following is good.
gem 'rqrcode'
#qr = RQRCode::QRCode.new( #url, :size => 7, :level => :h )
## Your VIEW
<div id="qr">
<style type="text/css">
#qr table {
border-width: 0;
border-style: none;
border-color: #0000ff;
border-collapse: collapse;
}
#qr td {
border-left: solid 10px #000;
padding: 0;
margin: 0;
width: 0px;
height: 10px;
}
#qr td.black { border-color: #000; }
#qr td.white { border-color: #fff; }
</style>
<%= raw #qr.as_html %>
</div>

Related

My Website Does Not Seem to Want to Print Anything

I have developed a website and am in the process of converting most of the tables over to DataTables. In testing out one of the DataTable features the Print button, I discovered that nothing would print except the Title of the web page. At first I thought it was an issue with DataTables, but after playing around I've discovered that none of my pages seem to want to print. I'm testing with Chrome because it has the Print Preview, but I can right-click on any page in my site and select Print... and I get the same behavior -- only the Title of the web page displays. Has anybody experienced anything like this before? Here's a link to my site:
JCPS DMC
Even on the home page, try right clicking and select Print and you'll see what I mean. Please tell me this is some super-easy that I just don't know about -- some setting that I've overlooked. I will be happy to provide any support information you need, but I don't even know what that would be... :(
Well this is embarrassing...apparently at some point I included a css script in my Master page (the site is developed using asp.net). In the css I had this little gem which was blocking anything from being printed:
#media print {
body
{
visibility: hidden;
border-top: hidden;
width: 50%;
}
.noPrint
{
display: none !important;
}
ol
{
display: none;
}
.printSection, .printSection *
{
visibility: visible;
margin: 1px;
padding: 1px;
}
.printSection
{
position: relative;
left: 0;
top: 0;
}
}
Not even sure why I put that in there, but I removed it and everything is working peachy now...

Display background image in Neo4j browser

Some nodes in my graph database have a property which contain a URL to an image. I wanted to use Neo4j browser's style sheet functionality to display that image as the background image of a node.
My .grass file looks like this:
node {
diameter: 40px;
color: #DFE1E3;
border-color: #D4D6D7;
border-width: 2px;
text-color-internal: #000000;
caption: '{name}';
font-size: 10px;
background-color: #00aaee;
}
node.Actor {
color: #AD62CE;
border-color: #9453B1;
text-color-internal: #FFFFFF;
background-image: url('{image}');
}
After I uploaded the file, the line background-image: url('{image}'); gets converted to background-image: url({image}); (missing apostrophes). No image is shown in the browser.
What am I doing wrong?
You're not doing anything wrong.
The feature is not supported in the Neo4j browser. Other visualization solutions do exist. Unfortunately the ones that use this feature out of the box are not open source and may require a commercial license.
Of these solutions are:
http://linkurio.us/
https://www.tomsawyer.com/products/visualization/index.php
http://www.keylines.com/
As #Kenny Bastani said most of the libraries that implement this feature have a commercial license.
For a full list of the supported ones have a look to the official Neo4J visualize page.

How to strip HTML tags including escaped image tags without ' and stuff?

I need to strip all the html elements from my content. Example of the content :
"<p><img alt=\"\" src=\"/ckeditor_assets/pictures/1/content_twitter-sink.jpg\" style=\"width: 570px; height: 399px;\" /></p>\r\n\r\n<h3 style=\"font-size: 1.38462em; margin: 1em 0px 0px; font-weight: 600; line-height: 1.2; font-family: freight-sans-pro, sans-serif; -webkit-font-smoothing: antialiased; text-rendering: optimizelegibility; color: rgb(46, 46, 46);\">Soraya Calavassy, communications manager at the Award in Australia, shares her organisation's experience piloting our new global visual identity.</h3>\r\n\r\n<p style=\"margin: 0.5em 0px 0px; text-rendering: optimizelegibility; font-size: 1.30769em; line-height: 1.3; color: rgb(78, 78, 78); font-family: freight-sans-pro, sans-serif;\">"While Australia has a very strong brand locally, there are some great benefits for incorporating"
When displaying the post i use raw which does give me the output I need. But I need to generate an excerpt. For that, I need to strip all the HTML tags and even remove the images. But when I use sanitize it won't remove the images. If I use strip_tags , it will remove the images but it will add ' for apostrophe, for space, etc. So, how to get a clean excerpt without images and without stuff?
try strip_tags(text).html_safe
Doesn't work with rails 4.1
Only way by combing strip_tags with the gsub function (link below)
Ruby gsub multiple characters in string
So in helper, I'd do:
def format_text(string)
strip_tags(string).gsub(" ", "").gsub("'", "'")
end
I meet problem with such code
strip_tags("<p>a</p>\r\n") # => a
I use
sanitize("<p>a</p>", tags: [ ]) # => a\r\n
raw(strip_tags(text).html_safe) is actually what you want

How to display n characters of a string without counting the included formatting data

I am using CKEditor for my blogging app, and am saving formatting data in my :content attribute.
For example, a particular #post.content may start out like this.
<p>\r\n\t<span class=\"s1\" style=\"color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1.1em; line-height: 1.7em;\">This is my text starting here. This is an really awesome entry, you see...
The first part of the entry is all formatting data, and the actual written content starts with "This is my text starting here..."
What I would like to do is display the first fifty characters of the written content.
I tried something like this,
<%= post.content.first(50).try(:html_safe) %>
But this doesn't return anything, unless the formatting data is less than fifty characters.
How can I go about displaying the first fifty characters of written content?
Please let me know if this is unclear, or if any additional info is needed. Thanks much for your help!
try using strip_tags method
e.g.
<%= truncate(strip_tags(post.content), :length => 50, :omission => '..').html_safe %>
One way to do that would be to use Nokogiri to extract out the raw text.
require 'nokogiri'
text = Nokogiri::HTML(post.content).text.strip
The above would give you raw text on which you can use the truncate method to display the first 50 characters.

sIFR3 and line-height/leading

I've successfully implemented sIFR3 using the nightlies from the end of Oct. All is well and much easier to work with than sIFR2 except where it comes to line-height.
I was able to deal with my headings fine. But I have a pullquote that needs more line-height/leading and though I've read through support and see that it needs to be applied to the .sIFR-root, it's not working. Is there something funky I don't know about?
Here's my code:
sIFR.replace(fedraBook, {
selector: '.callout p',
css: '.sIFR-root { background-color: #FFFFFF; color: #968b85; leading: 3.5;}'
});
I had the leading at 1.5 but changed to 3.5 just to see if I could get it to vary at all. It does not.
I tried also affecting it with this CSS selector with no joy:
.sIFR-active .callout p {
font-size: 1.6em;
padding-top: 7px;
line-height: 2.5em;
}
Does anyone have any ideas here? What am I missing?
i know my answer is not of much help but I too have had this issue. there is very little documentation on the subject. as far as I know, sIFR does not support true line-height. It uses the height of the flash object and the font-size to set the line-height. http://tests.novemberborn.net/sifr3/experiments/tuning/line-height.html

Resources