mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 15:08:12 -05:00
Automatic GistId recognition
This commit is contained in:
parent
9bb9319e33
commit
87f76aa795
@ -288,7 +288,12 @@ class ChromeSyncStorage extends OmegaTarget.Storage
|
||||
# param(withRemoteData) retrive gist file content
|
||||
##
|
||||
init: (args) ->
|
||||
gistId = args.gistId
|
||||
gistId = args.gistId || ''
|
||||
if gistId.indexOf('/') >= 0
|
||||
# get gistId from url `https://gist.github.com/{username}/{gistId}`
|
||||
gistId = gistId.replace(/\/+$/, '')
|
||||
gistId = gistId.split('/')
|
||||
gistId = gistId[gistId.length - 1]
|
||||
gistToken = args.gistToken
|
||||
return new Promise((resolve, reject) ->
|
||||
getLastCommit(gistId).then( (lastGistCommit) ->
|
||||
|
@ -2,6 +2,14 @@ angular.module('omega').controller 'IoCtrl', (
|
||||
$scope, $rootScope, $window, $http, omegaTarget, downloadFile
|
||||
) ->
|
||||
|
||||
getGistId = (gistUrl = '') ->
|
||||
# get gistId from url `https://gist.github.com/{username}/{gistId}`
|
||||
# or directly gistId
|
||||
gistId = gistUrl.replace(/\/+$/, '')
|
||||
gistId = gistId.split('/')
|
||||
gistId = gistId[gistId.length - 1]
|
||||
return gistId
|
||||
|
||||
omegaTarget.state([
|
||||
'web.restoreOnlineUrl',
|
||||
'gistId',
|
||||
@ -13,6 +21,7 @@ angular.module('omega').controller 'IoCtrl', (
|
||||
$scope.restoreOnlineUrl = url
|
||||
if gistId
|
||||
$scope.gistId = gistId
|
||||
$scope.gistUrl = "https://gist.github.com/" + getGistId(gistId)
|
||||
if gistToken
|
||||
$scope.gistToken = gistToken
|
||||
$scope.lastGistSync = new Date(lastGistSync or Date.now())
|
||||
|
@ -74,7 +74,7 @@ section.settings-group
|
||||
| {{'('}}
|
||||
| {{lastGistState}}
|
||||
| {{')'}}
|
||||
a(href="https://gist.github.com/{{gistId}}" role="button" target="_blank")
|
||||
a(href="{{gistUrl}}" role="button" target="_blank")
|
||||
| {{' '}}
|
||||
span.glyphicon.glyphicon-link
|
||||
br
|
||||
|
Loading…
Reference in New Issue
Block a user