Permalink
Browse files

Switched glimpse over to new URI template engine

  • Loading branch information...
1 parent 447e7f9 commit c65a1c83af7d03b557ea1ab503f3e6e32882bedb @avanderhoorn avanderhoorn committed Aug 1, 2012

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -71,15 +71,15 @@
var glimpseMetadata = {"environmentUrls":{"Dev":"http://localhost/","QA":"http://qa.getglimpse.com/","Prod":"http://getglimpse.com/"},
"version":[{name: 'core', current: '0.85', channel: 'dev'}, {name: 'glimpse.mvc', current: '0.85', channel: 'dev'}, {name: 'glimpse.webforms', current: '0.85', channel: 'dev'}],
"resources" : {
- "glimpse_request" : "Request?requestId={requestId}",
- "glimpse_ajax" : "Ajax?parentRequestId={parentRequestId}&ajaxResults={ajaxResults}",
- "glimpse_history" : "History?",
- "glimpse_tab" : "Tab?requestId={requestId}&pluginKey={pluginKey}",
- "glimpse_paging" : "Pager?key={key}&pageIndex={pageIndex}",
- "glimpse_config" : "Config",
- "glimpse_logo" : "logo.png",
- "glimpse_sprite" : "sprite.png",
- "glimpse_popup" : "test-popup.html"
+ "glimpse_request" : "Request?requestId={requestId}&version={version}{&Callback}",
+ "glimpse_ajax" : "Ajax?parentRequestId={parentRequestId}&version={version}{&Callback}",
+ "glimpse_history" : "History?version={version}{&top}{&Callback}",
+ "glimpse_tab" : "Tab?requestId={requestId}&pluginKey={pluginKey}&version={version}{&Callback}",
+ "glimpse_paging" : "Pager?key={key}&pageIndex={pageIndex}&version={version}{&Callback}",
+ "glimpse_config" : "Config?version={version}",
+ "glimpse_logo" : "logo.png?version={version}",
+ "glimpse_sprite" : "sprite.png?version={version}",
+ "glimpse_popup" : "test-popup.html?version={version}"
},
"plugins": {
"Paging":{"pagingInfo":{ pagerType : 'continuous', pageSize : 5, pageIndex : 0, totalNumberOfRecords : 31 }},
@@ -128,15 +128,15 @@
var glimpseMetadata = {"environmentUrls":{"Dev":"http://localhost/","QA":"http://qa.getglimpse.com/","Prod":"http://getglimpse.com/"},
"version":[{name: 'core', current: '0.85', channel: 'dev'}, {name: 'glimpse.mvc', current: '0.85', channel: 'dev'}, {name: 'glimpse.webforms', current: '0.85', channel: 'dev'}],
"resources" : {
- "glimpse_request" : "Request?requestId={requestId}",
- "glimpse_ajax" : "Ajax?parentRequestId={parentRequestId}&ajaxResults={ajaxResults}",
- "glimpse_history" : "History?",
- "glimpse_tab" : "Tab?requestId={requestId}&pluginKey={pluginKey}",
- "glimpse_paging" : "Pager?key={key}&pageIndex={pageIndex}",
- "glimpse_config" : "Config",
- "glimpse_logo" : "logo.png",
- "glimpse_sprite" : "sprite.png",
- "glimpse_popup" : "test-popup.html"
+ "glimpse_request" : "Request?requestId={requestId}&version={version}{&Callback}",
+ "glimpse_ajax" : "Ajax?parentRequestId={parentRequestId}&version={version}{&Callback}",
+ "glimpse_history" : "History?version={version}{&top}{&Callback}",
+ "glimpse_tab" : "Tab?requestId={requestId}&pluginKey={pluginKey}&version={version}{&Callback}",
+ "glimpse_paging" : "Pager?key={key}&pageIndex={pageIndex}&version={version}{&Callback}",
+ "glimpse_config" : "Config?version={version}",
+ "glimpse_logo" : "logo.png?version={version}",
+ "glimpse_sprite" : "sprite.png?version={version}",
+ "glimpse_popup" : "test-popup.html?version={version}"
},
"plugins": {
"Paging":{"pagingInfo":{ pagerType : 'continuous', pageSize : 5, pageIndex : 0, totalNumberOfRecords : 31 }},
@@ -120,6 +120,7 @@
<Content Include="UnitTests\Unit\glimpse.core.process.js" />
<Content Include="UnitTests\Unit\mock-glimpse.core.element.js" />
<Content Include="UnitTests\Unit\mock-glimpse.core.pubsub.js" />
+ <Content Include="uritemplate.min.js" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
@@ -4,7 +4,7 @@
pubsub.subscribe('state.build', build);
},
getCss = function() {
- return '<style type="text/css"> ' + template.css.replace(/url\(\)/gi, 'url(' + data.currentMetadata().resources.glimpse_sprite + ')') + ' </style>';
+ return '<style type="text/css"> ' + template.css.replace(/url\(\)/gi, 'url(' + util.replaceTokens(data.currentMetadata().resources.glimpse_sprite) + ')') + ' </style>';
},
getHtml = function() {
return template.html;
@@ -1,7 +1,7 @@
toolbarController = function () {
var //Support
isPopup = function() {
- return window.location.href.indexOf(data.currentMetadata().resources.glimpse_popup) > -1;
+ return window.location.href.indexOf(util.replaceTokens(data.currentMetadata().resources.glimpse_popup)) > -1;
},
wireListeners = function() {
pubsub.subscribe('action.open', function(topic, payload) { open(payload); });
@@ -33,7 +33,7 @@
util.cookie('glimpseKeepPopup', '1');
- var path = data.currentMetadata().resources.glimpse_popup,
+ var path = util.replaceTokens(data.currentMetadata().resources.glimpse_popup),
url = path + (path.indexOf('?') > -1 ? '&' : '?') + 'requestId=' + data.current().requestId;
window.open(url, 'GlimpsePopup', 'width=1100,height=600,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
},
@@ -1,4 +1,5 @@
/*(import:jquery-1.6.3.min.js)*/
+/*(import:uritemplate.min.js)*/
var glimpse = (function ($, scope) {
if (!window.console) { (window.console = {}).log = function () {}; }
@@ -71,34 +71,7 @@
that.scope = scope;
that.text = scope.find('span');
return that;
- },
- tokenizer = (function () {
- var results = {},
- pattern = /\{([a-zA-z0-9]*)\}+/ig,
- parse = function (input, data) {
- var tokens = results[input];
- if (!tokens) {
- tokens = results[input] = [];
- input.replace(pattern, function (a, b) {
- tokens.push(b);
- });
- }
-
- for (var tokenIndex in tokens) {
- var token = tokens[tokenIndex],
- value = data[token];
- if (value === undefined)
- value = '';
- input = input.replace('{' + token + '}', value);
- }
-
- return input;
- };
-
- return {
- parse : parse
- };
- })();
+ };
connectionNotice.prototype = {
connected : false,
@@ -215,6 +188,12 @@
return value + 'ms';
return Math.round(value / 10) / 100 + 's';
},
- replaceTokens: tokenizer.parse
+ replaceTokens: function (url, data) {
+ if (!data)
+ data = {};
+ if (!data.version)
+ data = $.extend({}, data, { version : 1.0 }); //TODO get version number from somewhere
+ return UriTemplate.parse(url).expand(data);
+ }
};
} ()

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -50,7 +50,7 @@
//Poll for updated summary data
notice.prePoll();
$.ajax({
- url: glimpse.data.currentMetadata().resources.glimpse_history,
+ url: glimpse.util.replaceTokens(glimpse.data.currentMetadata().resources.glimpse_history),
type: 'GET',
contentType: 'application/json',
complete : function(jqXHR, textStatus) {
@@ -1,9 +1,9 @@
<div class="glimpse-info-title">
- <a href="http://getGlimpse.com/" target="_blank"><img border="0" src="' + metadata.resources.glimpse_logo + '" /></a>
+ <a href="http://getGlimpse.com/" target="_blank"><img border="0" src="' + util.replaceTokens(metadata.resources.glimpse_logo) + '" /></a>
</div>
<div>v' + metadata.version[0].current + '</div>
<div class="glimpse-info-quote">"What Firebug is for the client, Glimpse is for the server"</div>
-<div class="glimpse-info-more">Go to your Glimpse Config page <a href="' + metadata.resources.glimpse_config + '" target="_blank">Glimpse.axd</a></div>
+<div class="glimpse-info-more">Go to your Glimpse Config page <a href="' + util.replaceTokens(metadata.resources.glimpse_config) + '" target="_blank">Glimpse.axd</a></div>
<div class="glimpse-info-more">For more info see <a href="http://getGlimpse.com" target="_blank">http://getGlimpse.com</a></div>
<div style="margin:1.5em 0 0.5em;">
Created by

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit c65a1c8

Please sign in to comment.