Get local image path from a widget on Titanium - javascript

How can I create a widget with its own images to use in any project? I created an "images" folder inside the widget project and now I want to get the path without changing it on every project.
The structure is: ../widgets/WidgetFolderName/images/foo.png
I tried WPATH('images/foo.png') but didn't work.

As you can see in Alloy_Widgets documentation, it searches on the assets folder or the lib folder.
Create the assets folder on the root and move there my images folder and leave unchanged the WPATH path.

Related

Flask js files not loading due to template folder and static folder file structure

So I'm trying to make a website where I'm able to just drag and drop folders containing HTML, js, and CSS files into a "library" directory and have those files served on my flask app. There's one big problem I haven't been able to get over. The problem is that all of these HTML files link to their respective js files using relative paths. For example:
<script src="js/keyboard_input_manager.js"></script>
and these files are 2 folders deep into my (combined) templates/static folder. I could fix this by doing
<script src="library/2048/js/keyboard_input_manager.js"></script>
but that is very tedious, especially when working with so many files.
TLDR: If I were to run my flask app and load a template, it wouldn't load any js or CSS because of relative paths.
Is there any way to go about this without individually changing each path to relate to the templates folder?
Example of my current filesystem:
-FLASK PROJECT
|->library (templates/static folder)
| |->2048
| |->index.html, index.css, index.js
| |->Game2
| |->index.html, index.css, index.js
|->main.py
What I've Tried:
Using Blueprint but I can't create a whole blueprint for every file?
Messing with paths of template folder and static folder
Flask Noob - Please let me know if I'm leaving out any helpful information :) Thanks

Favicon won't load and throws error in console

What work-arounds are available for this aside from updating the assets import in the angular.json file and adding an images folder in the assets directory?
I'm aware that there are a number of posts around this. And I have solved the issue in my app. But it seems that you cannot access a favicon reliably from the src folder in an Angular app. In adding an images folder to the assets directory in the app, and accessing an icon or graphic from there...the app loads the app icon every time.
My current working solution:
Add an images folder to the ./assets directory in your app. Place the image/icon in this folder and access it from there.
Google favicon generator and make an icon. Name it favicon.ico and drop it in your webroot.
See if this helps.
Also here is a tutorial on favicon: https://www.w3.org/2005/10/howto-favicon

Location of JavaScript files in ASP.NET Core Areas

I am creating an ASP.NET Core application that will contain several areas.
Where would I add JavaScript files that are specific to a certain area (usually I put them into the wwwroot\js Folder. Is there something like this for an area?)?
"Where would I add JavaScript files"? Answer is you can choose your location based on your requirements and convenience. Default location is content root i.e. wwwroot folder and its subfolders however ASP.Net Core doesn't stop you from placing those static files outside "wwwroot" folder. However if you want to place it outside default content folder i.e. wwwroot you need to tell asp.net core where your content files are located. Way to tell asp.net core is configure StaticFiles middleware as follows:
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), #"MyStaticFiles")),
RequestPath = new PathString("/StaticFiles")
});
Here MyStaticFiles folder is outside wwwroot and located just inside your project directory.
Now if you want to access any file inside MyStaticFiles folder then it will be using following path.
http://<myapp>/StaticFiles/myscript.js
Note "StaticFiles" in above path and in middleware configuration.

How to change path of welcome html file

I have created Dynamic web project and it has .html, .css and .js files. I group these file in respective folders like .js file in javascripts folder and .html file in views folder but i don't able to access these file in project. I used eclipse IDE for this. Is there need to configure path for these folder?
You need to put the JSP file in /index.jsp instead of in /WEB-INF/jsp/index.jsp. This way the whole servlet is superflous by the way.
WebContent
|-- META-INF
|-- WEB-INF
| -- web.xml
-- index.jsp
If you're absolutely positive that you need to invoke a servlet this strange way, then you should map it on an URL pattern of /index.jsp instead of /index. You only need to change it to get the request dispatcher from request instead of from config and get rid of the whole init() method.
These are not Java source files, so it makes no sense to configure them as such. By default in a Dynamic Web Project you only see the src folder under Java Resources. Other folders will be listed at the bottom of the tree. This is by design.
Or if you meant, that you do not see them when you move into the folder by an external file manager: press F5 on the project.
Its based on from which file you are trying to access those files.
If it is in the same folder where your working project file is, then you can use just the file name. no need of path.
If it is in the another folder which is under the same parent folder of your working project file then you can use location like in the following /javascript/sample.js
In your example if you are trying to access your js file from your html file you can use the following location
../javascript/sample.js
the prefix../ will go to the parent folder of the file(Folder upward journey)
I got answer to my question...
Now my directory structure is
WebContent
--javascripts
--stylesheets
--viwes
--META-INF
--WEB-INF
Note: view contain html files
To change path of my welcome html file i made bit change in web.xml present in WEB-INFfolder.
<welcome-file-list>
<welcome-file>/views/welcome.html</welcome-file>
</welcome-file-list>

How to upload folder in php

Hi i wanted to upload folder and move to some destination is it possible doing in php ? or at least i can read the folder name and create same folder in divination and copy all files into created folder.
You can do this with the new HTML5 directory capabilities. Just put the directory attributes in your input field. After you got the directory server-side, you can do everything you want with it.
URL for a simple guide:
http://www.w3bees.com/2013/03/directory-upload-using-html-5-and-php.html

Categories

Resources