Add stylesheets to rails static HTML page - html

I have a few static HTML pages in my rails project. They need access to stylesheets in my vendor assets folder. How can I add the proper references since they do not use the same application layout? I attempted adding a reference to the sheets directly in the vendor folder. This works during development but fails on deploy since the assets are compiled and the individual sheets no longer exists.

You should put all your HTML pages (static or not) in view folder if you want to use assets pipeline.
Don't forget that assets are dynamically generated, compressed and named so there is no way you can include them manually (without painful hacks).
Another solution is to put your stylesheets in /public folder together with your static HTML.

Related

Correct path for linking a style sheet inside MVC

I have a website I built inside atom text editor. I am trying to build the website again in an ASP.NET environment. I am using the MODEL VIEW CONTROLLER design pattern. I have placed some simple styling inside my css file but I don't think my path is correct. I am including a screenshot of my link tag and my codebase/directory. Any help is much appreciated
Static files, such as HTML, CSS, images, and JavaScript, are assets an ASP.NET Core app serves directly to clients. Some configuration is required to enable serving of these files. The default directory for these files is wwwroot.You should put the css file under this directory. You can also take a look at the Static files Docs if you want to change the default directory for your static files.
Once you put the content folder inside the wwwroot directory. You can use the following code in your view to refer it.
<link rel="stylesheet" href="~/Content/StyleSheet.css" />
Hope it helps.

Jekyll copy a folder to another folder at build time

I have multiple language versions of my website from the root folder as
en-ca/*
fr-ca/*
en-us/*
etc.
I have created a _resources folder that contains css common to all sites.
I would like to copy the content of the _resources folder into en-ca/*, fr-ca/*, en-us/*, etc. at build time.
Hmmmm.... Are you sure you want to do that? That doesn't seem like a good idea.
If the CSS is identical across the different languages, why would you make the end-users download the same file again when switching to a different language, if they already have the same file cached in their browser?
It would be better to have the common CSS in a single place, and have your HTML templates reference that instead, and leverage the browser cache, etc.
Anyway, to answer your question, if you want to use pure Jekyll (without a plugin), you can create empty common.css files inside each language folder, and use the tag include_relative to copy the contents of the common.css to it.
Jekyll Includes / include_relative
https://jekyllrb.com/docs/includes/#including-files-relative-to-another-file
Alternatively, you can write a plugin that copies the file to the folders you want. In the answer below there's a small example of a plugin that renames files... You can adapt it to copy files instead:
https://stackoverflow.com/a/48600246/211672

How to load static mediawiki content from a CDN?

I'd like to load all the MedaiWiki static resources from a Content Delivery Network (CDN) for obvious reasons (using MW 1.17.0).
I think I need to set $wgStylePath=http://cdn.example.com/ Then put everything currently in my /skins/ directory into http://cdn.example.com/
(this appears to be suggested in this Stack Overflow question/answer: How can you change images src attributes in mediawiki to access a CDN? but it's not very clear
My concern is the .php files that are currently in the /skins/ directory...
My only thought is that I need to put all the sub-directories from /skins/ into the CDN, but not the .php files that are directly in /skins/
Maybe I'm going about this the wrong way... is there a better way to achieve what I'm trying to do? (I'd like all the theme related .js, .css and image files to load from the external CDN)
Thanks,
-Dan
There are two completely different paths here: the filesystem path through which the webserver accesses skin-related PHP files ($wgStyleDirectory) and the URL which will be placed in the HTML code and used by the browser to access css/js files ($wgStylePath). If you want to use a CDN, you set the latter to the CDN url and leave the former in peace.

Drupal site. How do I add custom js/css prettify.js/prettify.css for a drupal page?

I want to use custom css/js. I have moved these to the server. But the drupal page starts with a section. how do I add the custom css/js to my drupal site page. I have admin and just need to know what to do to get this included on the page. Please send exact steps as I am totally new to drupal. Thanks
"Custom CSS and JavaScript files" module allows to specify two folders, one for CSS and one for JS where the stylesheets and javascripts files are located respectively.
The module creates two sub-folders under your files folder:
files/customcssjs/css
files/customcssjs/js
Indeed, it's depend on your task, what css and js files should do, and adding these in custom module (drupal_add_js, drupal_add_css) or custom theme (info file, preprocess in template.php or directly in page-XXX.tpl.php and so on).

Rewriting URLs with XDV

We are using static HTML files as theme for our Plone 4 site with collective.xdv.
The static HTML files themselves are openable in a web browser making the theming process easy for the theme authors.
However, theme files use a file system resource directores which are referred in HTML like
<link rel="stylesheet" type="text/css" href="../css/jquery/accordion.css"/>
How it could be possible to rewrite these to be absolute URL when served through Plone, with a custom prefix? (Can it be done in rules.xml??
E.g. translate
../images/logo.gif
To
http://portal_url/images/logo.gif
If you use the "absolute_prefix" setting
<registry>
<record interface="collective.xdv.interfaces.ITransformSettings" field="absolute_prefix">
<value>/++resource++example.sitetheme</value>
</record>
</registry>
and manage your static files via the resource registries with the "applyPrefix=True" option you can use both relative and absolute urls inside your theme html file (preserving the possibility for theme authors to simply use the static directory independent from Plone) and use
<drop theme="/html/head/style" />
<append theme="/html/head" content="/html/head/style " />
to remove them from the theme template and pull all static resources back in from the resource registries (with the additional benefit of having them merged for production use). See collective.xdv for details.
Note: though Nginx is very fast at serving static files we got better overall performance from utilizing the resource registries for our theme`s static files in combination with the usual caching proxy (Varnish) in front.
Register the static directory as a resource. Keep the directories containing the rules and the media files separate.
To register a resource directory inside your package, named 'my.package', use the following in your configure.zcml
<browser:resourceDirectory
name="my.package.media"
directory="static"
/>
In your template, you will now be able to access a resource using '++resource++my.package.media/name-of-resource', i.e.
<link rel="stylesheet" type="text/css" href="++resource++my.package.media/css/jquery/accordion.css"/>
This should now work as intended even after a url rewrite.
Avoid using absolute paths when defining the locations of your XDV rules and templates. Instead, simply use Python :) For example, we have placed our template files (.html) and our rules files (.xml) in a directory called xdvstuff, inside our package:
python://my.package/xdvstuff/theme.html
python://my.package/xdvstuff/theme.xml