{"action":"created","comment":{"url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/comments/73338483","id":73338483,"diff_hunk":"@@ -721,80 +722,64 @@\n \n     <script>\n       (function() {\n+        function getParam(name){\n+          return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,\"\"])[1].replace(/\\+/g, '%20'))||null;\n+        }\n+\n+\n         // Make sure ajax is using cached requests\n         $.ajaxSetup({\n           cache: true\n         });\n-\n+ \n+        var adminUrlRegexp = new RegExp('${admin_url_regexp}');\n         var module = angular.module('geoadmin');\n         var cacheAdd = '${version}' != '' ? '/' + '${version}' : '';\n         var pathname = location.pathname.replace(/(index|mobile|embed)\\.html$/g, '');\n-\n-        function getParam(name){\n-          return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,\"\"])[1].replace(/\\+/g, '%20'))||null;\n+        var staging = 'prod';\n+        var testres = /^mf-geoadmin3\\.([a-z]+)\\.bgdi.ch$/.exec(location.hostname);\n+        if (testres && testres.length == 2) {\n+          staging = testres[1];\n         }\n+        var hasOverWrite = false;\n \n-        var adminUrlRegexp = new RegExp('${admin_url_regexp}');\n-        var wmsUrl = location.protocol + getParam('wms_url');\n-        wmsUrl = adminUrlRegexp.test(wmsUrl) ? wmsUrl : null;\n-\n-        var apiParam = getParam('api_url');\n-        var apiEnv = getParam('api_env');\n-        var apiUrlBase = '${api_url}';\n-\n-        if (apiEnv){\n-          if (apiEnv == 'prod'){\n-            host = '//api3.geo.admin.ch';\n-          } else {\n-            host = '//mf-chsdi3.' + apiEnv + '.bgdi.ch';\n+        function setBackend(prodUrl, techUrl, overWriteParam) {\n+          hasOverWrite = false;\n+          var url = prodUrl;\n+          if (staging != 'prod') {\n+            url = techUrl + staging + '.bgdi.ch';\n           }\n-        } else {\n-          host = '${api_url}';\n-        }\n-\n-        if (host.slice(-1) == '/'){\n-          host = host.slice(0, -1);\n-        }\n-\n-        if (apiParam){\n-          apiUrl = host + '/' + apiParam;\n-        } else {\n-          apiUrl = host;\n+          var overWrite = 'https://' + getParam(overWriteParam);\n+          hasOverWrite = adminUrlRegexp.test(overWrite);\n+          url = hasOverWrite ? overWrite : url;\n+          return url;\n         }\n \n-        var shopUrl = getParam('shop_url');\n-        var shopUrlBase = '${shop_url}';\n-\n-        if (shopUrl){\n-          shopUrl = shopUrl;\n-          if (shopUrl == 'dev' || shopUrl == 'int'){\n-            shopUrl = '//shop-bgdi.'+ shopUrl + '.bgdi.ch';\n-          } else if (shopUrl == 'prod'){\n-              shopUrl = '//beta.shop.swisstopo.ch';\n-          } else if (shopUrl == 'puzzle'){\n-              shopUrl = '//shop-shopbgdi.openshift.puzzle.ch';","path":"src/index.mako.html","position":116,"original_position":116,"commit_id":"d74ba8dc9d74ffc33ceff3acf455ffd1ebde7279","original_commit_id":"d74ba8dc9d74ffc33ceff3acf455ffd1ebde7279","user":{"login":"gjn","id":2572317,"avatar_url":"https://avatars.githubusercontent.com/u/2572317?v=3","gravatar_id":"","url":"https://api.github.com/users/gjn","html_url":"https://github.com/gjn","followers_url":"https://api.github.com/users/gjn/followers","following_url":"https://api.github.com/users/gjn/following{/other_user}","gists_url":"https://api.github.com/users/gjn/gists{/gist_id}","starred_url":"https://api.github.com/users/gjn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gjn/subscriptions","organizations_url":"https://api.github.com/users/gjn/orgs","repos_url":"https://api.github.com/users/gjn/repos","events_url":"https://api.github.com/users/gjn/events{/privacy}","received_events_url":"https://api.github.com/users/gjn/received_events","type":"User","site_admin":false},"body":"Yes.","created_at":"2016-08-03T13:33:37Z","updated_at":"2016-08-03T13:33:37Z","html_url":"https://github.com/geoadmin/mf-geoadmin3/pull/3402#discussion_r73338483","pull_request_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/3402","_links":{"self":{"href":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/comments/73338483"},"html":{"href":"https://github.com/geoadmin/mf-geoadmin3/pull/3402#discussion_r73338483"},"pull_request":{"href":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/3402"}}},"pull_request":{"url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/3402","id":77464145,"html_url":"https://github.com/geoadmin/mf-geoadmin3/pull/3402","diff_url":"https://github.com/geoadmin/mf-geoadmin3/pull/3402.diff","patch_url":"https://github.com/geoadmin/mf-geoadmin3/pull/3402.patch","issue_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/3402","number":3402,"state":"open","locked":false,"title":"[WIP] build once for dev/int/prod","user":{"login":"gjn","id":2572317,"avatar_url":"https://avatars.githubusercontent.com/u/2572317?v=3","gravatar_id":"","url":"https://api.github.com/users/gjn","html_url":"https://github.com/gjn","followers_url":"https://api.github.com/users/gjn/followers","following_url":"https://api.github.com/users/gjn/following{/other_user}","gists_url":"https://api.github.com/users/gjn/gists{/gist_id}","starred_url":"https://api.github.com/users/gjn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gjn/subscriptions","organizations_url":"https://api.github.com/users/gjn/orgs","repos_url":"https://api.github.com/users/gjn/repos","events_url":"https://api.github.com/users/gjn/events{/privacy}","received_events_url":"https://api.github.com/users/gjn/received_events","type":"User","site_admin":false},"body":"As discussed in https://github.com/geoadmin/mf-geoadmin3/pull/3142, this PR tries to configure the project and the index.html so that only one build is required for dev/int/prod. It moves the application configuration (definition of back-ends mainly) from build time to run-time.\r\n\r\nThis is unfinished work but the basic idea is working: the information in the rc_* files is not needed anymore for the application build. Backend definitions happen on load and depend on the URL under which the appliation is served. Most backends can be overwritten by a parameters for flexibility.\r\n\r\nThere are a few things missing:\r\n- appcache adaptions (I think they are needed)\r\n- robots.txt needs adaptions as well\r\n- maybe we need to add canonical name in html for SEO\r\n- not all backends have `ci` environment. this needs to be treated.\r\n- during dev, api should not only be staging dependant, but also point to user specific api (ltjeg points to ltjeg api)\r\n- ....others","created_at":"2016-07-14T14:20:23Z","updated_at":"2016-08-03T13:33:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da1f0781937b538a2f869ac7ad40a2808360e103","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/3402/commits","review_comments_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/3402/comments","review_comment_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/3402/comments","statuses_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/statuses/d74ba8dc9d74ffc33ceff3acf455ffd1ebde7279","head":{"label":"geoadmin:gjn_build_once","ref":"gjn_build_once","sha":"d74ba8dc9d74ffc33ceff3acf455ffd1ebde7279","user":{"login":"geoadmin","id":3369793,"avatar_url":"https://avatars.githubusercontent.com/u/3369793?v=3","gravatar_id":"","url":"https://api.github.com/users/geoadmin","html_url":"https://github.com/geoadmin","followers_url":"https://api.github.com/users/geoadmin/followers","following_url":"https://api.github.com/users/geoadmin/following{/other_user}","gists_url":"https://api.github.com/users/geoadmin/gists{/gist_id}","starred_url":"https://api.github.com/users/geoadmin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geoadmin/subscriptions","organizations_url":"https://api.github.com/users/geoadmin/orgs","repos_url":"https://api.github.com/users/geoadmin/repos","events_url":"https://api.github.com/users/geoadmin/events{/privacy}","received_events_url":"https://api.github.com/users/geoadmin/received_events","type":"Organization","site_admin":false},"repo":{"id":10399273,"name":"mf-geoadmin3","full_name":"geoadmin/mf-geoadmin3","owner":{"login":"geoadmin","id":3369793,"avatar_url":"https://avatars.githubusercontent.com/u/3369793?v=3","gravatar_id":"","url":"https://api.github.com/users/geoadmin","html_url":"https://github.com/geoadmin","followers_url":"https://api.github.com/users/geoadmin/followers","following_url":"https://api.github.com/users/geoadmin/following{/other_user}","gists_url":"https://api.github.com/users/geoadmin/gists{/gist_id}","starred_url":"https://api.github.com/users/geoadmin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geoadmin/subscriptions","organizations_url":"https://api.github.com/users/geoadmin/orgs","repos_url":"https://api.github.com/users/geoadmin/repos","events_url":"https://api.github.com/users/geoadmin/events{/privacy}","received_events_url":"https://api.github.com/users/geoadmin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/geoadmin/mf-geoadmin3","description":"map.geo.admin.ch source code","fork":false,"url":"https://api.github.com/repos/geoadmin/mf-geoadmin3","forks_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/forks","keys_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/teams","hooks_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/hooks","issue_events_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/events{/number}","events_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/events","assignees_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/assignees{/user}","branches_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/branches{/branch}","tags_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/tags","blobs_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/git/refs{/sha}","trees_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/statuses/{sha}","languages_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/languages","stargazers_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/stargazers","contributors_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/contributors","subscribers_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/subscribers","subscription_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/subscription","commits_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/commits{/sha}","git_commits_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/git/commits{/sha}","comments_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/comments{/number}","issue_comment_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/comments{/number}","contents_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/contents/{+path}","compare_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/merges","archive_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/downloads","issues_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues{/number}","pulls_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls{/number}","milestones_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/milestones{/number}","notifications_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/labels{/name}","releases_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/releases{/id}","deployments_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/deployments","created_at":"2013-05-31T06:37:20Z","updated_at":"2016-07-19T12:45:42Z","pushed_at":"2016-08-03T12:22:17Z","git_url":"git://github.com/geoadmin/mf-geoadmin3.git","ssh_url":"git@github.com:geoadmin/mf-geoadmin3.git","clone_url":"https://github.com/geoadmin/mf-geoadmin3.git","svn_url":"https://github.com/geoadmin/mf-geoadmin3","homepage":"http://map.geo.admin.ch","size":259810,"stargazers_count":93,"watchers_count":93,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":47,"mirror_url":null,"open_issues_count":108,"forks":47,"open_issues":108,"watchers":93,"default_branch":"master"}},"base":{"label":"geoadmin:master","ref":"master","sha":"fa7d891ea235ea8fd65c5b4408d1fc81767972dc","user":{"login":"geoadmin","id":3369793,"avatar_url":"https://avatars.githubusercontent.com/u/3369793?v=3","gravatar_id":"","url":"https://api.github.com/users/geoadmin","html_url":"https://github.com/geoadmin","followers_url":"https://api.github.com/users/geoadmin/followers","following_url":"https://api.github.com/users/geoadmin/following{/other_user}","gists_url":"https://api.github.com/users/geoadmin/gists{/gist_id}","starred_url":"https://api.github.com/users/geoadmin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geoadmin/subscriptions","organizations_url":"https://api.github.com/users/geoadmin/orgs","repos_url":"https://api.github.com/users/geoadmin/repos","events_url":"https://api.github.com/users/geoadmin/events{/privacy}","received_events_url":"https://api.github.com/users/geoadmin/received_events","type":"Organization","site_admin":false},"repo":{"id":10399273,"name":"mf-geoadmin3","full_name":"geoadmin/mf-geoadmin3","owner":{"login":"geoadmin","id":3369793,"avatar_url":"https://avatars.githubusercontent.com/u/3369793?v=3","gravatar_id":"","url":"https://api.github.com/users/geoadmin","html_url":"https://github.com/geoadmin","followers_url":"https://api.github.com/users/geoadmin/followers","following_url":"https://api.github.com/users/geoadmin/following{/other_user}","gists_url":"https://api.github.com/users/geoadmin/gists{/gist_id}","starred_url":"https://api.github.com/users/geoadmin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geoadmin/subscriptions","organizations_url":"https://api.github.com/users/geoadmin/orgs","repos_url":"https://api.github.com/users/geoadmin/repos","events_url":"https://api.github.com/users/geoadmin/events{/privacy}","received_events_url":"https://api.github.com/users/geoadmin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/geoadmin/mf-geoadmin3","description":"map.geo.admin.ch source code","fork":false,"url":"https://api.github.com/repos/geoadmin/mf-geoadmin3","forks_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/forks","keys_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/teams","hooks_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/hooks","issue_events_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/events{/number}","events_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/events","assignees_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/assignees{/user}","branches_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/branches{/branch}","tags_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/tags","blobs_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/git/refs{/sha}","trees_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/statuses/{sha}","languages_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/languages","stargazers_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/stargazers","contributors_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/contributors","subscribers_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/subscribers","subscription_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/subscription","commits_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/commits{/sha}","git_commits_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/git/commits{/sha}","comments_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/comments{/number}","issue_comment_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/comments{/number}","contents_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/contents/{+path}","compare_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/merges","archive_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/downloads","issues_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues{/number}","pulls_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls{/number}","milestones_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/milestones{/number}","notifications_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/labels{/name}","releases_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/releases{/id}","deployments_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/deployments","created_at":"2013-05-31T06:37:20Z","updated_at":"2016-07-19T12:45:42Z","pushed_at":"2016-08-03T12:22:17Z","git_url":"git://github.com/geoadmin/mf-geoadmin3.git","ssh_url":"git@github.com:geoadmin/mf-geoadmin3.git","clone_url":"https://github.com/geoadmin/mf-geoadmin3.git","svn_url":"https://github.com/geoadmin/mf-geoadmin3","homepage":"http://map.geo.admin.ch","size":259810,"stargazers_count":93,"watchers_count":93,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":47,"mirror_url":null,"open_issues_count":108,"forks":47,"open_issues":108,"watchers":93,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/3402"},"html":{"href":"https://github.com/geoadmin/mf-geoadmin3/pull/3402"},"issue":{"href":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/3402"},"comments":{"href":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/3402/comments"},"review_comments":{"href":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/3402/comments"},"review_comment":{"href":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/3402/commits"},"statuses":{"href":"https://api.github.com/repos/geoadmin/mf-geoadmin3/statuses/d74ba8dc9d74ffc33ceff3acf455ffd1ebde7279"}}}}
{"actor":{"display_login":"gjn"}}