Meteor Images, CSS, "Normal" Web Serving - image

I've seen this question come up a lot;
How do I put images on my Meteor website?
How do I host "standard" web content with Meteor?
I tried adding a <img src="img/myimage.png"> tag but no image shows!
How can I host some files on a Meteor site?

Put the content in a folder named "public" in your project root.
You do not need to include /public in your URLs.
Any additional folder structure within public is supported.
NodeJS routing plugins are not required, as other answers have supplied.
Place external library's javascript files in /lib. They will be automatically included.
Explanation
In Meteor, you can host "standard" web content by creating a "public" directory in the root of your project. Any images, files, or data you place in this folder will be served as normal by the NodeJS server, as if they were in the root of the server.
Example
Structure within project: /public/test/img.png
Corresponding image URL: /test/img.png
Example HTML tag: <img src="/test/img.png"/>

Create a new folder public inside the project directory. Add a new folder img (or any other name of your choice) inside the public folder. Copy all the images that you require to be added in to your HTML into this folder.
Now you can use it like - <img src="img/myimage.png">
You don't need to include /public in the in the URL.

Related

No images on Nuxt static site after running npm run generate

I am working on a small nuxt website for a client, i havnt been using nuxt for very long but so far what i do is add target: "static" to the config when i'm ready to build for production, then send the dist folder to backend for deployment, but now i notice that after i run npm run generate images and others assets like js files do not get added to he page.. i have tried to create a new dummy project just to test, chose static mode when setting up the project, added 1 image to the project and display it in index page using
<img src="~/path-to-file" />
the image will appear normally in dev server, will also appear if project is hosted on netlify, but will not appear in git-pages or local apache server
i am confused on why this is happening, typically adding target static fixes issues like this but not this time, please help
There are two main ways to display images through nuxt. One via the assets folder, the other via the static folder.
Any images in the /assets folder will be bundled with webpack. These images can be referenced using:
<img src="~/assets/image.png"/>
If you do not want images to be bundled by webpack, then save them in the /static folder and reference using the following format:
<img src="/image.png"/>
Currently, you are using ~/ , which is shorthand to the base directory. Once you build your site for production this will no longer work, because the structure is transformed - which is why there is a discrepancy between your environments.

Laravel5: Where do I place a css file with only backend design classes?

I have a separate stylesheet (backend.css) for my admin backend css classes. Since clearly it shouldn't be in the public folder, where would be the appropriate location to store it?
Also, since HTML helper function:
{{ Html::style('css/stylesheet.css') }}
locates to only files in the public folder, how do I access it?
The "public" folder is called that way because it is accessible via HTTP. It does not refer to any specific part of your application (public or admin). So the "public" folder is the appropriate place for any files that have to be accessed directly via HTTP, like images, css and javascript files.

CodeIgniter: How to load css file that is WITHIN application folder

It appears that this question is asked often and answered the same way: store the css files outside of the application directory and then use base_url() . "path/to/file".
However, I want to keep my css files and js files inside my application/views/ directory, because the views directory is effectively the html space, and css and js belong to that space (in my opinion).
Below is the structure that I wish for:
root
- application
-- views
--- assets
---- css
---- js
- system
When I attempt to load css files from within this directory structure, I get a NetworkError: 403 Forbidden, which makes sense because of CI's framework protocol.
But I am guessing that there is a way.
Publicly reachable files like CSSes images and JS files need to be in public directory next to index.php file. So hierarchy would be:
root
- application
- system
- assets
-- css
-- js
You can aproach to those files with hard coded
Link
or using (loaded) url helper with it's function base_url() or site_url(). Don't forget to fill correct URL into application config file.
Link
Docs.
Hey i'm going to politely push back on this idea :-)
Your application and system folders should be ABOVE the root, so they are not publicly accessible. (Unless this is a really simple application and you are not doing any database interaction, etc). They should not be considered part of the HTML or public space because you do not want the public accessing them. Set the path for them once in the main index.php file and its done.
Also i suggest renaming your system and application folders, like "system302". Over the long term it makes versioning and upgrading (and reverting if needed) much easier.

how to build image service website with sails.js

I am using sails.js to build an image service website. There are lots of images need be shown on the webpage. And the website will allow users to upload images as well. If I put it all images under assets folder, they will be copied to .tmp/public everytime when i restart the sails server . it will be very slow. Does anyone have an idea where should i put .Should I write a route rule to handle this? thanks.
/assets are for your static contents (like css, frontendjs, ...).
If you have a lots of images you should place them in one folder of your server and write a route for showing it.
Or better: Use some Cloud-Hosting like amazonS3 or imageShack.
Example for middleware:
1.) create a file "express.js" in config/
2.) Put this code into the file and change to the right path (routing + your local folder):
module.exports.express = {
customMiddleware: function(app){
app.use('/images', require('../node_modules/sails/node_modules/express').static('/User/yourfolder'));
}
}

CodeIgniter How to create Multiple Site with One CMS

I want to create a blog site with only one CMS. This CMS will be in different domain.
For example: mycms.com
Then my blog sites are also in different domains.
For example: website1.com, website2.com, website3.com
They will all use mycms.com as their admin
*Images will be uploaded in mycms.com/images/ so all the 3 websites will get the images from this directory
If images are loaded on website1.com from the main database, they should be displayed as if they're from website1.com. So for example website1.com/images/cat.jpg instead of mycms.com/images/cat.jpg
How will I build this using codeigniter?
You can use the same CodeIgniter /System and /Application folders for all the websites if you like; just make sure all the index.php files are setup to use those same folders for $system_path and $application_folder respectively. Note that these sites also need to reside on the same server.
You can serve up different content by checking $_SERVER['HTTP_HOST'] for the domain the request came from.
As for htaccess you should be able to use %{HTTP_HOST}/$1 or %{HTTP_HOST}$1 (depending on server config) to make the rewrite rule dynamic.
I am actually building a similar project right now using CodeIgniter but there are also several other projects available like halogy, codefight, pyro (with an extension), and many others.
CodeIgniter has a System and an Application folder. You could have one global system folder and then one application folder for each of your subdomains, or you could have one application folder and just make your subdomian folders parallel with your www folder.

Resources