In UWP app, where should html assets be stored in the assets directory? - c++-winrt

In a UWP app using cppwinrt I want to use WebView to display contents of a book kept in the Assets folder. I read that it is necessary to reference an html asset this way for use as a Uri argument to the Navigate method in web view:
TheWebView.Navigate(Uri(L"ms-appx-web:///SampleBook/PageOne.html"));
This produces an empty view, while
TheWebView.Navigate(Uri(L"ms-appx:///SampleBook/PageOne.html"));
crashes. Msdn says that for files "that will be loaded into the web compartment" one must use ms-appx-web, and I've seen mention that this is a security issue. But does that mean the files are in a special location within the project - i.e. not merely in the Assets folder - or does it only mean that the path must begin with ms-appx-web independent of the file's location? "Web compartment" is not explained but seems to be not a location but rather a classification of the type of resource. At any rate, neither of the above approaches works, so I'm curious to know the recommended way to store and access a collection of html files in the package. In the assets folder? A special folder within assets? In Solution Explorer the html file is listed, "content" is True, and the file is Included In Project. Thanks.

My mistake: ms-appx-web does not point to the assets folder, but to its parent. The correct path for content of this type would be ms-appx-web///Assets/SampleBook/PageOne.html. The reference to material to be "loaded to the web compartment" apparently is just a way of saying: stuff to be loaded with WebViewer.

Related

Find invalid image paths in vue project

In my Vue 3 project, all images are located in public/assets/image then in .vue files I refer to these images like assets/image/image.png.
Sometimes I might make a typo in a path or a path might not be correct anymore.
Is there any automated way to find and fix all incorrect paths in a project?
I am using "VS Code" and "IntelliJ IDEA" might be there are any plugins to handle this.
In VS Code there is an extension called Image preview
https://marketplace.visualstudio.com/items?itemName=kisstkondoros.vscode-gutter-preview
If the path is right it shows the image at the left side of the import.

How to build with a custom eglfs cursor atlas?

I'm trying to change the eglfs mouse cursor graphics for my embedded linux QT application (QT5.5). I have the new cursor atlas PNG and the new JSON descriptor file, but the documentation is rather vague:
".. a custom cursor atlas can be provided by setting the QT_QPA_EGLFS_CURSOR environment variable to the name of a JSON file. The file can also be embedded into the application via Qt's resource system."
I'd prefer to keep everything within the resource system if possible but I can't work out how to do it.. do I need a specific qrc file containing the path to the JSON file? I assume that the PNG file would also need to be added as a resource so that it gets built into the application?
If adding it via the resource system is a bad idea where's the correct place to set the QT_QPA_EGLFS_CURSOR environment variable? I'm currently specifying the platform on the command line via "-platform eglfs"; will this be ok or will I need to set the platform to eglfs in the build?
After much trial, error and digging around I have found the solution that I was looking for within the resource system.
Create a new resource file called "cursor.qrc", the contents of which needs to be two lines:
path/to/your/custom-cursor-atlas.png
cursor.json
The first line (path to your cursor atlas) must be relative to your resource directory.
You then need to put the JSON file (contents as described in the documentation) in the root of your resource directory. It must be called "cursor.json", and its image location line must must match the location in your new resource file and be of the format:
"image": ":/path/to/your/custom-cursor-atlas.png",
This will then include your cursor atlas in resources, and Qt will find it when your application starts.
Run time solution example:
export XDG_RUNTIME_DIR=~
export QT_QPA_EGLFS_CURSOR=~/cursor.json
In the cursor.json:
"image": "cursor.png",
Put your custom cursor.png atlas into your home dir (~) then run the Qt app from there.

Where should I put my custom widget files in Yii framework?

From this page,
http://www.yiiframework.com/wiki/23/how-to-create-a-breadcrumb-widget/
It seems it suggests that we should put the files in the component folder. But if my widget contains javascript and css files, where should these files be placed?
By the way, is this a good idea that I create it as an extension? If I go this way, all widget files are more self-contained in a folder inside the extension folder. But since the widget I am going to work on is very customized, it's unlikely that it will be useful to other people or my other projects. Making it an extension seems a little bit strange.
I understand that it does not really matter where I put these files as long as the paths I am using in the codes are correct but I would like to know the common practice.
I think the common practice is to put the widget in extensions folder with js & css files in an folder named asset. In the php class file, you do initialization first by publishing the asset with yii asset manager.
The file structure may be like
extensions/
widget_name/
widget.class.php
assets/
plugin.js
style.css
I would join the recommendation to put the widget under /protected/extensions.
I put the assets in a slightly more detailed manner: /protected/extensions/WidgetClassName/assets/ and the widget view files in /protected/extensions/WidgetClassName/views/...
Don't forget to edit your /protected/config/main.php and add a row in the 'import' section (for autoloading of the widget): 'ext.WidgetClassName.WidgetClassName.*'

ActionScript 2 load another SWF that loads other files - relative path/url problem

Few facts first:
1. I can only use ActionScript 2.
2. All files are within the same domain (i.e "http://www.example.com").
I have a loader SWF which acts as a selection tool ("auto_magic.swf") located at "/" in the website (the root folder).
A User selects the tool he needs (it's a mechanical diagnostic system) and the main movie loads it (currently I use loadMovie() - suggest else if needed).
That tool is located at "/tools/[tools_name]/tool_main.swf".
Now, the "tool_main.swf" is loading just fine.
The problem is that "tool_main.swf" needs to load other files located in its folder, so for example it tries to load "config.xml", BUT Flash isn't looking for "config.xml" in the tool's dedicated folder - instead it's looking for this file at the root folder "/" where "auto_magic.swf" is located, probably because the movie's main swf is coming from there.
To make it even worst I cannot modify the tool's SWF ("tool_main.swf") because it's coming from a third party.
Is there any solution? As far as I see this I need one of these solutions;
1. Be able to set the base url of the loaded swf.
2. *Change* the whole movie's base url at run-time because it needs to load several tools from different folders.
Trying to solve this for several good hours. Help will be highly appriciated!
relative paths are always relative to where the main swf exists. so as your load chain expands, '/' always refers to the location of the Main.swf.
in AS2, you can inspect a swfs _url property to determine its fully qualified url location, and determine its parent folder.
In the AS2 child swf, you can use this:
var myfolder = this._url.slice(0, this._url.lastIndexOf('/') + 1);
and then use that to load in further assets relative to itself.
hope that helps.

Using images from a static Library

I'm trying to convert a project, which has images, into a static library.
The code that gets the image is as follows:
[UIImage imageNamed:#"foo.png"]
When I include this library into another project, the image doesn't load. However, if I copy the images into the new project, then it does load.
Is there any way I can get this to work where the images are only contained in the library and I don't have to copy them over to my project?
By the way, my Header Search Paths contains the path to where these images are located in the library, if that makes any difference.
Just prepend the name of the bundle that contains your image to the image name:
[UIImage imageNamed:#"Myframework.bundle/MyImage"
This also works in Interface Builder, the preview may be broken but the image will be properly loaded.
If using CocoaPods (which I would recommend) make sure to use the resource_bundles option for your images and Nibs.
You can see a related answer here.
A static library cannot contain bundle resource. So simply linking the .a file will not be enough. But you should be able to cross-reference the static library xcodeproj. Example
Had a similar situation to this and wrote a script to copy the files in to the .app at compile time. A similar fix to the one we use is described in the "Non-code assets for static libraries" section on this web page. This works but can cause some code signing errors. Another option is to create a second .bundle target for the resources described on this web page although for some reason I could not get the bundle to actually build. I am currently looking at writing a script to copy the resources in to a bundle at compile time and compile any .xib files to .nibs, this is also a possible solution you could look at.