Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: web/apps/logdog-app/elements/routing.html

Issue 2543323004: Rewrite LogDog log viewer app. (Closed)
Patch Set: Control all fetch sizes, fix follow on initial click, fix small fetch when auth is retrid. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: web/apps/logdog-app/elements/routing.html
diff --git a/web/apps/logdog-app/elements/routing.html b/web/apps/logdog-app/elements/routing.html
index 1d99b473a8266cb903e8731dd0bce42371e8a76a..9eec0c1d540631d89f420bf61aff38bea5702495 100644
--- a/web/apps/logdog-app/elements/routing.html
+++ b/web/apps/logdog-app/elements/routing.html
@@ -14,7 +14,8 @@
// client-side router inspired by the Express router
// More info: https://visionmedia.github.io/page.js/
// Removes end / from app.baseUrl which page.base requires for production
- page.base(app.baseUrl);
+ var baseUrl = app.baseUrl;
+ page.base(baseUrl);
// Middleware
function scrollToTop(ctx, next) {
@@ -26,19 +27,36 @@
next();
}
+ // Hack to make this work on root-URL apps (e.g., localhost testing).
+ if ( baseUrl === "/" ) {
+ var oldReplace = page.replace;
+ page.replace = function(path, state, init, dispatch) {
+ if ( path.substring(0, 1) !== "/" ) {
+ path = "/" + path;
+ }
+ if ( path.substring(0, 3) !== "/#!" ) {
+ path = "/#!" + path;
+ }
+ return oldReplace(path, state, init, dispatch);
+ };
+ }
+
// Routes
- page('*', scrollToTop, closeDrawer, function(ctx, next) {
+ page("*", scrollToTop, closeDrawer, function(ctx, next) {
next();
});
- page('/', function() {
- app.route = 'root';
+
+ page("/", function() {
+ app.route = "root";
});
- page('/list/*', function(data) {
- app.route = 'list';
+
+ page("/list/*", function(data) {
+ app.route = "list";
app.$.list.base = logdog.correctStreamPath(data.params[0]);
});
- page('/stream/*', function(data) {
- app.route = 'stream';
+
+ page("/stream/*", function(data) {
+ app.route = "stream";
app.$.stream.streams = logdog.getQueryValues(data.querystring, "s").
map(logdog.correctStreamPath);
});
@@ -50,7 +68,7 @@
app.$.toast.show();
page.redirect(app.baseUrl);
});
- // add #! before urls
+
page({
hashbang: true,
});

Powered by Google App Engine
This is Rietveld 408576698