Comments (7)
HTML allows us to use relative URLs, which, by default, use the current location as the starting point. E.g.:
Current Location: https://app.com/some/where/far
Link href: "away" -> https://app.com/some/where/far/away
Link href: "../near" -> https://app.com/some/where/near
Link href: "/right-here" -> https://app.com/right-here
HTML also allows us setting the base
path. Similar to the proposed root_url
(which I'd suggest for it to be named base
instead, for consistency…)
Current Location: https://app.com/some/where/far
Base : /
Link href: "away" -> https://app.com/away
Link href: "../near" -> https://app.com/near (or 404, I can't remember correctly)
Link href: "/right-here" -> https://app.com/right-here
Nothing prevents us from using the templating approach as well, but that's not quite the same thing…
Edit: there are probably path resolution libs out there to help out.
from documentation.
It's not really a Jasonette solution, but I do all template expansion on the server and expanding relative URLs is trivial in python, the json tree is walked looking for any key that has an expected URL for a value and uses python's urlparse to rewrite the urls.
I'm not sure I grok the problem, why this would have edge cases or be difficult, the Jasonette code that fetches anything should look at the URL and if it's missing a scheme rewrite the URL in terms of either the view's origin URL $env.view.url or (in order) $cache.base, $global.base (and prohibit user variables from starting with underscore during json lint checking)
Then it doesn't matter if the url is generated by a template or hard coded in the json, it still works. Ideally Jasonette would pass this value in by default to the WebComponents so they too could share in the joys of relative urls
from documentation.
@gliechtenstein the reason I brought this up is for me its already difficult to cope with the workflow I set up of: quickly develop using a httpd on my local machine serving to apps run on emu, phone etc. Then once I'm happy, push it to "test" url for alpha test users, then next step I want is to be able to bundle into apk for deploy to Google Play. Currently that means having to have seperate git branches and do manual in-texteditor global search/replace or write a script to do that per @darenr suggestion.
Unfortuntatly given mixins and other urls (eg. for images) templates+$env.view.url is not enough.
My preference is definitely for your suggestion for resolving the url against the url of the current json as that would also better align with using mixins.
I'll get the original PR updated against current master as I need this functionality for my project right now anyway and resubmit.
from documentation.
I have started looking at this seriously. I do understand the problem (the JSON is not portable enough) but would like to understand the problem a bit better before moving forward.
Unfortuntatly given mixins and other urls (eg. for images) templates+$env.view.url is not enough.
@maks could you elaborate on this a bit? An example snippet that demonstrates how this is tricky would be really helpful.
from documentation.
@gliechtenstein Sorry yes, I should have provided concrete examples.
So for example I have a top-level jason like so:
{
"$jason" : {
"head" : {
"title" : "NGV Guide",
"description": "NGV Guide",
"icon" : "",
"actions" : {
"@" : "http://192.168.1.117:8080/actions.json"
},
"templates" : {
"@" : "http://192.168.1.117:8080/app-template.json"
},
"styles" : {
"@" : "http://192.168.1.117:8080/styles.json"
}
}
}
}
then in for example app-template.json I have more mixins to split out the body and footer, the body mixing then has urls to images that I use for image buttons, etc. Having to put the absolute url in all the files means if I want to go from testing locally (the urls with the IPs above) to eg testing on a server somewhere out on the net it all needs to change. Sure I could do tricks DNS tricks having overrides in my laptops hots file, but then thats doesn't work with a real phone I might test with. Even testing with the android emulator has issues when for instance I'm away from my home network, as I then need to use the emu's network bridge to localhost IP's (10.0.2.2) instead.
Hope that gives an idea of the issue here?
I have thought about just using a grep script to do the replacement each time I need to move between environments but it seems an annoying work around vs being able to support relative urls.
from documentation.
Hi all @maks @gliechtenstein , i downloaded the jasonette file to use to run my website on an android platform and i believe the xml form am to change the link to mine is the string.xml which i did but the website wont come up, it just keep on loading and never shows anything. And going through the tutorials i discovered there was a file named settings.plist where i could make some edits but i couldn't find the file in the zip folder i downloaded and also in the folder i deployed on my Android studio.
P.S: The website was written in json and used heroku as DB
from documentation.
@adefemi171 Please post this as a new issue on Android repo so we don't spam everyone on this thread.
Also please make sure to post:
- The JSON markup you're using
- Your device type
- Your OS version
- Your Android studio version
Especially make sure you post the code you're using, otherwise there's no way to figure out what's going wrong.
from documentation.
Related Issues (20)
- action for pin selected on map component HOT 2
- Send message from web containers to the parent app HOT 4
- Add connection type to $env HOT 2
- #each with index
- Call JS functions inside web containers from the parent app
- Clarify inline action vs regsitry based trigger gotcha
- Keyboard type HOT 8
- support file url in $network.upload
- Label component styling HOT 1
- Add body.style.align to documentation + more options
- Custom Events (push notification, websocket, geolocation, etc) HOT 3
- Event Logger HOT 8
- add core UI component for on-off (boolean) component
- [Request] Add ios and android attribute to options HOT 1
- Error: no implicit conversion of String into Integer HOT 2
- Errata in $util.datepicker actions documentation, formatting
- Dead link HOT 2
- Search for text on a website
- Porting 32-bit code to 64-bit
- Project Status
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from documentation.