Handlebars NodeJS/Koa Script/Src Reference - css

The answer is probably going to make me bang my head on the keyboard, but for the life of me I can't seem to figure out how to reference a template file so that I can load it from a handlebars view.
Let's say the view is 'ROOT/views/intro/home.html'. In it I want to reference an external CSS file called style.css.
Let's say that this external CSS file is located at 'ROOT/assets/css/style.css'.
How would I reference this file in the view in the <link ref=""></link> tag? I have tried everything from
'../../assets/css/style.css' to
'../assets/css/style.css' to
even appending localhost to the front and referencing
'localhost/assets/css/style.css'.
Thank you in advance!

Figured it out! For anyone else having this problem, you have to declare the static path for public files in the middleware, using something like koa-static and opening up that folder for access like:
_app.use(serve(__dirname + '/public/'));
Hope this saves someone a lot of time! It definitely was a trip trying to figure this one out.

Related

How can I get the full path to the file I saved my code in when it is currently executing and writing out HTML for me?

I tried to make my title as direct as humanly possible.
I wrote some code, saved it in a file. I want the name of that file, and the disk path to it, at the moment it runs. This is for a website, and I have access to HttpContext.
I wrote some code in a Razor file. I put that file on my IIS website, and it got executed by some convoluted hierarchy steps with partials and the like. I want to write some code that spits out the path to that file.
I don't want to hard-code the filename and its current path in my code. I want to copy the magic piece of code I'm asking for here onto lots of other Razor pages, so each time I can spit out a comment in some script or style tag somewhere so that other developers can track down my mistakes amazing work.
I don't want to know how the end-user's browser got to my file. I'd use Server.MapPath or Request.ServerVariables["SCRIPT_NAME"] if I wanted that.
I don't want to know merely what directory my website app is running in. I'd use HttpContext.Current.Request.PhysicalPath for that.
Does anybody know how to do this?

Wordpress: how to know which page is requesting a specific css file

I am helping out a friend with a slow WP. I installed hummingbird and it's telling me that some css files are slow to load (for example: https://cdnjs.cloudflare.com/ajax/libs/gsap/1.11.2/TweenMax.min.js - it takes 390ms to load). I would like to store this file locally and see if the performance improves. The problems is that I'm not sure about how to locate the file that is actually requesting this css file. Any help is appreciated.
I suggest a sweet plugin I use called String locator. It will search the whole site for a string like TweenMax.min.js. It will also search by plugin. When it find it it gives options to edit straight to the file. Hope this helps.

Meteor markdown editor with embedded images / files

I want to be able to insert a file or image into a post written in markdown. I have a decent idea of how to do this using collectionFS and inserting the appropriate markdown text, but I was hoping that someone else has done this in a convenient smart-package.
Do any of these do what you're looking for?
https://atmospherejs.com/?q=markdown
I'm with you. I want to know if there's already something out there.
I've ended up implementing something I need only to find out there's already a smart package in atmosphere that does it better too many times! lol
It's possible to reference images stored directly in your server. Place any images you want in the Public folder of your Meteor project. Even better Public/Images.
In your page, reference these images without the Public directory, e.g. <img src="/Images/pic1.png">

unable to use display suite template files

i use display suite to style my taxonomy page and it suggests me some template files but i am not able to use that file, i put them in place but they do not include,
do you know how it will works please ? or any references ?!
this is my display suite screen
and i place file ds-reset--node-article-article-ds.tpl.php into address sites/all/modules/contrib/ds/layouts/ds_reset
but not thing gana happen
(would be a comment if I could :) You're supposed to put your template file in /sites/all/themes/your_theme/templates/, not in the DS folder.

Changing image "source" dynamically in runtime

i am trying to modify during runtime an image in my application, this image is located inside assets folder, so thats why i dissable -use-network=false flag, then i call something like this:
img.source="../assets/pict.png";
but it's not working.
i know its a silly question but i am stuck here. any hint i appreciate.
Br
I don't think you need the ".." all of my images are in my "img" folder and I call them with "/img/image.png"

Resources