How can I help IntelliJ IDEA resolve my files and directories? - intellij-idea

I have a web site project folder that looks something like this:
/
/css/
/includes/public.cfm
/js/jquery.js
index.cfm
My index.cfm file includes the content from the /includes/public.cfm file. The public.cfm file has references to various .css and .js files in it like this:
/includes/public.cfm
------------------------
<base href="http://localhost/mysite/">
<script type="text/javascript" src="js/jquery.js"></script>
The problem is that IDEA can't find the file /js/jquery.js and shows a "cannot resolve directory" inspection error even though the file does exist in the project structure.
How can I tell IDEA to always look at my project root for resolving directory locations? It would be great if it could first look relative to the current folder and then look relative to the project root.
Note: when the web site gets deployed to production, it will reside at www.mydomain.com but it should also be able to reside in a sub folder for development purposes.

Related

How to make IntelliJ understand the Next.js `public` directory structure?

I am using IntelliJ to edit a Next.js website.
IntelliJ IDEA 2020.2.1
Next.js 9.5.3-canary.23
Next.js static file serving uses a /public directory as a container for static assets, but when publishing a Next.js site, the contents of the public directory are hosted at the root of the site.
So, as shown in the linked doco, an image that exists in the codebase at /public/my-image.png is addressed by an URL path of src="/my-image.png".
This confuses IntelliJ and it shows a warning that it can't resolve the directory of the img src:
I tried marking the /public directory as a "Source root" or a "Resources root" - but that didn't make the warning go away.
I also tried adding the /public directory as a "Content root", but IntelliJ doesn't want to do that because it overlaps with the root directory of the module, which is already a content root.
Is there any way to tell idea to look in the /public directory for statically referenced assets like this?
I've had the same problem. In my case, "Mark Directory as > Resource Root" worked well.
Before...
Right click ./public. Then Mark Directory as > Resource Root
After...
Image loads.

404 error serving .js files on ASP.NET Core

I've got a straightforward ASP.NET Core web app using Razor pages (not MVC). I've been looking at the Application Insights as I run the app and see a ton of 404 errors related to files like this...
https://localhost:5001/~/lib/bootstrap/dist/js/bootstrap.bundle.js
My Startup class has app.UseStaticFiles(); and is able to serve other files in the root directory and sub directories like css and images. So why can't it find and serve these .js files? I've tried adding options to the static file configuration but nothing seems to work. I keep getting the 404 errors in Application Insights. I can go to the file explorer and see that these files all exist. I've been working on this for hours with no success.
The ~ should be changed to the root of the application (which might be the root of the domain, or a virtual directory). If it's not, then it's not being used correctly.
My guess is that you have a slash in front:
<script src="/~/lib/bootstrap/dist/js/bootstrap.bundle.js"></script>
The path should begin with a ~, not a slash:
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.js"></script>
I figured it out. My clue was that in the empty template project in the Layout.cshtml some of the tags like <environment> were displayed in bold but in my project they weren't. In my ViewImports file I included #tagHelperPrefix th: which makes it so the Microsoft tag helpers require special syntax like <th:link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />. The Microsoft tag helpers must do something special with paths that involve a ~ character.
When I replaced all my link tags in Layout.cshtml from <link> to <th:link> it started to work. Or I can take out #tagHelperPrefix th: from ViewImports and use the normal looking tags.

How are polymerDart components deployed in Dartium versus their Source tree

When i am making PolymerElements in Dart and have folders organized to store css/html/dart files, when i run index.html in Dartium and look at the sources it seems that everything is shifted around and stored in the packages folder.
Im trying to find these custom PolymerElement dart files I have written, but to no avail. It seems when looking at index.html at runtime, it will paste the css/html as required into the custom elements i had created, but im still not sure where the dart files themselves are stored.
Right now I have a SRC structure that looks like:
.pub/
lib/
common/
...
tw_datagrid/
a.css
a.html
a.dart
packages/
web/
packages/
index.html
main.dart
and for the deployment to Index, i look at the source and see the following:
proj_name/web
packages/
it seems that packages in the web sources has a more robust set of information. My logic tends to lean towards it containing the imported libraries as well.
Still though, i cant find the new location of: a.dart within the packages/ folder
Html, CSS and JS is inlined into index.html. For CSS files this can be disabled.
Source files from the library directory can be found in Dartium (in the Sources tab in the dev-tools) under the (no domain) node under package:proj_name/tw_datagrid/a.dart

Apache directory root and public directory can't access to files

In my /var/www/ i have:
my_project
|-app
|-controllers
|-models
|-views
|-core
|-css
|-js
|-public
|-index.php
I have set up "DirectoryRoot" to:
/var/www/my_project/public/
Now when i open web page in browser my views are loaded but links to files in css and js folders don't work. It looks like I can't go one directory up. What am i doing wrong ?

Apache htaccess setting default index.html or <folder name>.html

We have an automated legacy system that provides zip files with html content (including images and other files). The system will either provide a folder with an index file or a file with the name as the folder.
For example say the file being sent in was User Supplies.zip
We would either see a folder structure like this
User Supplies/index.html
or like this
User Supplies/User Supplies.html
Currently we examine the contents for the zip file and rename anything that matches the folder name back to index.html. Since there could be other html files in there it has become a bit of spaghetti code to get it to work.
We could get rid of all this code if we can include something to the equivalent of "Use index.html or [folder name].html as the default file"