Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

WIP (do not merge!)- Type relative URIs, Template relative URIs #901

Closed
wants to merge 3 commits into from

Conversation

blois
Copy link

@blois blois commented Apr 14, 2014

Making template and CSS URIs relative to the library in which the type which is annotated resides. This resolves the template and CSS URIs against the type's location.

Also this leverages some code from Polymer to make the loaded HTML contents and CSS be relative to those files.

The two changes are separable, but I think it makes sense to at least discuss in parallel:

  • Annotation URIs are relative to the type which is being annotated.
  • URIs within templates and CSS are relative to those files.

Primary work remaining- support for the static case.

@blois
Copy link
Author

blois commented Apr 14, 2014

This work is to address #873

///
/// This converts URIs within a document from relative URIs to being absolute
/// URIs.
class AbsoluteUris {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a class if everything is static ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on how this code is to be exposed- if it's an internal utility (as it is now), then top-level methods are probably correct. If it becomes a part or is re-exported like the rest of the code here then there's too much pollution of the top-level namespaces and the class namespacing is cleaner.

I'm ambivalent and can change, primarily looking for feedback at this time on how URIs should behave.

@blois blois added cla: yes and removed cla: no labels Apr 14, 2014
/// https://github.com/Polymer/platform-dev/blob/896e245a0046a397bfc0190d958d2bd162e8f53c/src/url.js
///
/// This converts URIs within a document from relative URIs to being absolute
/// URIs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By convention we use /** ... */ for multi-line comments, would you mind switching ?

@mhevery
Copy link
Contributor

mhevery commented Apr 18, 2014

Is this blocked on anything? Could you walk me through this on VC?

@blois
Copy link
Author

blois commented Apr 18, 2014

Would be happy to walk through on VC, will try to explain some here for others as well.

The first part is that URIs on annotations are considered relative to the type on which the annotation resides. Basically it gets the URI of the type (actually the library) by using mirrors to get to LibraryMirror.uri, which it then combines to find the absolute URI. It then normalizes these package-relative URIs (currently to the form '/packages/'). URIs on types which are in web/ or test/ (non-package-relative) become relative to the entry point of the application.

This package normalization is important because I assume that there will need to be a separate uri resolver which translates from the normalized package syntax ('/packages/') to be non-root-relative- most likely relative to the location of the main script entry of the app.

Next part is making the URIs of HTML and CSS files be relative to their source locations. Currently it's doing it in two steps, the first step is parsing the HTML fragment within the context of a document with the base URI set to the original location of the HTML, second step is modifying all fragment-relative URIs to be absolute URIs (using the absolute_uri's lib).

Outstanding questions:

  • What should the normalized package URI syntax should be? The proposal is '/packages/', to allow this to work from HTML as well.
  • What's the best way to resolve the package-relative URIs? Should be able to have a default root-script-relative resolver for this.
  • Should the package-relative URI resolution also occur on the URIs fixed up by the absolute_uri lib? Seems like yes.

@cbracken also mentioned that he'd be interested in lending a hand on this, as he's currently running into a number of URI issues.

Pete Blois added 3 commits April 21, 2014 13:10
Making template and CSS URIs relative to the library in which the type which is annotated resides.

Also making all URIs within the template and CSS files be relative to those files.
- Changed AbsoluteUris to be top-level methods rather than all statics.
- Clarified unittest for Image by setting attributes rather than src directly.
- Changed multi-line comments format from /// to /** syntax
 - package-relative URIs are now 'packages/' rather than '/packages/'.
 - Support for mirrorless mode with a transformer. This transformer generates
   one large table for type->URI lookups.
 - Integrated with tip-of-tree Angular

This generates a global table of type to URI lookups
@blois
Copy link
Author

blois commented Apr 22, 2014

Further progress, mirrorless support is now in.

Remaining items:

  • Update expression extractor for type-relative URIs
  • Dart2JS bug hitting my test app which is causing some referenced methods to be discarded. Investigating.

@mhevery
Copy link
Contributor

mhevery commented Apr 23, 2014

Awesome progress sir.

On Mon, Apr 21, 2014 at 6:29 PM, blois [email protected] wrote:

Further progress, mirrorless support is now in.

Remaining items:

  • Update expression extractor for type-relative URIs
  • Dart2JS bug hitting my test app which is causing some referenced
    methods to be discarded. Investigating.


Reply to this email directly or view it on GitHubhttps://github.com//pull/901#issuecomment-40995165
.

@cbracken
Copy link
Contributor

I've got a working patch for the expression extractor on top of this (rebased to latest master) here:
https://github.com/cbracken/angular.dart/commits/type_relative_uris

@jbdeboer
Copy link
Contributor

@blois @cbracken Anything outstanding here? Can we take part of it?

@cbracken
Copy link
Contributor

My branch is pretty close to ready. I'll rebase and give a run through this afternoon.

@vicb
Copy link
Contributor

vicb commented Jul 21, 2014

Superseded by 1238 /cc @TedSander

@vicb vicb closed this Jul 21, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

5 participants