Action
Bear + Location
Bear 로 매일 일기쓰기
일일단위로 태그 분류
시간 및 장소 정보 추가.
Steps
-
script
// set googleMaps personal API key credential let credential = Credential.create("GoogleApiKey", "Enter your googleapis API key, https://cloud.google.com/maps-platform/"); credential.addTextField("GoogleApiKey", "API Key"); credential.authorize(); let api_key = credential.getValue("GoogleApiKey"); let getAddress = (latitude, longitude) => { let googleMapsReverseGeocodingURL = `https://maps.googleapis.com/maps/api/geocode/json?latlng=${latitude},${longitude}&key=${api_key}`; let http = HTTP.create(); let response = http.request({ "url": googleMapsReverseGeocodingURL, "method": "GET" }); if (response.statusCode != 200) { alert("!= 200"); context.fail(); console.log("API Error: " + response.error); return null; } // parse response JSON to object let data = JSON.parse(response.responseText); if (!data) { alert("!= data"); context.fail(); console.log("API Error: Unable to parse response"); return null; } return data; } let placeString; let globalPlusCode; let realLat = draft.processTemplate("[[latitude]]") let realLon = draft.processTemplate("[[longitude]]") let data = getAddress(realLat, realLon); if (data.status == "OK") { let firstResultFormattedAddress = data.results[0].formatted_address placeString = firstResultFormattedAddress globalPlusCode = data.plus_code.global_code } else { placeString = "장소정보 없음"; globalPlusCode = ""; } draft.setTemplateTag("placeInfo",placeString); draft.setTemplateTag("placeCode", globalPlusCode);
-
clipboard
template ### [[date|%H:%M]] [[placeCode]] ##### [[placeInfo]] [[draft]]
-
callbackUrl
template bear://x-callback-url/add-text?title=%23%ED%95%98%EB%A3%A8%EA%B8%B0%EB%A1%9D%2F[[date|%Y]]%2F[[date|%m]]%2F[[date|%d]]&text=[[clipboard]]&mode=append
waitForResponse true
encodeTags true
-
clipboard
template
Options
-
After Success Trash Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.