mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-02-02 02:58:13 -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
|
# param(withRemoteData) retrive gist file content
|
||||||
##
|
##
|
||||||
init: (args) ->
|
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
|
gistToken = args.gistToken
|
||||||
return new Promise((resolve, reject) ->
|
return new Promise((resolve, reject) ->
|
||||||
getLastCommit(gistId).then( (lastGistCommit) ->
|
getLastCommit(gistId).then( (lastGistCommit) ->
|
||||||
|
@ -2,6 +2,14 @@ angular.module('omega').controller 'IoCtrl', (
|
|||||||
$scope, $rootScope, $window, $http, omegaTarget, downloadFile
|
$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([
|
omegaTarget.state([
|
||||||
'web.restoreOnlineUrl',
|
'web.restoreOnlineUrl',
|
||||||
'gistId',
|
'gistId',
|
||||||
@ -13,6 +21,7 @@ angular.module('omega').controller 'IoCtrl', (
|
|||||||
$scope.restoreOnlineUrl = url
|
$scope.restoreOnlineUrl = url
|
||||||
if gistId
|
if gistId
|
||||||
$scope.gistId = gistId
|
$scope.gistId = gistId
|
||||||
|
$scope.gistUrl = "https://gist.github.com/" + getGistId(gistId)
|
||||||
if gistToken
|
if gistToken
|
||||||
$scope.gistToken = gistToken
|
$scope.gistToken = gistToken
|
||||||
$scope.lastGistSync = new Date(lastGistSync or Date.now())
|
$scope.lastGistSync = new Date(lastGistSync or Date.now())
|
||||||
|
@ -74,7 +74,7 @@ section.settings-group
|
|||||||
| {{'('}}
|
| {{'('}}
|
||||||
| {{lastGistState}}
|
| {{lastGistState}}
|
||||||
| {{')'}}
|
| {{')'}}
|
||||||
a(href="https://gist.github.com/{{gistId}}" role="button" target="_blank")
|
a(href="{{gistUrl}}" role="button" target="_blank")
|
||||||
| {{' '}}
|
| {{' '}}
|
||||||
span.glyphicon.glyphicon-link
|
span.glyphicon.glyphicon-link
|
||||||
br
|
br
|
||||||
|
Loading…
Reference in New Issue
Block a user