구글 앱 스크립트

위키백과, 우리 모두의 백과사전.

앱 스크립트
개발자구글
발표일2009년 8월 19일(14년 전)(2009-08-19)[1]
프로그래밍 언어자바스크립트
종류웹 프레임워크, 스크립팅 프레임워크
웹사이트script.google.com

앱 스크립트(Apps Script)는 구글 워크스페이스 플랫폼에서 가벼운 애플리케이션 개발을 위해 구글이 개발한 스크립팅 플랫폼이다. 구글 앱 스크립트는 처음에 마이크 함(Mike Harm)이 구글 시트의 개발자로서 일할 당시 부차적인 프로젝트로서 개발하였다.[2] 구글 앱 스크립트는 2009년 5월 베타 테스트 프로그램이 당시 구글 문서 제품 관리자 조나란 로첼에 의해 발표되었을 때 처음 발표되었다.[3] 2009년 8월 구글 앱 스크립트는 모든 구글 앱 프리미어 및 에듀케이션 에디션 고객들에게 이용이 가능해졌다.[4] 자바스크립트 1.6에 기반을 두지만 ECMA스크립트 5 API의 하위 집합 및 1.7, 1.8의 일부도 포함한다.[5] 앱 스크립트 프로젝트는 구글 인프라의 서버 사이드로 실행된다. 구글에 따르면 구글 스크립트는 구글 제품과 서드파티 서비스 간 태스크를 자동화하기 용이한 방법을 제공한다.[6] 앱 스크립트는 또한 구글 드라이브용 추가 기능을 제공하는 도구이기도 하다.[7]

예시[편집]

function doGet(e) {
  var searchTerm = 'Script Tools'
  var ui = XmlService.createDocument(XmlService.createElement('html')).setDocType(XmlService.createDocType('html'))
  var body = XmlService.createElement('body')
  body = buildTree(body, searchTerm);
  ui.getRootElement().addContent(body)
  return HtmlService.createHtmlOutput(XmlService.getRawFormat().format(ui))
}


function buildTree(node, searchTerm) {
  var ul = XmlService.createElement('ul').addContent(XmlService.createElement('p').addContent(XmlService.createText(searchTerm)));
  // Use of the Apps Script DriveApp Service to retrieve the collections.
  var folders = DriveApp.getFoldersByName(searchTerm).next().getFolders()
  while (folders.hasNext()){
    var thisFolder = folders.next();
    var li = XmlService.createElement('li');
    var resp = buildTree(li, thisFolder.getName())
    ul.addContent(li);
  }

  var files =  DriveApp.getFoldersByName(searchTerm).next().getFiles()
  while (files.hasNext()) {
    var thisFile = files.next()
    if (thisFile.getMimeType() === "application/vnd.google-apps.document") {
      urlBase = "https://docs.google.com/document/edit?id=";
      iconHTML = "https://drive-thirdparty.googleusercontent.com/32/type/application/vnd.google-apps.document";
    }
    else if (thisFile.getMimeType() === "application/vnd.google-apps.spreadsheet") {
      urlBase = "https://spreadsheets.google.com/ccc?key=";
      iconHTML = "https://drive-thirdparty.googleusercontent.com/32/type/application/vnd.google-apps.spreadsheet";
    }
    else if (thisFile.getMimeType() === "application/vnd.google-apps.script") {
      urlBase = "https://docs.google.com/fileview?id=";
      iconHTML = "https://drive-thirdparty.googleusercontent.com/32/type/application/vnd.google-apps.script";
    }
    else if (thisFile.getMimeType() === "application/vnd.google-apps.presentation") {
      urlBase = "https://docs.google.com/present/edit?id=";
      iconHTML = "https://drive-thirdparty.googleusercontent.com/32/type/application/vnd.google-apps.presentation";
    }
    else if (thisFile.getMimeType() === "application/vnd.google-apps.drawing") {
      urlBase = "https://docs.google.com/drawings/edit?id=";
      iconHTML = "https://drive-thirdparty.googleusercontent.com/32/type/application/vnd.google-apps.drawing";
    }
    else {
      urlBase = "https://docs.google.com/fileview?id=";
      iconHTML = "https://drive-thirdparty.googleusercontent.com/32/type/application/application/vnd.google-apps.unknown";
    }

    var li = XmlService.createElement('li');
    var image = XmlService.createElement('img').setAttribute('src', iconHTML);
    var fileLabel =  XmlService.createElement('a').setAttribute('href', urlBase + thisFile.getId())
                      .setAttribute('target', '_blank').addContent(XmlService.createText(thisFile.getName()))
    var fileLabelPanel = XmlService.createElement('div').setAttribute('style', 'display:flex;flex-direction: row;')
    fileLabelPanel.addContent(image)
    fileLabelPanel.addContent(fileLabel)
    li.addContent(fileLabelPanel)
    ul.addContent(li)
  }
  node.addContent(ul)
  return node;
}

같이 보기[편집]

각주[편집]

  1. Meyer, David (2009년 8월 20일). “Google Apps Script gets green light”. 《CNet》. 2012년 8월 10일에 원본 문서에서 보존된 문서. 2011년 3월 26일에 확인함. 
  2. Koleda, Eric (2019년 8월 21일). “Celebrating 10 years of Apps Script: looking back on how it started”. 《Google Cloud Blog》. 2019년 8월 22일에 확인함. 
  3. Rochelle, Jonathan (2009년 5월 27일). “Old tool, new tricks”. 《Google Cloud Blog》. 2019년 8월 22일에 확인함. 
  4. Levey, Evin (2009년 8월 19일). “Google Apps Script Launched to Google Apps Premier and Education”. 《Google Apps Script》. 2019년 8월 22일에 확인함. 
  5. Kienle, Holger (May–June 2010). “It's About Time to Take JavaScript (More) Seriously”. 《IEEE Software》 27 (3): 60–62. doi:10.1109/MS.2010.76. 2010년 6월 29일에 원본 문서에서 보존된 문서. 2011년 3월 25일에 확인함. 
  6. Google Apps Script
  7. Bring a little something extra to Docs and Sheets with add-ons

외부 링크[편집]