Hey guys, I'm currently making a web app in Mojolicious, but cannot figure out why the css stylesheets and js files I'm linking are not showing up. I've put them in the public directory in the same directory as my application.


This is the default layout I'm using:


<!doctype html><html> <head> <title>Main title</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11. +1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="/programcss.css"> <script type="text/javascript" src="listCollapse.js"></script> </head> <body><%== content %></body> </html>

I've tried all sorts of combinations of pathways to link to the files, but nothing seems to be working. I'm using Windows 7, and testing it in Chrome if that helps.


Here is the code for the app itself:


#!/usr/bin/env perl use Mojolicious::Lite; use File::Slurp; use Data::Dump qw(dump); use lib 'lib'; use webprogramsubs; # Documentation browser under "/perldoc" plugin 'PODRenderer'; get '/' => sub { my $c = shift; $c->render('contents'); }; app->start; __DATA__ @@ contents.html.ep <html> % layout 'default'; <body> <h1>a heading</h1> </body> </html>

Any advice would be much appreciated!


In reply to Mojolicious - linking external css/js not working. by desertcrocodile

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.