GithubHelp home page GithubHelp logo

Comments (7)

gtramontina avatar gtramontina commented on August 18, 2024 4

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.

darenr avatar darenr commented on August 18, 2024

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.

maks avatar maks commented on August 18, 2024

@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.

gliechtenstein avatar gliechtenstein commented on August 18, 2024

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.

maks avatar maks commented on August 18, 2024

@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.

adefemi171 avatar adefemi171 commented on August 18, 2024

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.

gliechtenstein avatar gliechtenstein commented on August 18, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.