Detect navigator inside WebExtension's manifest.json - if-statement

I am currently working on a WebExtension and I have a small problem. On my Firefox browser I'm able to import and run my work without any error/warning. However with Google Chrome I have a big warning about a feature not implemented (the browser_style property of manifest.json key options_ui).
I'd like to create something like an if statement based on the navigator name to not set this property on Chrome but keep it on Firefox.
Here is the part of my manifest.json:
"options_ui": {
"page": "contents/settings.html",
"browser_style": true
},
And here is what I'd like to have (not working):
"options_ui": {
"page": "contents/settings.html",
if (options_ui.browser_style) {
"browser_style": true
}
},
Any ideas on how to create a condition like this in a manifest.json file?

As Daniel Herr implied in a comment, the manifest.json file is straight JSON formatted data. JSON has no capability to run code. There is no possibility to dynamically define properties within your manifest.json file. You have 2 options:
Live with the warning(s).
Both Chrome and Firefox have valid properties defined for manifest.json files which the other does not support. Both show warnings when there are unsupported properties. These are only warnings and do not cause the browser to prevent the extension from running. Chrome prominently shows these in chrome://extensions/. Firefox shows them in the Browser Console (Ctrl-Shift-J, or Cmd-Shift-J on OSX).
Have a separate manifest.json file per browser.
This adds some complexity to your build/development process, but will allow you to eliminate these warnings in each browser.
Note: Even if you don't submit different manifest.json files to Google (Chrome Web Store - Extensions) and Mozilla (AMO), by the time the extension package is distributed to the user, the manifest.json files and other contents of the extension package will be different, as the process of going from submission to distribution results in that file being modified and/or additional files being added to the extension package.

Related

Difference between Modification Controllers and Catalog Controllers

I am confused that what is the difference between controllers modifications in the storage directory and the catalog directory.
Editions in extensions don't affect pages in catalog controllers.
Can you enlight me?
When you see a core file in storage/modification folder, it means that you have an OCMod file that needs to edit that core file. for example:
Core File (OpenCart original file):
catalog/controller/product/product.php
Modification File (copy of original file with some edits altered by OCMod):
storage/modification/catalog/controller/product/product.php
Go to admin panel / Extensions / Modifications, you should see a list of installed OCMod files. also you can see a Refresh button on top of this page, if you hit this button all files in storage/modification folder will be deleted And if necessary, it will be rebuilt.
Read more about modification system:
https://github.com/opencart/opencart/wiki/Modification-System

How publish a directory with ring middleware?

I am trying to use Clojure + Compojure + Ring in combination with the qooxdoo JS library. This is actually going well, but qooxdoo runs in two modes "build" (that works for me) and "source" (not so good). In the latter case, the JS generated by qooxdoo actually hardcodes references (well, using relative addresses ../../..) back to the qooxdoo installation and at run time it asks for sth like:
http://localhost:3000/opt/qooxdoo-5.0.1-sdk/framework/source/class/qx/bom/client/OperatingSystem.js
...since I have the library installed under /opt/qooxdoo-5.0.1-sdk.
Serious sanity check: if I directly open the index.html in the browser, it works fine. So it seems I just have to figure out how to serve the static files under the /opt library install.
I have tried wrap-file from the ring.middleware.file because that sounds like what I want but no matter what path I give it I get hundreds of 404s as it tries to pick up each framework file individually from the installed library.
I can work OK under "build" (qooxdoo cobbles together a single minified .js I serve with wrap-resource) but on occasion I need to run in source mode to find JS bugs.
Am I missing something simple?
The correct way to handle this is to configure Qooxdoo to tell it what URIs you would like to use - by default the source build does just use relative paths, but you can easily override this by editing the config.json.
In your config.json you will have a "jobs" section containing a "libraries" section, containing a "library" array - your application is a library, as is Qooxdoo, as is any contribs so it will look something like this:
"jobs" : {
"libraries" : {
"=library" : [ {
"manifest" : "${QOOXDOO_PATH}/framework/Manifest.json"
}, {
"manifest" : "Manifest.json"
}
},
Each "library" object can have a "uri" property, so for your example you probably want something like this:
"jobs" : {
"libraries" : {
"=library" : [ {
"manifest" : "${QOOXDOO_PATH}/framework/Manifest.json",
"uri" : "/opt/qooxdoo-5.0.1-sdk"
}, {
"manifest" : "Manifest.json"
}
},
Simple indeed: (wrap-file "/")
In development/source mode qooxdoo works off the installation directory instead of code pulled into my local tree, and does so by hardcoding relative paths that resolve to an absolute /opt/qooxdoo-etc path.
This looks to the server like a relative "opt/qooxdoo..." file request, so I had to offer root ("/") as a search directory.
(wrap-file "/") is a serious security issue since you're offering the root directory for all.
What you can potentially do is to make a dedicate directory to server your static file, and serve your content from there.
su
mkdir -p /var/clojure/static/opt
cd /var/clojure/static/opt
ln -s /opt/qooxdoo-5.0.1-sdk qooxdoo-5.0.1-sdk
chown -r YOUR-USER-ID /var/clojure/static/opt
And use the middleware: (wrap-file "/var/clojure/static") to serve your file.
There is a section in the manual that deals with the issue of serving a source version through a web server.
I guess you found the basic insight yourself, that the web server must export a root where the relative paths used in the generated loader match URL paths under that web server. (The rational behind this is that the source version uses all the JS files from all involved libraries directly from disk.)
In the worst case that might mean you need to export the file system root ("/") from your web server. As you are doing this on a local development machine this shouldn't be much of a problem. If security is a concern you might want to collect your qooxdoo environment under some innocent path like /home/kenny/devel/qooxdoo, containing the qooxdoo SDK, your app, and all libs/contribs you might be using.
If you follow the above link you will also find some help from the qooxdoo tool chain. E.g. if you run generate.py source-httpd-config[*] it will tell you which path on your local disk is the closest parent directory that will encompass all necessary libraries, i.e. needs to be exported in your web server for the source version to work.
Alternatively, as John wrote you can export each qooxdoo lib through an individual path under your web server, and then tell your main application where to find it. You might actually need to give a proper URL like http://localhost/libs/qooxdoo-5.0.1-sdk/framework, not just a file system path as John suggests. Also remember that you have to go as far as the directory where the Manifest file resides (hence the above path ending in .../framework). See this manual section for a deep dive.

Zurb foundation 6 , what-input.min.js file functionality

Id like to know the relevance of what-input.min.js include in Zurbs foundation-6 framework , in the js/vendor directory , this is because i keep getting an 404 not found error not loading while running the site , ... js/vendor/jquery.min.map file , is there any connection ?
You don't need the .map file which is used to map a minified file back to the original. It is available for download from jquery's site. Source maps are can be ignored in inspector settings which makes sense when you don't plan on debugging minified javascript files
It is unrelated to the source map file 404 but what-input.min.js is a JS library "to watch for mouse, keyboard and touch events"
They have a github page with more documentation: https://github.com/ten1seven/what-input
and a demo:
https://ten1seven.github.io/what-input/
"Tab, click or tap the links and form controls to see how What Input allows them to be styled differently"
I had this exact same problem on every site when using JointsWP with Foundation 6 framework. I finally just figured it out. I turned off css source mapping and still received the error. It turns out that it wasn't lying to me and the js file really does not exist where it is trying to load it from:
/vendor/what-input/what-input.min.js
But it is under the dist folder within that same directory. So if you find your enqueue-scripts.php file where the what-input.min.js is loaded, you can fix the directory path to:
/vendor/what-input/dist/what-input.min.js
And no more 404!

Cannot save file in WebStorm 9

I have been using the same workflow for months to add a new page in my ASP .NET site, but all of a sudden I am getting problems with trying to save a .ascx file inside of WebStorm.
I created the .ascx page in VS and then saved it. I then go over to WebStorm to start developing and I cannot save any of these new files. I get this error:
Following errors occurred on attepmt to save files:
C:\...\Management\Management.ascx___jb_bak___ (Access is denied)
I don't get what this file is and why it can't be saved... The jb makes it seem like a JetBrains file, but this file doesn't actually exist in the filesystem. All the other files I have had work just fine. Its just this new file all of a sudden.
What does this error even mean.. there is no valuable information
This error happened to me everytime I used Nodemon to start Webpack on a separate process. The problem was fixed by disabling "Safe write" in "Settings", as VyvIT suggested.
Hello to Developers using Jetbrains products!
I had this problem today and I think it was for the webstorm but I check my E: drive that I was developing on.
The problem was with my hard drive that changed to read-only.
I changed my drive to C and it solved.
Check your drive that you are using. That might be the problem.
You need to change your security options for user in Windows:
Right Click
The Folder > Properties > Security Tab
Click on
Edit to change Permissions > Select User

Why does my web-app work offline in Firefox, but not on iPad?

I recently wrote a few scripts for Javascript which I am trying to run as a native app on my iPad in offline mode.
The scripts do nothing complex, simply run off a bunch of prompts and generate a document.write() based on the information the user has entered.
So I set up my own little website to host the scripts on and went about setting up an application cache. I am new to this sort of thing however from what I gather, I have followed instructions correctly. To set up my app cache, I did the following:
Added the following two lines to my .htaccess file:
AddType text/cache-manifest .manifest
AddType text/manifest .manifest
Made a new file called "generator.manifest", which has the following lines:
CACHE MANIFEST
generator.html
answergenerator.js
And added in to my generator.html file:
Apart from a few functions used to prompt some iOS features, all I have in my generator.html file is this:
along with the other stock standard html tags.
That is my appcache setup. The generator.manifest file is in the exact same directory as the generator.html file.
When I enter Firefox and go to my site, I can run the script, allow it to cache files for offline usage (Firefox comes up with a prompt), and then run the script in offline mode.
HOWEVER, whenever I try to do this on my iPad (4.2.1), I simply get the error: "Generator could not be opened because it is not connected to the Internet."
Where have I gone wrong? Can someone help me fix this please?
A huge thanks in advance,
Haz.
You might look at this answer. iOS does seem to have some issues. I found that I had to power cycle my iPad (in addition to clearing open Safari's) before it would recognize the appcache.