I trying to make my on module for openwrt. I make simple pages for luci and now need for jQuery. So I add
<script type="text/javascript" src="/resources/jquery-2.1.1.min.js"></script>
to my htm file. But browser returns a 404 for jquery-2.1.1.min.js.
How to add jquery-2.1.1.min.js in luci?
SSH into your router and issue following commands to download jquery-2.1.1.min.js at an appropriate location in the web directory of your device.
$ cd /www/luci-static/resources
$ wget http://code.jquery.com/jquery-2.1.1.min.js
Include the downloaded JQuery source in your HTML file as follows:
<script type="text/javascript" src="/luci-static/resources/jquery-2.1.1.min.js"></script>
That should do the trick!
Related
I am running into an issue where I am deploying a Blazor app that contains several public NuGet packages into a Linux Docker container. The container builds properly and adds the appropriate dll files of the packages into /app and /scr, but it isn't putting the js files into the wwwroot folder.
I can reproduce this with a minimal app by:
starting a new Blazor app with Docker support,
adding a public NuGet package (in this case, BlazorInputMask)
adding the calls to _Layout.cshtml for the js files
<script type="text/javascript" src="_content/BlazorInputMask/Main.js"></script>
<script type="text/javascript" src="_content/BlazorInputMask/IMask.js"></script>
Running the app locally using the Docker debugger
Checking the Network calls in the browser and seeing a 404 - Main.js not found
Checking the files in VS's Docker tools, and navigating to wwwroot, where Main.js and IMask.js are not found.
This works properly when doing a non-containerized build. It's just the container that is the problem.
The problem exists with the scaffolded Dockerfile generated by VS.
I tried laying out a Nuget.config file with the following code, but I got the same behavior:
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="wcmMapsSrc" value="." />
</packageSources>
Well, I found the problem!
There is a case mismatch between the NuGet package's docs and code base. In the docs, they reference Main.js but the filename is main.js.
This never presented a problem in any non-Dockerized deployment we have run, all of which have been Windows-based. However, when run through the Linux container there must be some case-sensitivity added.
Updating my codebase to reference the proper script file name solved the issue.
<script type="text/javascript" src="_content/BlazorInputMask/main.js"></script>
Turns out, not a NuGet concern. Leaving this here for others.
I have a React Native project where I'm trying to bundle some pre-generated HTML, JS, and CSS with the application, and have a WebView render the web assets using the react-native-community/react-native-webview library. I can load the index.html file just fine, but it won't load the other assets because it seems to be pointing to the wrong path. I've tried using baseUrl but it doesn't seem to work.
My React Native code looks like this:
<WebView
source={{ uri: './assets/index.html' }}
allowFileAccessFromFileURLs={true}
allowUniversalAccessFromFileURLs={true}
originWhitelist={["*"]}
mixedContentMode='always'
/>
And then as part of the build process, my assets directory has this structure:
ios
|- assets
|- index.html
|- js
|- main.js
|- css
|- main.css
I have this as part of the Copy Bundle Resources step in Xcode, so the assets directory is included with the ios app bundle.
Inside index.html is this code:
<html>
<head>
<link rel="stylesheet" href="/css/main.css">
</head>
<body>
Hello World!
<script type="text/javascript" src="/js/main.js"></script>
</body>
</html>
Going back to the original question, when I run this application, I can see the "Hello world!" so that tells me the HTML is loading, but the CSS and the JS files don't load because as far as I can tell it's trying to load from file:///assets/js/main.js instead of being relative to the app bundle location. Is there any way I can get this to work as desired?
I'd really, really like to avoid having to change the script src from /js/main.js if at all possible. The actual application I'm building auto-generates these files from a separate react project I have.
I have a sample minimal project that demonstrates this issue here:
https://github.com/jabbawookiees/psyduck
You can just clone this project then run the following if you want to try fixing it:
yarn install
cd ios && pod install && cd ..
yarn run react-native run-ios
What I ended up doing was bundling a web server with my iOS app and serving the resources from there.
https://github.com/futurepress/react-native-static-server
For example:
yarn add babel
bower install babel
I have application running without server (I don't plan to use NodeJS as my back-end). It is now pure-front-end double-click HTML file.
I tried to import browser.js into my HTML file to be able to process JSX.
Import with <script src="node_modules/babel-core/lib/api/browser.js"> does not work.
But, import with <script src="bower_components/babel/browser.js"> works.
Apparently, the codes are different. Since, Bower is dead and it suggests its users to use Yarn, how can the codes be different?
How can I use Yarn like I use Bower?
I have tested. There is no way ReactJS downloaded from package manager like Yarn or NPM work without server. At least any static-file server works.
In my case I ran yarn build, go to build directory, make sure the working directory is in the build folder, then run any server from there (root must be at the build folder). I use python3 -m http.server (because that is the only thing I conveniently use). I suppose you can use basic NodeJS HTTP as well.
I am not happy with the result, with fact that I can use CDN and Bower to serve React application as a single HTML file but I cannot do as such with React downloaded form the currently hip package manager.
First, it would be really nice if the stagehand "reversed text" Dart Polymer default example worked in all browsers.
Reading this > this, I changed the example's index.html to include the webcomponents line:
<body unresolved>
<main-app></main-app>
<script type="application/dart" src="index.dart"></script>
<script src="packages/browser/dart.js"></script>
<script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
</body>
I also downloaded the webcomponents zip and copied the js file to my project web folder and referenced it there. Clearly, I don't know what I'm doing. Do I need to change or add something to pubspec dependencies?
Thanks
Steve
There is the Dart web_components package that wraps web-components polyfills for Dart. Stagehand automatically adds the dependency to your pubspec.yaml.
After you run pub get or pub upgrade you can find the scripts in the packages/web_components/ directory.
Just add
<script src="web_componentsjs/webcomponents-lite.min.js"></script>
in the head of your entry page (not after the Dart script tag as shown in your question).
Stagehand is a community project. Please file an issue in the GitHub repo to add the script tag or create a pull request with the necessary changes.
I'm using yeoman's backbone generator, and I ran this:
bower install backbone.localStorage -S
And I manually had to insert this into index.html:
<script src="bower_components/backbone.localStorage/backbone.localStorage.js"></script>
Is there some way for bower to automatically insert <script> tags? I thought part of the benefit of bower was not having to figure out in which order to include your scripts?
Just run
grunt bowerInstall
after bower install
You can use wiredep to push dependencies into your HTML code from bower. This is the approach used by generator-angular when you run yo angular:
var wiredep = require('wiredep');
wiredep({
directory: 'app/bower_components',
bowerJson: JSON.parse(fs.readFileSync('./bower.json')),
ignorePath: 'app/',
htmlFile: 'app/index.html',
cssPattern: '<link rel="stylesheet" href="{{filePath}}">'
});
Bower won't add support for a specific function like this, but will soon allow you to specify an action to take after 'bower install'ing a new package. This will be called a "postinstall," similar to npm.
In the meantime, however, I have created a library to help with this. Since you're using yeoman, just add "grunt-bower-install" as an npm 'devDependency', then follow the instructions here: https://github.com/stephenplusplus/grunt-bower-install.
Use --save
bower install --save <YOUR_PACKAGE>
The --save option updates the bower.json file with dependencies. This will save you from having to manually add it to bower.json yourself. You'll see that the script section at the bottom of index.html has automatically updated.
Reference: http://yeoman.io/codelab/install-packages.html