Assets in public folder not loading when browsing CRUD pages of a class in Sinatra - sinatra

I am using Bootstrap for some basic styling to a CRUD app in Sinatra. While the assets in the public folder load as usual on all pages, they don't load when I am browsing a particular record in my database.
For example, http://localhost:4567/songs loads all stylesheets and assets, but not http://localhost:4567/songs/1.
In my console, the page seems to be trying to find the css file in /songs folder, which I am not sure why its doing that.
http://localhost:4567/songs/bootstrap.css
Any help or pointers would be appreciated.
My main.rb file: http://pastie.org/8543319
My song.rb class file: http://pastie.org/8543312

Provide absolute path for assets in your views.

Related

Hugo deploy and delete not necessary files

I'm developing a new Hugo site and in this case I thought to create also a template so.I can use for future site.
Well in the template there are tons of vendor files and library because depending of the pages that the site will implement these library will be used. The problem is on the deploy. For example I use Line icons library that has a lot of .png files. (For example 200 files).
Well in the template I put all the files but could happen that in the site that implement this template I use only five icons. Is there a way that look around the final HTML and the usage of the icons and delete in the public folder the not necessary files?
Not directly.
You would need to add an utility script to your template, in order for any user implementing said template to be able to call this script on demand.
That script should then be able to:
analyze the HTML files generated in public_html
cleanup the icons accordingly

Not able to access image on jsp file

Attaches is the image of my project hierarchy. I am trying to call image from images directory to the jsp file in jsp directory but I am getting blank screen.
So far I have tried :
/WEB-INF/images/'<'imageFileName'>'
/images/'<'imageFileName'>'
/'<'imageFileName'>'
src/main/webapp/WEB-INF/images/'<'imageFileName'>'
Please help me on this.
You can't access any resources that are under WEB-INF folder, it serves just that purpose, to hold the resources that are not directly visible for the public but available to the classloader (servlets) of your web app.
You should make a mapping by the means of mvc:resources element, you should checkout the docs
for your particular case a mapping like
<mvc:resources mapping="/images/**" location="/WEB-INF/images"/>
should work out, and you'll be able to browse your images via request such as
/images/'<'imageFileName'>'
You can place your images and jsp folder under the web-app folder rather than WEB-INF folder. Then you can access the images using:
/images/'<'imageFileName'>'
The JSPs cannot access files inside WEB-INF folder directly, since it's not publicly available. But you can access it indirectly through a Servlet which will return the Image's stream object.
The sample code to access files in WEB-INF folder is in the below link. Have a look.
http://simple.souther.us/ar01s10.html

How to add a unity app to a wix site?

I developed a simple app in Unity for a web site. How can I add my app to my wix site?
I tried finding on the web articles on how to do so but found nothing useful.
A web build will provide you with an HTML and a .unity3d file. If your host allows you to embed HTML, take the relevant sections out of the HTML file and upload your .unity3d file.
If your host does not allow you to upload the required .unity3d file, you'll have to host it yourself. This can be on your own server, on a Dropbox, or wherever you find appropriate. This does require a small change in the generated JavaScript.
Inside your HTML file you'll find a line like
u.initPlugin(jQuery("#unityPlayer")[0], "myAwesomeGame.unity3d");
Of course the exact name depends on however your build was named. If you don't host it in the same location as the HTML, you'll need to update this.
Say you're uploading it to your public Dropbox folder. In that case you can get a public link for the Unity3D file. Replace the call above with something like
u.initPlugin(jQuery("#unityPlayer")[0], "https://dl.dropboxusercontent.com/u/XXXXXXXX/myAwesomeGame.unity3d");
and you should be good to go. Of course the same works for other hosts.

Where do I put picture in my ASP.Net MVC2 application?

Where do I place images within my solution?
I usually create Images folder inside Content folder. Most 3rd party components that use .css files search images subdirectory for their images by default.
You could put them in the Content folder, along with your .css files. Or you could create a brand new folder and organize it any way you like.
In the content folder.
We have a separate resources domain that serves up all static content (recommended). In the solution, I just have a 'resources' folder that mimics the structure of the production folder. Easier to deploy using a script. You can create a separate site or vdir on your local web server and map it to this static folder. The location could then be refernced in your project via an app setting (configuration.resourcedomain + "/resources/images/xyz.jpg")

Use html files from another project in ASP.NET MVC

I know that I can use normal html files in ASP.NET MVC; however I have a situation where several (above 20) html files are needed for static display. This is fine and good, but I really don't want it cluttering the MVC project since none of them will have controller actions.
Is there any way to load up a second project and use static html files from it, within ASP.NET MVC?
I know my answer is not directly related to your question as you are asking how to access HTML pages from a second project. But an alternate would be to place the html files in your content directory. This way you could catalog your static html pages
For Instance:
MVC Directory Structure
Content
images
logo.png
script
utility.js
staticHtml
static.html
static2.html
Model
Views