Re: Include Bootstrap Files in Perl Script?
by NetWallah (Canon) on May 10, 2016 at 17:07 UTC
|
print <<"__HEAD__";
Content-Type: text/html
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1
+">
<!-- The above 3 meta tags *must* come first in the head; any othe
+r head content must come *after* these tags -->
<title>MY Program's title</title>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery-2.0.0.js"></script>
<!-- Bootstrap V 3.3 CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstr
+ap/3.3.6/css/bootstrap.min.css"
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhj
+VME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstr
+ap/3.3.6/css/bootstrap-theme.min.css" integrity=
"sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0
+En5r" crossorigin="anonymous">
<!-- Bootstrap V 3.3 JavaScript (Minified)-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/boot
+strap.min.js" integrity=
"sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9a
+J7xS" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tableso
+rter/2.25.1/js/jquery.tablesorter.combined.min.js">
</script>
<style>
...
__HEAD__
If you /msg me with your email, I can share a simple perl Bootstrap module that I wrote to help make buttons, dropdowns, alerts and panels. It does not do forms.
This is not an optical illusion, it just looks like one.
| [reply] [d/l] |
|
++ While I also tend to use CDNs it’s important to note some things: 1) it puts you at the mercy of someone else’s outages and it’s possibly a remote network so it shouldn’t be part of anything meant to be bulletproof or things like bundled webapps that might run in a VPN or intranet with no external access, 2) use Google’s, not jQuery’s or others unless it’s all there is (Google is more reliable, faster, and more likely to be in someone’s cache already), and 3) schemeless URIs are a best practice; so I say. :P
| [reply] |
|
Thanks Much NetWallah,
Forgive me for this but is the code you showed in your example in perl? I'm a programmer but mostly on .NET client side and don't understand perl much at all.
Would it be possible to show me complete .PL perl script showing the Bootstrap includes with the a simple button using the Bootstrap class in a form like below that I could run on my server to get a feel for perl using Bootstrap...
<form>
<input class="btn btn-default" type="submit" value="Order Product" nam
+e="submit">
</form>
I would greatly appreciate it. Thanks, Glenn
| [reply] [d/l] |
|
You don't need to do anything special in Perl to include these files. Somewhere in your script it outputs HTML - it may also generate that HTML itself or read it in from an external file or template. What you need to do is find that place in your script and then insert the lines as shown by NetWallah into the output HTML. It could just be copy and paste - no Perl required.
| [reply] |
|
Hi Glenn,
Your question is pretty vague. Think about how you would form the question using C# or whichever .NET language you're used to. A better question would be, I have an old Perl script that uses CGI.pm that I need to update to add the following to the output but here is the (sanitized version) script I need to update simplified:
Your code would go here. Preferably it would be code that would execute but code snippets can also be used
Perl is the uber-tool of doing just about anything. There are many many ways of doing something. How to add those css and javascript to your code will depend on what your code looks like, what modules, if any, are being used and whether it uses a template system.
While we would love to help you, you have to help us help you :)
| [reply] [d/l] |
|
|
|
The only "perl" in the code I posted is the "print" statement - the remaining 99% is HTML, and shows how you can incorporate external CDN references to the jquery, bootstrap and tablesorter components.
It would not be practical to post the 5k line complete script from whence that snippet came.
Even if I did, it would raise a lot more questions than it answers - it is a hairy mess mixing up HTML, javascript and perl.
Today, I would not write a mess like that. So I certainly would not want it used as a sample to generate more such monstrosities.
To get familiar with Bootstrap, you need to work with plain HTML, javascript, jquery and bootstrap.
Only after you get your head around these, should you approach building your own monstrosity, or messing with someone elses.
I suggest you follow the advice posted belo this comment, and seek external assistance in getting your project into this decade.
Good luck.
This is not an optical illusion, it just looks like one.
| [reply] |
Re: Include Bootstrap Files in Perl Script?
by hippo (Bishop) on May 10, 2016 at 16:25 UTC
|
Only the HTML needs amending, does it not? This hardly seems like a perl task (in the absence of any posted code suggesting the contrary).
| [reply] |
Re: Include Bootstrap Files in Perl Script?
by jellisii2 (Hermit) on May 10, 2016 at 16:11 UTC
|
| [reply] |