web2py site is not loading the usual css, just plain ugly html - html

I'm moving my web2py powered site from one server to another. After fighting a permissions problem with /tmp/fcgi.sock default file location for weeks I finally understood that is was better put it under /srv/http/ on Arch Linux on any other place owned by the user who runs the http server (in my case http) as indicated here. Now I'm trying to figure out what is happening with the look and feel of the site because web2py is loading plain ugly html instead of the usual bootstrap twitter theme. I remember having this problem before, and solved it with the proper permissions, but I have tested several permissions on the web2py's folder and all of them give me the same ugly results. Any pointer to a solution?

Ok, here was the problem: My combination was lighttpd + web2py on Arch Linux, and lighhtpd have not the proper mimetype assignation for css, so the server was treating css files as ocstream. The solution is to add ".css" => "text/css" to the mime type section of the lighttpd.conf for example:
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png",
".css" => "text/css",
"" => "application/octet-stream"
)
For details see on: Styles (CSS) not working properly on the Arch Wiki.
Thanks to #neoecos for helping with this on twitter.

Related

Creating two html pages in SAPUI5 and executing one or the other depends on the situation

Currently I have my project running as welcomFile the index.html file. This file takes me to an authentication process. The case is that I need to access one of my views but without performing this authentication, that is, I don't want to go through this index.html. To do so, I created another html (index_new.html). Even if I run this last one it always redirects me to the index.html, I don't know if it has to do with how the neo-app.json file is configured. I tried to put in the index.html that if it arrived a parameter in the url to be directed to the index_new.html but without success, it says that the page does not exist. This is what I tried:
<script>
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
window.location.search = urlParams.toString();
const con = urlParams.get('con');
if (con !== ""){
window.open("/index_new.html", "_self");
}
</script>
The only way I have managed to load the path I want is to run the program, it goes to the index.html and once it has loaded, I change the path to the index_new.html/viewthatIwanttoshow and it shows up. Is there any way to run the new index_new.html without having to run the old one?
I also think it's because of the manifest, because from the index_new.html I do it like this, just like in the index.html:
……
<script id="sap-ui-bootstrap>
…
data-sap-ui-resourceroots='{"app.hello”: “./“}’
…
</script>
</head>
<body class="sapUiBody">
<div data-sap-ui-component data-name="app.hello” data-id="container" data-settings='{"id" : “hello”}’ style="height: 100%"></div>
</body>
Maybe I should change the path here but I don't know which one or how to configure it in the manifest.json.
Maybe my question is not clear, if you have any questions please let me know.
My neo-app.json:
"welcomeFile": "/webapp/index.html",
My manifest.json:
"sap.app": {
"id": “app.hello”,
"type": "application",
I can't / don't want to give you a direct answer on your question. But I would like to mention to think about the concept you are going for.
I don't really understand why you want to load different index.html files. It's pretty far away from a best practice scenario - at least with the information I have out of your post.
When we are talking about authentication, mostly you save a token in cookies / browser storage. Then you can check if you are authenticated. If so, use the UI5 router. In every page you want to, you can check for valid authentication / authorization and redirect again to a login page, if you are not.
IMO you shouldn't use two different index.html sites.
I hope this help you to find another way to solve it.

wordpress - site not update after update style.css

When I updated the style.css in Appearance > Theme Editor > stylesheet(style.css),
I refresh my site, then I see that the style is not applied.
I've also tried clear cache in browser and use cmd + shift + r to re-download the resources but still not working.
Is there any way to make the site live for development, or is there any preferred way for development?
In style.css
...
/*
Author: xxx Limited
Description: This is the template for xxx
Version: 1.0.0. // tried to update the version here but not working
...
*/
.....
Need to check few things.
upload style.css through ftp or cpanel again to check whether it is properly saved or not,
Remove cache , check in private window to make sure that there is no cache.
check in console for error if above 2 doesn't work.
If the CSS file has been updated, the problem is because of caching. There are different levels of cache.
Clear Cloudflare cache if you are using it.
Clear any caching mechanism that your Webhosting offered.
Clear all plugins cache
Salman and PHP Geek are right, do the steps they mention that should solve your problem. If the problem continues then...
In function.php find wp_enqueue_style function it would look something like this. There can be multiples of them so look for the 'style.css' inside them
wp_enqueue_style('yourtheme-style', get_template_directory_uri() . '/style.css', '', '1.1.0');
see the last argument '1.1.0' this could be anything on your case, this can also be a variable. Change this to something else like '1.1.1' (anything other then 1.1.0)
OR
replace the line with the below code (doing this will change your version automatically whenever you change something in the style.css)
$ver = filemtime(get_template_directory().'/style.css');
wp_enqueue_style('yourtheme-style', get_template_directory_uri() . '/style.css', '', $ver);

Link to home page renders blank

In my rails app, I have a link to the root that renders in all browsers as
<html>
<head>
<style type="text/css"></style>
</head>
<body>19</body>
</html>
Server-side I can see all assets getting passed back. For some reason the browser will not display them because if I view page source I can see ALL my markup correctly.
Now if I load or reload the page localhost:3000 normally the page and all assets are displayed correctly. If I simply refresh I get nothing.
The only time this occurs is when I click a link back to the homepage like a href="/".
The behavior does not occur if I hardcode a href="localhost:3000/" but I don't want to do this.
Rails app, Turbolinks, nowhere in code do I use the number 19, rake routes with root GET well-defined, no public/index.html. I suspect something to the degree of caching or turbolinks but I have no clue how to resolve.
Edit: Config/Routes.rb
SCRR::Application.routes.draw do
root 'home#index'
#pages
get 'about' => 'pages#about'
get 'history' => 'pages#history'
get 'links' => 'pages#links'
get 'safety' => 'pages#safety'
get 'membership' => 'pages#membership'
get 'events' => 'events#index'
get 'grand_prix' => 'grand_prix#index'
get 'newsletters' => 'newsletters#index'
end
Edit 2: Chrome Devtools Console Errors
This error is probably more relevant
Resource interpreted as Font but transferred with MIME type application/x-woff: "https://netdna.bootstrapcdn.com/font-awesome/2.0/font//fontawesome-webfont.woff".
jquery-2.1.0.js?body=1:1078
25115 : CS -> BG : FAILED closepopuptoplevel
onloadwff.js:77
From what you've posted, I don't know whether this would be a Rails issue or a browser issue.
I see you've tagged turbolinks, which could be a contributor to the issue; so let's have a look as to what the problem might be for you:
ERB
The ERB code you should use should be the following:
<%= link_to "Home", root_path %>
If you're trying to reference the "home" url directly, there may be an issue with how you're rendering the URL, hence why it won't show. You should ensure you use the path helper as described above.
This should be coupled with the correct routes:
#config/routes.rb
root "home#index"
resources :pages, path: "" do
collection do
get :about
get :history
get :links
get :safety
get :membership
get :events
get :grand_prix
get :newsletters
end
end
Assets
You mention the assets don't render when you refresh the page, this could be an issue with Turbolinks, although I'm not sure
Turbolinks basically just reloads the <body> of the page, leaving the <head> intact. Although this might sound like nothing to do with your issue, perhaps the problem is to do with the way in which Turbolinks is working with your assets
From your edit, it may appear that your assets are not loading correctly, or are at least not being shown correctly.
I hope this helps, I doubt it will give you a constructive answer

Resource interpreted as stylesheet but transferred with MIME type text/html (seems not related with web server)

I have this problem. Chrome continues to return this error
Resource interpreted as stylesheet but transferred with MIME type text/html
The files affected by this error are just the Style, chosen and jquery-gentleselect (other CSS files that are imported in the index in the same way work well and without error). I've already checked my MIME type and text/css is already on CSS.
Honestly I'd like to start by understanding the problem (a thing that seems I cannot do alone).
i'd like to start by understanding the problem
Browsers make HTTP requests to servers. The server then makes an HTTP response.
Both requests and responses consist of a bunch of headers and a (sometimes optional) body with some content in it.
If there is a body, then one of the headers is the Content-Type which describes what the body is (is it an HTML document? An image? The contents of a form submission? etc).
When you ask for your stylesheet, your server is telling the browser that it is an HTML document (Content-Type: text/html) instead of a stylesheet (Content-Type: text/css).
I've already checked my myme.type and text/css is already on css.
Then something else about your server is making that stylesheet come with the wrong content type.
Use the Net tab of your browser's developer tools to examine the request and the response.
Using Angular?
This is a very important caveat to remember.
The base tag needs to not only be in the head but in the right location.
I had my base tag in the wrong place in the head, it should come before any tags with url requests. Basically placing it as the second tag underneath the title solved it for me.
<base href="/">
I wrote a little post on it here
I also had problem with this error, and came upon a solution. This does not explain why the error occurred, but it seems to fix it in some cases.
Include a forward slash / before the path to the css file, like so:
<link rel="stylesheet" href="/css/bootstrap.min.css">
My issue was simpler than all the answers in this post.
I had to setup IIS to include static content.
Setting the Anonymous Authentication Credentials to Application Pool Identity did the trick for me.
Try this <link rel="stylesheet" type="text/css" href="../##/yourcss.css">
where ## is your folder wherein is your .CSS - file
Don't forget about the: .. (double dots).
I was also facing the same problem. And after doing some R&D, I found that the problem was with the file name. The name of the actual file was "lightgallery.css" but while linking I has typed "lightGallery.css".
More Info:
It worked well on my localhost (OS: Windows 8.1 & Server: Apache).
But when I uploaded my application to a remote server ( Different OS & Web server than than my localhost) it didn't work, giving me the same error as yours.
So, the issue was the case sensitivity (with respect to file names) of the server.
In case you serve static css with nginx you should add
location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
or
location ~ \.css{
default_type text/css;
}
location ~ \.js{
default_type application/x-javascript;
}
to nginx conf
Based on the other answers it seems like this message has a lot of causes, I thought I'd just share my individual solution in case anyone has my exact problem in the future.
Our site loads the CSS files from an AWS Cloudfront distribution, which uses an S3 bucket as the origin. This particular S3 bucket was kept synced to a Linux server running Jenkins. The sync command via s3cmd sets the Content-Type for the S3 object automatically based on what the OS says (presumably based on the file extension). For some reason, in our server, all the types were being set correctly except .css files, which it gave the type text/plain. In S3, when you check the metadata in the properties of a file, you can set the type to whatever you want. Setting it to text/css allowed our site to correctly interpret the files as CSS and load correctly.
#Rob Sedgwick's answer gave me a pointer, However, in my case my app was a Spring Boot Application. So I just added exclusions in my Security Config for the paths to the concerned files...
NOTE - This solution is SpringBoot-based... What you may need to do might differ based on what programming language you are using and/or what framework you are utilizing
However the point to note is;
Essentially the problem can be caused when every request, including
those for static content are being authenticated.
So let's say some paths to my static content which were causing the errors are as follows;
A path called "plugins"
http://localhost:8080/plugins/styles/css/file-1.css
http://localhost:8080/plugins/styles/css/file-2.css
http://localhost:8080/plugins/js/script-file.js
And a path called "pages"
http://localhost:8080/pages/styles/css/style-1.css
http://localhost:8080/pages/styles/css/style-2.css
http://localhost:8080/pages/js/scripts.js
Then I just add the exclusions as follows in my Spring Boot Security Config;
#Configuration
#EnableGlobalMethodSecurity(prePostEnabled = true)
#Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
#Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers(<comma separated list of other permitted paths>, "/plugins/**", "/pages/**").permitAll()
// other antMatchers can follow here
}
}
Excluding these paths "/plugins/**" and "/pages/**" from authentication made the errors go away.
Cheers!
Using Angular
In my case using ng-href instead of href solved it for me.
Note :
I am working with laravel as back-end
If you are on JSP, this problem can come from your servlet mapping.
if your mapping takes url by defaut like this:
#WebServlet("/")
then the container interpret your css url, and goes to the servlet instead of going to the css file.
i had the same issue, i changed my mapping and now everyting works
i was facing the same thing, with sort of the same .htaccess file for making pretty urls. after some hours of looking around and experimenting. i found out that the error was because of relatively linking files.
the browser will start fetching the same source html file for all the css, js and image files, when i would browse a few steps deep into the server.
to counter this you can either use the <base> tag on your html source,
<base href="http://localhost/assets/">
and link to files like,
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="js/script.js"></script>
or use absolute links for all your files.
<link rel="stylesheet" type="text/css" href="http://localhost/assets/css/style.css" />
<script src="http://localhost/assets/js/script.js"></script>
<img src="http://localhost/assets/images/logo.png" />
I have a similar problem in MVC4 using forms authentication. The problem was this line in the web.config,
<modules runAllManagedModulesForAllRequests="true">
This means that every request, including those for static content, being authenticated.
Change this line to:
<modules runAllManagedModulesForAllRequests="false">
I also face this problem recently on chrome. I just give absolute path to my CSS file problem solve.
<link rel="stylesheet" href="<?=SS_URL?>arica/style.css" type="text/css" />
For anyone that might be having this issue.
I was building a custom MVC in PHP when I encountered this issue.
I was able to resolve this by setting my assets (css/js/images) files to an absolute path.
Instead of using url like href="css/style.css" which use this entire current url to load it. As an example, if you are in http://example.com/user/5, it will try to load at http://example.com/user/5/css/style.css.
To fix it, you can add a / at the start of your asset's url (i.e. href="/css/style.css"). This will tell the browser to load it from the root of your url. In this example, it will try to load http://example.com/css/style.css.
Hope this comment will help you.
It is because you must have set content type as text/html instead of text/css for your server page (php,node.js etc)
I want to expand on Todd R's point in the OP. In asp.net pages, the web.config file defines permissions needed to access each file or folder in the application. In our case, the folder of CSS files did not allow access for unauthorized users, causing it to fail on the login page before the user was authorized. Changing the required permissions in web.config allowed unauthorized users to access the CSS files and solved this problem.
I have the same exact problem and after a few minutes fooling around I deciphered that I missed to add the file extension to my header. so I changed the following line :
<link uic-remove rel="stylesheet" href="css/bahblahblah">
to
<link uic-remove rel="stylesheet" href="css/bahblahblah.css">
Using React
I came across this error in my react profile app. My app behaved kind of like it was trying to reference a url that doesn't exist. I believe this has something to do with how webpack behaves.
If you are linking files in your public folder you must remember to use %PUBLIC_URL% before the resource like this:
<link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/bootstrap.min.css" />
In case anyone comes to this post and has a similar issue. I just experienced a similar problem, but the solution was quite simple.
A developer had mistakenly dropped a copy of the web.config into the CSS directory. Once deleted, all errors were resolved and the page properly displayed.
I came across the same issue whilst resuming work on a old MEAN stack project. I was using nodemon as my local development server and got the same error Resource interpreted as stylesheet but transferred with MIME type text/html. I changed from nodemon to http-server which can be found here. It immediately worked for me.
This occurred when I removed the protocol from the css link for a css stylesheet served by a google CDN.
This gives no error:
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Architects+Daughter">
But this gives the error Resource interpreted as Stylesheet but transferred with MIME type text/html :
<link rel="stylesheet" href="fonts.googleapis.com/css?family=Architects+Daughter">
I was facing similar issue. And Exploring solutions in this fantastic Stack Overflow page.
user54861 's response (mismatching names in case sensetivity) makes me curious to inspect my code again and realized that "I didnt upload two js files that I loaded them in head tag". :-)
When I uploaded them the issue runs away ! And code runs and page rendered without any another error!
So, moral of the story is don't forget to make sure that all of your js files are uploaded where the page is looking for them.
I came across the same issue with a .NET application, a CMS open-source called MojoPortal. In one of my themes and skin for a particular site, when browsing or testing it would grind and slow down like it was choking.
My issue was not of the "type" attribute for the CSS but it was "that other thing". My exact change was in the Web.Config. I changed all the values to FALSE for MinifyCSS, CacheCssOnserver, and CacheCSSinBrowser.
Once that was set the web site was speedy once again in production.
Had the same error because I forgot to send a correct header a first
header("Content-type: text/css; charset: UTF-8");
print 'body { text-align: justify; font-size: 2em; }';
I encountered this problem when loading CSS for a React layout module that I installed with npm. You have to import two .css files to get this module running, so I initially imported them like this:
#import "../../../../node_modules/react-grid-layout/css/styles.css";
but found out that the file extension has to be dropped, so this worked:
#import "../../../../node_modules/react-grid-layout/css/styles";
If nodejs and using express
the below code works...
res.set('Content-Type', 'text/css');
I started to get the issue today only on chrome and not safari for the same project/url for my goormide container (node.js)
After trying several suggestions above which didn't appear to work and backtracking on some code changes I made from yesterday to today which also made no difference I ended up in the chrome settings clicking:
1.Settings;
2.scroll down to bottom, select: "Advanced";
3.scroll down to bottom, select: "Restore settings to their original defaults";
That appears to have fixed the problem as I no longer get the warning/error in the console and the page displays as it should. Reading the posts above it appears the issue can occur from any number of sources so the settings reset is a potential generic fix.
Cheers
If you are serving the app in prod make sure you are serving the static files with service worker. I had this error when I was serving only static subfolder of React build on Django (without assets that have styles)

Perl Catalyst - Page not found when using href to link to page on the same site

I am creating a Catalyst application, currently I have a simple login page that also contains a 'Forgotten Password' link. It is all working perfectly, except when I click the 'Forgotten Password' link it should take me to a brand new html page that simply contains the words "Unlucky, you should have remembered it". Instead I get a 'Page not found' error.
What I am doing:
I have a Controller called Login.pm containing the following:
sub default : Private {
my ( $self, $c ) = #_;
$c->forward('login');
}
sub login : Path('/login') {
my ( $self, $c ) = #_;
$c->stash->{title} = "Login page";
$c->stash->{page} = "html";
$c->stash->{template} = "login.html";
}
All of the above works correctly and produces the login page.
In the Catalyst root/login.html file (along with all the other bits like buttons) I have the following piece of code that should allow me to link to the 'Forgotten Password' html page.
<p>Forgot Password?</p>
The root/forgotpassword.html file it is referencing contains the following:
<!DOCTYPE html>
<html>
<body>
<h1>Unlucky, you should have remembered it</h1>
</body>
</html>
However, when I click the 'Forgotten Password' link on the login page it goes to 'mydomainname/forgotpassword.html' and says 'Page not found'.
Do I need to create a Controller for the forgotpassword page? and if so what would it need to contain? Or is there something obvious I am overlooking?
I am new to Catalyst.
Finally worked out the issue, thanks to 'mikew' for referring me to the 'Serving static content' section of the cookbook on CPAN.
What the problem was:
Using the html5 code below I was referencing a simple html page that required no interaction with Catalyst to work.
<p>Forgot Password?</p>
However, as mentioned in the Cookbook and Catalyst::Plugin::Static::Simple
"By default, the following extensions are not served (that is, they will be processed by Catalyst): tmpl, tt, tt2, html, xhtml."
and
"There are some file types you may not wish to serve as static files. Most important in this category are your raw template files. By default, files with the extensions tmpl, tt, tt2, html, and xhtml will be ignored by Static::Simple in the interest of security."
To prevent the 'Page not found' error (as the html page is ignored by default) you need to do add the following to the MyApp.pm file ensuring that you remove the extension/s you do not want to be ignored (in my case html files).
MyApp->config(
static => {
ignore_extensions => [
qw/tmpl tt tt2 xhtml/
],
},
);
I believe what you want to do is make sure that file is served up statically. Look at the cookbook for making sure you are configured to serve up static files instead of sending that request through catalyst.