File tree Expand file tree Collapse file tree 1 file changed +23
-6
lines changed Expand file tree Collapse file tree 1 file changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -168,16 +168,33 @@ def self.clean_key(key)
168168class DocumentMacros
169169 def self . get_doc ( obj , args )
170170 doc_key = args [ 0 ]
171+ action = false
172+ domain = false
171173 if args . length == 2
172- edit = ( args [ 1 ] . strip == "edit" )
173- else
174- edit = false
174+ case args [ 1 ] . strip
175+ when "edit"
176+ action = "edit"
177+ when "view"
178+ action = "view"
179+ else /^[\w ]+(\. +[\w -])+/
180+ domain = args [ 1 ] . strip
181+ end
182+ end
183+ if args . length == 3
184+ domain = args [ 1 ] . strip if /^[\w ]+(\. +[\w -])+/ . match ( args [ 1 ] . strip )
185+ action = "edit" if args [ 2 ] . strip == "edit"
186+ action = "view" if args [ 2 ] . strip == "view"
175187 end
176188 if /^[\w -]+$/ . match ( doc_key )
177- if edit
178- url = "https://docs.google.com/document/d/#{ doc_key } /edit"
189+ if domain
190+ url = "https://docs.google.com/a/#{ domain } /document/"
191+ else
192+ url = "https://docs.google.com/document/"
193+ end
194+ if action
195+ url += "d/#{ doc_key } /#{ action } "
179196 else
180- url = "https://docs.google.com/document/d/ #{ doc_key } "
197+ url + = "pub?id= #{ doc_key } "
181198 end
182199 out = "<iframe src='#{ url } ' width='800' height='400'></iframe>"
183200 else
You can’t perform that action at this time.
0 commit comments