Inject multiple javascript sources in nw.js - node-webkit

I'm trying to inject multiple scripts when the Window opens:
gui.Window.open (goToURL, {
focus: true,
position: 'center',
width: 1280,
height: 1024,
'inject-js-end': ['./js/script1.js', './js/script2.js']
});
So far no luck. Any ideas?

One possible solution for this is to combine both of your JS files into a single file using a tool like browserify.

Related

Picache gif is a still image (Expo + ReactNative)

I'm trying to speed up loading a bunch of gifs, but a big limitation is that I'm using Expo, and don't want to detach. I found Picache, which states it can be used just like react native Image. When the page loads though, everything loads super fast now, but the gifs are still and not 'gify'.
<Picache
source={{uri: someURL.gif)}}
style={{height: 300, width: 300, borderRadius: 10}}
/>
I've spent so long trynig to figure out how to speed up loading a bunch of images without detaching. Is there a way to make Picache work with gifs, or a similar easy way to implement?
**Before someone suggests, I've already tried... react-native-fast-image-expo but unfortunately it requires detaching as well. That is the desired package though.
If you don't want to bring out the project, you can replace it with this.
Until Expo added the module,
example:
import {Image} from "react-native-expo-image-cache";
// preview can be a local image or a data uri
const preview = { uri: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" };
const uri = "https://firebasestorage.googleapis.com/v0/b/react-native-e.appspot.com/o/b47b03a1e22e3f1fd884b5252de1e64a06a14126.png?alt=media&token=d636c423-3d94-440f-90c1-57c4de921641";
<Image style={{ height: 100, width: 100 }} {...{preview, uri}} />
Get the local image from a remote URI
import {CacheManager} from "react-native-expo-image-cache";
const {uri} = this.props;
const path = await CacheManager.get(uri).getPath();
// if path is undefined, the image download has failed

Trying to set Montserrat font on all pages of my React-Native App

I'm trying to apply the Montserrat font to all elements in my react-native app but can't seem to do it.
I've downloaded all 18 of the ttf files and put them into my assets/fonts folder.
I then tried using react-native-global-props:
import { setCustomText } from 'react-native-global-props';
const customTextProps = {
style: {
fontFamily: 'Montserrat'
}
}
setCustomText(customTextProps);
This didn't do anything to the text components of my app.
I then tried using defaultProps:
Text.defaultProps.style = { fontFamily: 'Montserrat' }
Also had no effect.
I also followed all the steps in this medium post about using custom fonts:
https://medium.com/react-native-training/react-native-custom-fonts-ccc9aacf9e5e
My main aim is to apply Montserrat font to every element of my entire app. I have a feeling it might have something to do with the font-type itself as Google Fonts say to apply fonts using this:
font-family: 'Montserrat', sans-serif;
However, react-native doesn't like the sans-serif as it has a hiphon so I just excluded it instead.
Any advice on this would be much appreciated.

Does anyone have examples of Google Street View working on Squarespace using the API?

Does anyone have examples of Google Street View working on Squarespace using the API?
I have been able to use other examples to display google maps (non street view) but when I try to get Google's street view example to work... nothing.
Here is my attempt:
http://keweenaw.squarespace.com/googlemapsapitest
I have this code in my page header code injection
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#street-view {
height: 100%;
}
</style>
<script>
var panorama;
function initialize() {
panorama = new google.maps.StreetViewPanorama(
document.getElementById('street-view'),
{
position: {lat: 37.869260, lng: -122.254811},
pov: {heading: 165, pitch: 0},
zoom: 1
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key= AIzaSyBSlsYgCGP7KfS5doe_q0X9guiJ3WNrfns&callback=initialize">
</script>
And this in a code block on the page:
<div id="street-view""></div>
You've got a number of issues which, once corrected, do in fact generate a working embedded Google Street View on a test Squarespace account.
You have a space at the beginning of your API key, causing it to be invalid.
You have an extra set of double quotes on <div id="street-view""></div>
Your CSS rule `#street-view {height: 100%;} won't work. Briefly put, you'll have to define a height in pixels, like "400px" or a similar 'fixed' unit.
You are loading the API over HTTPS but your site is HTTP. You need to either enable SSL on your Squarespace site or change the API url to http://maps.googleapis.com/maps/...etc. The prior is likely preferred.
By opening your browser's console (F12) you can see the specific error messages and work through them one by one (although, having seen these before certainly makes diagnosis faster).
To get you back on the right track, I would put the following code entirely in a code block on the page, where you want the map to appear. You can adjust width and height via your CSS. Once you get it working, you can experiment (if you choose) with moving your CSS to the CSS Editor and your Javascript to Code Injection.
<div id="street-view"></div>
<style>
#street-view {
height: 400px;
width: 100%;
}
</style>
<script>
var panorama;
function initialize() {
panorama = new google.maps.StreetViewPanorama(
document.getElementById('street-view'),
{
position: {lat: 37.869260, lng: -122.254811},
pov: {heading: 165, pitch: 0},
zoom: 1
}
);
}
</script>
<script async defer src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBSlsYgCGP7KfS5doe_q0X9guiJ3WNrfns&callback=initialize"></script>
Also, note that the code above is using HTTP for the Maps API so that it will work with your current configuration. If you choose to enable SSL as mentioned, you'll need to change the Maps API url to HTTPS.
Here is a working example, using HTTPS. This example will quit working soon.

Adjusting Context when using rallystandardreport

I'm utilizing the rally standard report to generate an iteration burndown, but given that i want post this on a wiki/web page. Looking for a way to point this to a project/subproject so that I can have several instances of this on one page. I tried it via context, but I'm obviously missing something. The code is below, any guidance/recommendation would be greatly appreciated!
Thanks!
Mark
Ext.create('Ext.Container', {
context : {
workspace : 'https://rally1.rallydev.com/slm/webservice/v2.0/workspace/50876644101',
project : 'https://rally1.rallydev.com/slm/webservice/v2.0/project/50891172431'
},
items: [{
xtype: 'rallystandardreport',
width: 750,
height: 500,
reportConfig: {
report: 'IterationBurndown',
subchart: 'hide',
title : 'IterationBurndown',
project : 'Harrier'
}
}],
renderTo: Ext.getBody().dom
});
You're on the right track. The StandardReport component was one of the earliest ones written and so it doesn't quite follow the standard ability to pass in a context like most of the rest of the SDK.
You're on the right path with the project config above- it just needs to be the ref of the project you're targeting rather than the name, and it goes right on the root component config instead of beneath reportConfig. There are also projectScopeUp and projectScopeDown.
There's also a full example here: https://help.rallydev.com/apps/2.0/doc/#!/example/standard-report
{
xtype: 'rallystandardreport',
width: 750,
height: 500,
reportConfig: {
report: 'IterationBurndown',
subchart: 'hide',
title : 'IterationBurndown'
},
project: '/project/12345',
projectScopeUp: false,
projectScopeDown: true
}

Ember view to display a PDF

In one of my views I would like to display a PDF, which is accesible via URL. This should be done without opening an extra tab in the browser, and without downloading the PDF (to view it outside the browser). It should be visible embedded within the Ember application.
What I have in mind is:
Use the URL to get the PDF and make it accessible to the ember application.
Use a special "PDF view" to display the PDF.
Is this possible? What options do I have to display an embedded PDF in an Ember application?
Displaying a PDF is not really related to ember, because to view a PDF you need a PDF plugin installed in your browser (which is mostly installed by default depending by the browser).
That said, a possible solution I could imagine could be to create a custom ember view with the tagName iframe on which you set the src attribute to the link referring to the PDF.
Example:
App.PDFView = Ember.View.extend({
tagName: 'iframe',
attributeBindings: ['src', 'width', 'height', 'frameborder'],
src: 'pdffile.pdf',
width: 800,
height: 600,
frameborder: 0
});
I've also used width, height and frameborder only for convenience so you can control some of the iframe's attributes easily from within ember. Here a working demo.
You can also go with something more elaborated and use a js lib like http://pdfobject.com/ which you then initialize in your view's didInsertElement hook:
App.PDFView = Ember.View.extend({
src: 'pdffile.pdf',
width: 800,
height: 600,
didInsertElement: function() {
new PDFObject({
url: this.get('src'),
width: this.get('width'),
height: this.get('height')}
).embed(this.get('elementId'));
}
});
(haven't tested the latter, but you get the point)
And then use this App.PDFView like a normal ember view in your templates.
{{view App.PDFView}}
Or your can set the src, width & height directly from within your template like
{{view App.PDFView src="pdffile.pdf" width="600" height="800"}}
Hope it helps.
You can certainly leverage the Ember PDFJS Addon by doing:
ember install ember-pdfjs
The README on GitHub describes the installation and use cases.
In short, the addon provides your Ember project with a component, pdf-document, which you can use in your HTMLBars template like so:
{{pdf-document src=[model.src]}}
... there are other permutations of what src can be (including a string file path, resource URI, or Uint8Array buffer).
If you don't see a feature that you need, please suggest in the Issues.