From 5c4ef785e7a0a485afe60840c5fdb7b0c755e2da Mon Sep 17 00:00:00 2001 From: Dooho Yi Date: Fri, 15 Jan 2021 03:31:15 +0900 Subject: [PATCH] added atom package for 'timestamp' generation! --- system/atom/iso8601-timestamp-mod/.npmignore | 3 + .../atom/iso8601-timestamp-mod/CHANGELOG.md | 5 ++ system/atom/iso8601-timestamp-mod/LICENSE.md | 20 ++++++ system/atom/iso8601-timestamp-mod/README.md | 10 +++ .../keymaps/iso8601-timestamp.cson | 12 ++++ .../lib/iso8601-timestamp-view.coffee | 22 +++++++ .../lib/iso8601-timestamp.coffee | 20 ++++++ .../menus/iso8601-timestamp.cson | 26 ++++++++ .../atom/iso8601-timestamp-mod/package.json | 52 ++++++++++++++++ .../spec/iso8601-timestamp-spec.coffee | 62 +++++++++++++++++++ .../spec/iso8601-timestamp-view-spec.coffee | 5 ++ .../styles/iso8601-timestamp.less | 8 +++ 12 files changed, 245 insertions(+) create mode 100644 system/atom/iso8601-timestamp-mod/.npmignore create mode 100644 system/atom/iso8601-timestamp-mod/CHANGELOG.md create mode 100644 system/atom/iso8601-timestamp-mod/LICENSE.md create mode 100644 system/atom/iso8601-timestamp-mod/README.md create mode 100644 system/atom/iso8601-timestamp-mod/keymaps/iso8601-timestamp.cson create mode 100644 system/atom/iso8601-timestamp-mod/lib/iso8601-timestamp-view.coffee create mode 100644 system/atom/iso8601-timestamp-mod/lib/iso8601-timestamp.coffee create mode 100644 system/atom/iso8601-timestamp-mod/menus/iso8601-timestamp.cson create mode 100644 system/atom/iso8601-timestamp-mod/package.json create mode 100644 system/atom/iso8601-timestamp-mod/spec/iso8601-timestamp-spec.coffee create mode 100644 system/atom/iso8601-timestamp-mod/spec/iso8601-timestamp-view-spec.coffee create mode 100644 system/atom/iso8601-timestamp-mod/styles/iso8601-timestamp.less diff --git a/system/atom/iso8601-timestamp-mod/.npmignore b/system/atom/iso8601-timestamp-mod/.npmignore new file mode 100644 index 0000000..ade14b9 --- /dev/null +++ b/system/atom/iso8601-timestamp-mod/.npmignore @@ -0,0 +1,3 @@ +.DS_Store +npm-debug.log +node_modules diff --git a/system/atom/iso8601-timestamp-mod/CHANGELOG.md b/system/atom/iso8601-timestamp-mod/CHANGELOG.md new file mode 100644 index 0000000..4fa7e76 --- /dev/null +++ b/system/atom/iso8601-timestamp-mod/CHANGELOG.md @@ -0,0 +1,5 @@ +## 0.1.1 - License author name correction + +## 0.1.0 - First Release +* Provides 'iso8601-timestamp:local' and 'iso8601-timestamp:iso' +* Provides context menu local time diff --git a/system/atom/iso8601-timestamp-mod/LICENSE.md b/system/atom/iso8601-timestamp-mod/LICENSE.md new file mode 100644 index 0000000..3cff72c --- /dev/null +++ b/system/atom/iso8601-timestamp-mod/LICENSE.md @@ -0,0 +1,20 @@ +Copyright (c) 2015 John Gerrard Holland + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/system/atom/iso8601-timestamp-mod/README.md b/system/atom/iso8601-timestamp-mod/README.md new file mode 100644 index 0000000..4c042c8 --- /dev/null +++ b/system/atom/iso8601-timestamp-mod/README.md @@ -0,0 +1,10 @@ +# a modified version of iso8601-timestamp package + +2 keyboard shortcuts available + +C-c C-d +C-c d + +manually install + +don't forget to npm install @ ~/.atom/packages/iso8601-timestamp-mod/ diff --git a/system/atom/iso8601-timestamp-mod/keymaps/iso8601-timestamp.cson b/system/atom/iso8601-timestamp-mod/keymaps/iso8601-timestamp.cson new file mode 100644 index 0000000..c1ae576 --- /dev/null +++ b/system/atom/iso8601-timestamp-mod/keymaps/iso8601-timestamp.cson @@ -0,0 +1,12 @@ +# Keybindings require three things to be fully defined: A selector that is +# matched against the focused element, the keystroke and the command to +# execute. +# +# Below is a basic keybinding which registers on all platforms by applying to +# the root workspace element. + +# For more detailed documentation see +# https://atom.io/docs/latest/behind-atom-keymaps-in-depth +'atom-workspace': + 'ctrl-c ctrl-d': 'iso8601-timestamp:iso' + 'ctrl-c d': 'iso8601-timestamp:local' diff --git a/system/atom/iso8601-timestamp-mod/lib/iso8601-timestamp-view.coffee b/system/atom/iso8601-timestamp-mod/lib/iso8601-timestamp-view.coffee new file mode 100644 index 0000000..7f97dbf --- /dev/null +++ b/system/atom/iso8601-timestamp-mod/lib/iso8601-timestamp-view.coffee @@ -0,0 +1,22 @@ +module.exports = +class Iso8601TimestampView + constructor: (serializedState) -> + # Create root element + @element = document.createElement('div') + @element.classList.add('iso8601-timestamp') + + # Create message element + message = document.createElement('div') + message.textContent = "The Iso8601Timestamp package is Alive! It's ALIVE!" + message.classList.add('message') + @element.appendChild(message) + + # Returns an object that can be retrieved when package is activated + serialize: -> + + # Tear down any state and detach + destroy: -> + @element.remove() + + getElement: -> + @element diff --git a/system/atom/iso8601-timestamp-mod/lib/iso8601-timestamp.coffee b/system/atom/iso8601-timestamp-mod/lib/iso8601-timestamp.coffee new file mode 100644 index 0000000..51e94c6 --- /dev/null +++ b/system/atom/iso8601-timestamp-mod/lib/iso8601-timestamp.coffee @@ -0,0 +1,20 @@ +Iso8601TimestampView = require './iso8601-timestamp-view' +{CompositeDisposable} = require 'atom' + +module.exports = Iso8601Timestamp = + + activate: -> + atom.commands.add 'atom-workspace', "iso8601-timestamp:iso", => @iso() + atom.commands.add 'atom-workspace', "iso8601-timestamp:local", => @local() + + iso: -> + editor = atom.workspace.getActivePaneItem() + moment = require 'moment' + iso_time = moment().format('YYYYMMDDTHHmmssZZ_') + editor.insertText(iso_time) + + local: -> + editor = atom.workspace.getActivePaneItem() + moment = require 'moment' + local_time = moment().format('YYYY/MM/DD, HH:mm:ss, ZZ') + editor.insertText(local_time) diff --git a/system/atom/iso8601-timestamp-mod/menus/iso8601-timestamp.cson b/system/atom/iso8601-timestamp-mod/menus/iso8601-timestamp.cson new file mode 100644 index 0000000..9788010 --- /dev/null +++ b/system/atom/iso8601-timestamp-mod/menus/iso8601-timestamp.cson @@ -0,0 +1,26 @@ +# See https://atom.io/docs/latest/hacking-atom-package-word-count#menus for more details +'context-menu': + 'atom-text-editor': [ + { + 'label': 'Insert ISO 8601 local time' + 'command': 'iso8601-timestamp:local' + } + ] +'menu': [ + { + 'label': 'Packages' + 'submenu': [ + 'label': 'ISO 8601 timestamp' + 'submenu': [ + { + 'label': 'Insert ISO time' + 'command': 'iso8601-timestamp:iso' + }, + { + 'label': 'Insert local time' + 'command': 'iso8601-timestamp:local' + } + ] + ] + } +] diff --git a/system/atom/iso8601-timestamp-mod/package.json b/system/atom/iso8601-timestamp-mod/package.json new file mode 100644 index 0000000..c040332 --- /dev/null +++ b/system/atom/iso8601-timestamp-mod/package.json @@ -0,0 +1,52 @@ +{ + "_from": "https://www.atom.io/api/packages/iso8601-timestamp/versions/0.1.1/tarball", + "_id": "iso8601-timestamp@0.1.1", + "_inBundle": false, + "_integrity": "sha512-z/g3Ix3BDxaCruSUaGKLvK/0aVPVyPcjJanVDe+7HBvFrL4In9wAgegEtB9ni+jIMuRhCgM6YJmMdAGp9kyD9Q==", + "_location": "/iso8601-timestamp", + "_phantomChildren": {}, + "_requested": { + "type": "remote", + "raw": "https://www.atom.io/api/packages/iso8601-timestamp/versions/0.1.1/tarball", + "rawSpec": "https://www.atom.io/api/packages/iso8601-timestamp/versions/0.1.1/tarball", + "saveSpec": "https://www.atom.io/api/packages/iso8601-timestamp/versions/0.1.1/tarball", + "fetchSpec": "https://www.atom.io/api/packages/iso8601-timestamp/versions/0.1.1/tarball" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://www.atom.io/api/packages/iso8601-timestamp/versions/0.1.1/tarball", + "_shasum": "b4b2663b1f226415fb1e46e337950bd9f87f1ae6", + "_spec": "https://www.atom.io/api/packages/iso8601-timestamp/versions/0.1.1/tarball", + "_where": "/tmp/apm-install-dir-2021015-40948-1qub7ma.hfmtf", + "activationCommands": { + "atom-workspace": [ + "iso8601-timestamp:iso", + "iso8601-timestamp:local" + ] + }, + "bugs": { + "url": "https://github.com/hollandjg/iso8601-timestamp/issues" + }, + "bundleDependencies": false, + "dependencies": { + "moment": "2.10.6", + "moment-timezone": "0.4.0" + }, + "deprecated": false, + "description": "Atom package to insert ISO 8601 compliant timestamps", + "engines": { + "atom": ">=1.0.0 <2.0.0" + }, + "homepage": "https://github.com/hollandjg/iso8601-timestamp#readme", + "keywords": [], + "license": "MIT", + "main": "./lib/iso8601-timestamp", + "name": "iso8601-timestamp", + "repository": { + "type": "git", + "url": "git+https://github.com/hollandjg/iso8601-timestamp.git" + }, + "version": "0.1.1" +} diff --git a/system/atom/iso8601-timestamp-mod/spec/iso8601-timestamp-spec.coffee b/system/atom/iso8601-timestamp-mod/spec/iso8601-timestamp-spec.coffee new file mode 100644 index 0000000..92763ff --- /dev/null +++ b/system/atom/iso8601-timestamp-mod/spec/iso8601-timestamp-spec.coffee @@ -0,0 +1,62 @@ +Iso8601Timestamp = require '../lib/iso8601-timestamp' + +# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. +# +# To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` +# or `fdescribe`). Remove the `f` to unfocus the block. + +describe "Iso8601Timestamp", -> + [workspaceElement, activationPromise] = [] + + beforeEach -> + workspaceElement = atom.views.getView(atom.workspace) + activationPromise = atom.packages.activatePackage('iso8601-timestamp') + + describe "when the iso8601-timestamp:toggle event is triggered", -> + it "hides and shows the modal panel", -> + # Before the activation event the view is not on the DOM, and no panel + # has been created + expect(workspaceElement.querySelector('.iso8601-timestamp')).not.toExist() + + # This is an activation event, triggering it will cause the package to be + # activated. + atom.commands.dispatch workspaceElement, 'iso8601-timestamp:toggle' + + waitsForPromise -> + activationPromise + + runs -> + expect(workspaceElement.querySelector('.iso8601-timestamp')).toExist() + + iso8601TimestampElement = workspaceElement.querySelector('.iso8601-timestamp') + expect(iso8601TimestampElement).toExist() + + iso8601TimestampPanel = atom.workspace.panelForItem(iso8601TimestampElement) + expect(iso8601TimestampPanel.isVisible()).toBe true + atom.commands.dispatch workspaceElement, 'iso8601-timestamp:toggle' + expect(iso8601TimestampPanel.isVisible()).toBe false + + it "hides and shows the view", -> + # This test shows you an integration test testing at the view level. + + # Attaching the workspaceElement to the DOM is required to allow the + # `toBeVisible()` matchers to work. Anything testing visibility or focus + # requires that the workspaceElement is on the DOM. Tests that attach the + # workspaceElement to the DOM are generally slower than those off DOM. + jasmine.attachToDOM(workspaceElement) + + expect(workspaceElement.querySelector('.iso8601-timestamp')).not.toExist() + + # This is an activation event, triggering it causes the package to be + # activated. + atom.commands.dispatch workspaceElement, 'iso8601-timestamp:toggle' + + waitsForPromise -> + activationPromise + + runs -> + # Now we can test for view visibility + iso8601TimestampElement = workspaceElement.querySelector('.iso8601-timestamp') + expect(iso8601TimestampElement).toBeVisible() + atom.commands.dispatch workspaceElement, 'iso8601-timestamp:toggle' + expect(iso8601TimestampElement).not.toBeVisible() diff --git a/system/atom/iso8601-timestamp-mod/spec/iso8601-timestamp-view-spec.coffee b/system/atom/iso8601-timestamp-mod/spec/iso8601-timestamp-view-spec.coffee new file mode 100644 index 0000000..80962da --- /dev/null +++ b/system/atom/iso8601-timestamp-mod/spec/iso8601-timestamp-view-spec.coffee @@ -0,0 +1,5 @@ +Iso8601TimestampView = require '../lib/iso8601-timestamp-view' + +describe "Iso8601TimestampView", -> + it "has one valid test", -> + expect("life").toBe "easy" diff --git a/system/atom/iso8601-timestamp-mod/styles/iso8601-timestamp.less b/system/atom/iso8601-timestamp-mod/styles/iso8601-timestamp.less new file mode 100644 index 0000000..024d3e2 --- /dev/null +++ b/system/atom/iso8601-timestamp-mod/styles/iso8601-timestamp.less @@ -0,0 +1,8 @@ +// The ui-variables file is provided by base themes provided by Atom. +// +// See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less +// for a full listing of what's available. +@import "ui-variables"; + +.iso8601-timestamp { +}