Skip to content

Commit 099e559

Browse files
committed
Merge pull request #155 from akollegger/style-by-url
style accepts raw grass or load via URL
2 parents 9ae4659 + 415b565 commit 099e559

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

app/scripts/init/commandInterpreters.coffee

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,29 @@ angular.module('neo4jApp')
6363
type: 'style'
6464
matches: "#{cmdchar}style"
6565
exec: [
66-
'$rootScope', 'exportService', 'GraphStyle',
67-
($rootScope, exportService, GraphStyle) ->
66+
'$rootScope', 'exportService', 'GraphStyle', '$http'
67+
($rootScope, exportService, GraphStyle, $http) ->
6868
(input, q) ->
6969
switch argv(input)[1]
7070
when 'reset'
7171
GraphStyle.resetToDefault()
7272
when 'export'
7373
exportService.download('graphstyle.grass', 'text/plain;charset=utf-8', GraphStyle.toString())
7474
else
75-
$rootScope.togglePopup('styling')
75+
clean_input = input[('style'.length+1)..].trim()
76+
if /^https?:\/\//i.test(clean_input)
77+
$http.get(clean_input)
78+
.then(
79+
(res) ->
80+
GraphStyle.importGrass(res.data)
81+
,
82+
(r)->
83+
console.log("failed to load grass, because ", r)
84+
)
85+
else if clean_input.length > 0
86+
GraphStyle.importGrass(clean_input)
87+
else
88+
$rootScope.togglePopup('styling')
7689
true
7790
]
7891

0 commit comments

Comments
 (0)