How would I add this to response.files...or would I?

31 views
Skip to first unread message

Niels Jensen

unread,
Oct 4, 2014, 3:13:43 PM10/4/14
to web...@googlegroups.com
Hi Guys,

I'm trying to convert a html template for my first web2py app.  I'm pretty new to Python and very new to Web2py.  I've written a few Python scripts at work which hook into the API's of some of our services and pull back some useful data  Eventually I'd like to make this information available via Web2py but first I'm trying to understand the basics of how Web2py works.  I'm really enjoying the puzzle of figuring out how the pieces all fit together but I've come across an issue and either I'm not understanding the docs or I just can't find a reference on how to do what I'm looking for.

The template's <head> has a section in it with the following, I've converted a bunch of it already but the parts I really can't figure out are highlighted in yellow, any advice you could offer for the rest would also be much appreciated:

<head>
       
<meta charset="utf-8">
       
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

       
<meta name="description" content="">
       
<meta name="viewport" content="width=device-width">
       
<link rel='shortcut icon' type='image/x-icon' href='favicon.ico' />

       
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png">
       
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-72x72-precomposed.png">
       
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-114x114-precomposed.png">
       
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-144x144-precomposed.png">

        {{response.files.append("//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css")}}
        {{response.files.append(URL('static', 'css/normalize.min.css'))}}
        {{response.files.append(URL('static','css/main.css'))}}


       
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
       
<script>window.jQuery || document.write('<script src="{{=URL('static', 'js/vendor/jquery-1.10.1.min.js')}}"><\/script>')</script>
       
<!--original was below but I modified above to use {{URL}}:
        <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.1.min.js"><\/script>')</script>-->


        {{response.files.append(URL('static', 'js/vendor/jquery.hashchange.min.js'))}}
        {{response.files.append(URL('static', 'js/vendor/jquery.easytabs.min.js'))}}

        {{include 'web2py_ajax.html'}}
</head>

I've got a basic understanding of html and css and I'm quite ready to admit I have no idea what the jquery.min.js elements are even trying to do.  I read somewhere that it's essentially offering a CDN-hosted link for speed and if the link fails then it reverts to the local static version.  Can't quite figure out how yet, but I guess I'll get there if I keep hammering at it.

I've done some research and the rel=apple... links are all relating to iOS icons, but again, not sure how I should represent these in a web2py view, from what I understand the response.files is only used to reference static files ending with .js or.css.  So I'm thinking the apple bits referencing a .png wouldn't actually do anything?

So have I Web2pyified the head correctly, or do I need to do more?

Thanks in advance for any help you guys can offer
Niels
 

Reply all
Reply to author
Forward
0 new messages