From c6845a798c99e96aa0e2f6daece0684a8ac50681 Mon Sep 17 00:00:00 2001
From: Christian Segundo
Date: Sun, 19 Nov 2023 16:21:29 +0100
Subject: wip
---
background.js | 16 ++
.../vim-handler.app/Contents/Info.plist | 87 ++++++++++
.../vim-handler.app/Contents/MacOS/applet | Bin 0 -> 134000 bytes
example-handlers/vim-handler.app/Contents/PkgInfo | 1 +
.../Contents/Resources/Scripts/main.scpt | Bin 0 -> 718 bytes
.../vim-handler.app/Contents/Resources/applet.icns | Bin 0 -> 71867 bytes
.../vim-handler.app/Contents/Resources/applet.rsrc | Bin 0 -> 362 bytes
.../Contents/Resources/description.rtfd/TXT.rtf | 5 +
.../Contents/_CodeSignature/CodeResources | 177 +++++++++++++++++++++
icons/vim.svg | 4 +
log | 3 +
manifest.json | 44 +++++
options.html | 14 ++
options.js | 61 +++++++
page_action.js | 13 ++
script.sh | 16 ++
storage.js | 12 ++
17 files changed, 453 insertions(+)
create mode 100644 background.js
create mode 100644 example-handlers/vim-handler.app/Contents/Info.plist
create mode 100755 example-handlers/vim-handler.app/Contents/MacOS/applet
create mode 100644 example-handlers/vim-handler.app/Contents/PkgInfo
create mode 100644 example-handlers/vim-handler.app/Contents/Resources/Scripts/main.scpt
create mode 100644 example-handlers/vim-handler.app/Contents/Resources/applet.icns
create mode 100644 example-handlers/vim-handler.app/Contents/Resources/applet.rsrc
create mode 100644 example-handlers/vim-handler.app/Contents/Resources/description.rtfd/TXT.rtf
create mode 100644 example-handlers/vim-handler.app/Contents/_CodeSignature/CodeResources
create mode 100644 icons/vim.svg
create mode 100644 log
create mode 100644 manifest.json
create mode 100644 options.html
create mode 100644 options.js
create mode 100644 page_action.js
create mode 100755 script.sh
create mode 100644 storage.js
diff --git a/background.js b/background.js
new file mode 100644
index 0000000..3035416
--- /dev/null
+++ b/background.js
@@ -0,0 +1,16 @@
+chrome.webNavigation.onCommitted.addListener(async details => {
+ // Check if the navigation is in the main frame
+ if (details.frameId !== 0) {
+ return;
+ }
+
+ // If the url is in the list of domains, show the page action
+ const domains = await StorageGetDomains();
+ for (let i = 0; i < domains.length; i++) {
+ if (details.url.includes(domains[i])) {
+ browser.pageAction.show(details.tabId);
+ return;
+ }
+ }
+});
+
diff --git a/example-handlers/vim-handler.app/Contents/Info.plist b/example-handlers/vim-handler.app/Contents/Info.plist
new file mode 100644
index 0000000..af0ad74
--- /dev/null
+++ b/example-handlers/vim-handler.app/Contents/Info.plist
@@ -0,0 +1,87 @@
+
+
+
+
+ CFBundleAllowMixedLocalizations
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ applet
+ CFBundleIconFile
+ applet
+ CFBundleIdentifier
+ com.apple.ScriptEditor.id.vim-handler
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ vim-handler
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSignature
+ aplt
+ CFBundleURLTypes
+
+
+ CFBundleURLName
+ HTTPS URL
+ CFBundleURLSchemes
+
+ https+vim
+
+
+
+ LSMinimumSystemVersionByArchitecture
+
+ x86_64
+ 10.6
+
+ LSRequiresCarbon
+
+ NSAppleEventsUsageDescription
+ This script needs to control other applications to run.
+ NSAppleMusicUsageDescription
+ This script needs access to your music to run.
+ NSCalendarsUsageDescription
+ This script needs access to your calendars to run.
+ NSCameraUsageDescription
+ This script needs access to your camera to run.
+ NSContactsUsageDescription
+ This script needs access to your contacts to run.
+ NSHomeKitUsageDescription
+ This script needs access to your HomeKit Home to run.
+ NSMicrophoneUsageDescription
+ This script needs access to your microphone to run.
+ NSPhotoLibraryUsageDescription
+ This script needs access to your photos to run.
+ NSRemindersUsageDescription
+ This script needs access to your reminders to run.
+ NSSiriUsageDescription
+ This script needs access to Siri to run.
+ NSSystemAdministrationUsageDescription
+ This script needs access to administer this system to run.
+ OSAAppletShowStartupScreen
+
+ WindowState
+
+ bundleDividerCollapsed
+
+ bundlePositionOfDivider
+ 0.0
+ dividerCollapsed
+
+ eventLogLevel
+ 2
+ name
+ ScriptWindowState
+ positionOfDivider
+ 419
+ savedFrame
+ 1023 165 700 678 0 0 1920 1055
+ selectedTab
+ description
+
+
+
diff --git a/example-handlers/vim-handler.app/Contents/MacOS/applet b/example-handlers/vim-handler.app/Contents/MacOS/applet
new file mode 100755
index 0000000..d3df3b9
Binary files /dev/null and b/example-handlers/vim-handler.app/Contents/MacOS/applet differ
diff --git a/example-handlers/vim-handler.app/Contents/PkgInfo b/example-handlers/vim-handler.app/Contents/PkgInfo
new file mode 100644
index 0000000..3253614
--- /dev/null
+++ b/example-handlers/vim-handler.app/Contents/PkgInfo
@@ -0,0 +1 @@
+APPLaplt
\ No newline at end of file
diff --git a/example-handlers/vim-handler.app/Contents/Resources/Scripts/main.scpt b/example-handlers/vim-handler.app/Contents/Resources/Scripts/main.scpt
new file mode 100644
index 0000000..3dea2a2
Binary files /dev/null and b/example-handlers/vim-handler.app/Contents/Resources/Scripts/main.scpt differ
diff --git a/example-handlers/vim-handler.app/Contents/Resources/applet.icns b/example-handlers/vim-handler.app/Contents/Resources/applet.icns
new file mode 100644
index 0000000..0cdd170
Binary files /dev/null and b/example-handlers/vim-handler.app/Contents/Resources/applet.icns differ
diff --git a/example-handlers/vim-handler.app/Contents/Resources/applet.rsrc b/example-handlers/vim-handler.app/Contents/Resources/applet.rsrc
new file mode 100644
index 0000000..f70b834
Binary files /dev/null and b/example-handlers/vim-handler.app/Contents/Resources/applet.rsrc differ
diff --git a/example-handlers/vim-handler.app/Contents/Resources/description.rtfd/TXT.rtf b/example-handlers/vim-handler.app/Contents/Resources/description.rtfd/TXT.rtf
new file mode 100644
index 0000000..49a9a1b
--- /dev/null
+++ b/example-handlers/vim-handler.app/Contents/Resources/description.rtfd/TXT.rtf
@@ -0,0 +1,5 @@
+{\rtf1\ansi\ansicpg1252\cocoartf2757
+\cocoatextscaling0\cocoaplatform0{\fonttbl}
+{\colortbl;\red255\green255\blue255;}
+{\*\expandedcolortbl;;}
+}
\ No newline at end of file
diff --git a/example-handlers/vim-handler.app/Contents/_CodeSignature/CodeResources b/example-handlers/vim-handler.app/Contents/_CodeSignature/CodeResources
new file mode 100644
index 0000000..e3d7f52
--- /dev/null
+++ b/example-handlers/vim-handler.app/Contents/_CodeSignature/CodeResources
@@ -0,0 +1,177 @@
+
+
+
+
+ files
+
+ Resources/Scripts/main.scpt
+
+ EETGMkBCn2b9FcPxvdc5upETs6k=
+
+ Resources/applet.icns
+
+ sINd6lbiqHD5dL8c6u79cFvVXhw=
+
+ Resources/applet.rsrc
+
+ YiCnW3ykdJlnp9Xukl/hn/ZZf80=
+
+ Resources/description.rtfd/TXT.rtf
+
+ gWdu82pZeO6+KzdO5i4KmnMvUYQ=
+
+
+ files2
+
+ Resources/Scripts/main.scpt
+
+ hash
+
+ EETGMkBCn2b9FcPxvdc5upETs6k=
+
+ hash2
+
+ LB2/m8n5BaEHBzlA96AhO6oR36uU08IkQzuhYZGkWhg=
+
+
+ Resources/applet.icns
+
+ hash
+
+ sINd6lbiqHD5dL8c6u79cFvVXhw=
+
+ hash2
+
+ J7weZ6vlnv9r32tS5HFcyuPXl2StdDnfepLxAixlryk=
+
+
+ Resources/applet.rsrc
+
+ hash
+
+ YiCnW3ykdJlnp9Xukl/hn/ZZf80=
+
+ hash2
+
+ /ft2GMgtnIjlClHI13vJnzISA4Lu74YZMO+IkeUyOtY=
+
+
+ Resources/description.rtfd/TXT.rtf
+
+ hash
+
+ gWdu82pZeO6+KzdO5i4KmnMvUYQ=
+
+ hash2
+
+ td6ORViAPbolKCyWzz9ZbT1kN11R0lSv7s84qe+itPQ=
+
+
+
+ rules
+
+ ^Resources/
+
+ ^Resources/.*\.lproj/
+
+ optional
+
+ weight
+ 1000
+
+ ^Resources/.*\.lproj/locversion.plist$
+
+ omit
+
+ weight
+ 1100
+
+ ^Resources/Base\.lproj/
+
+ weight
+ 1010
+
+ ^version.plist$
+
+
+ rules2
+
+ .*\.dSYM($|/)
+
+ weight
+ 11
+
+ ^(.*/)?\.DS_Store$
+
+ omit
+
+ weight
+ 2000
+
+ ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/
+
+ nested
+
+ weight
+ 10
+
+ ^.*
+
+ ^Info\.plist$
+
+ omit
+
+ weight
+ 20
+
+ ^PkgInfo$
+
+ omit
+
+ weight
+ 20
+
+ ^Resources/
+
+ weight
+ 20
+
+ ^Resources/.*\.lproj/
+
+ optional
+
+ weight
+ 1000
+
+ ^Resources/.*\.lproj/locversion.plist$
+
+ omit
+
+ weight
+ 1100
+
+ ^Resources/Base\.lproj/
+
+ weight
+ 1010
+
+ ^[^/]+$
+
+ nested
+
+ weight
+ 10
+
+ ^embedded\.provisionprofile$
+
+ weight
+ 20
+
+ ^version\.plist$
+
+ weight
+ 20
+
+
+
+
diff --git a/icons/vim.svg b/icons/vim.svg
new file mode 100644
index 0000000..ab134bb
--- /dev/null
+++ b/icons/vim.svg
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file
diff --git a/log b/log
new file mode 100644
index 0000000..8f8aa62
--- /dev/null
+++ b/log
@@ -0,0 +1,3 @@
+Received URL: https+vim://gitlab.otters.xyz/skkrty/metatron/-/blob/master/.gitlab-ci.yml?ref_type=heads
+Repo Path: skkrty/metatron
+Repo exists in local
diff --git a/manifest.json b/manifest.json
new file mode 100644
index 0000000..bffc6e2
--- /dev/null
+++ b/manifest.json
@@ -0,0 +1,44 @@
+// vim: ft=jsonc
+{
+ "manifest_version": 2,
+ "name": "GitLab local edit",
+ "version": "1.0",
+ "description": "Your editor, your rules",
+ "developer": {
+ "name": "Christian Segundo",
+ "url": "https://git.segundo.io/moz-glab-local-edit/"
+ },
+ "homepage_url": "https://git.segundo.io/moz-glab-local-edit/",
+ "permissions": [
+ "tabs",
+ "storage",
+ "webNavigation"
+ ],
+ "page_action": {
+ "default_title": "Open in ViM",
+ "default_icon": "icons/vim.svg"
+ },
+ "options_ui": {
+ "page": "options.html"
+ },
+ "background": {
+ "scripts": [
+ "storage.js",
+ "page_action.js",
+ "background.js"
+ ]
+ },
+ "browser_specific_settings": {
+ "gecko": {
+ "id": "moz-glab-local-edit@git.segundo.io"
+ }
+ }
+ //"icons": {
+ //"48": "icons/icon-48.png",
+ //"96": "icons/icon-96.png",
+ //"128": "icons/icon-128.png",
+ //"256": "icons/icon-256.png",
+ //"512": "icons/icon-512.png",
+ //"850": "icons/icon-850.png"
+ //}
+}
diff --git a/options.html b/options.html
new file mode 100644
index 0000000..f8d6b55
--- /dev/null
+++ b/options.html
@@ -0,0 +1,14 @@
+
+
+
+ Open in $x
+
+
+
+ GitLab Settings
+
+
+
+
+
+
diff --git a/options.js b/options.js
new file mode 100644
index 0000000..aa33ea1
--- /dev/null
+++ b/options.js
@@ -0,0 +1,61 @@
+document.addEventListener('DOMContentLoaded', function() {
+ const domainInput = document.getElementById('domainInput');
+ const addDomainButton = document.getElementById('addDomainButton');
+ const domainList = document.getElementById('domainList');
+
+ // Load the current list of domains
+ browser.storage.sync.get('domains', function(data) {
+ const domains = data.domains || [];
+ if (domains.length === 0) {
+ updateDomainList(["https://gitlab.com"]);
+ } else {
+ updateDomainList(domains);
+ }
+ });
+
+ // Function to update the displayed domain list
+ function updateDomainList(domains) {
+ domainList.innerHTML = '';
+ domains.forEach(function(domain) {
+ const li = document.createElement('li');
+ li.textContent = domain;
+
+ // Add a delete button for each domain
+ const deleteButton = document.createElement('button');
+ deleteButton.textContent = 'Delete';
+ deleteButton.addEventListener('click', function() {
+ // Remove the domain and update the list
+ const updatedDomains = domains.filter(d => d !== domain);
+ browser.storage.sync.set({ 'domains': updatedDomains }, function() {
+ updateDomainList(updatedDomains);
+ });
+ });
+
+ li.appendChild(deleteButton);
+ domainList.appendChild(li);
+ });
+ }
+
+
+ // Add domain button click event
+ addDomainButton.addEventListener('click', function() {
+ const domain = domainInput.value.trim();
+
+ if (domain !== '') {
+ // Update the list of domains
+ browser.storage.sync.get('domains', function(data) {
+ const domains = data.domains || [];
+ domains.push(domain);
+
+ // Save the updated list
+ browser.storage.sync.set({ 'domains': domains }, function() {
+ // Update the displayed list
+ updateDomainList(domains);
+
+ // Clear the input field
+ domainInput.value = '';
+ });
+ });
+ }
+ });
+});
diff --git a/page_action.js b/page_action.js
new file mode 100644
index 0000000..ccb7925
--- /dev/null
+++ b/page_action.js
@@ -0,0 +1,13 @@
+function handleClick(tab) {
+ const newUrl = tab.url.replace('https://', 'https+vim://');
+ console.log(newUrl);
+ newTab = browser.tabs.create({ url: newUrl });
+
+ // TODO: close the tab after it's been opened
+ // this doesn't work as it happens too fast and the app isn't open yet
+ //newTab.then(function(ntab) {
+ //browser.tabs.remove(ntab.id);
+ //})
+}
+
+browser.pageAction.onClicked.addListener(handleClick);
diff --git a/script.sh b/script.sh
new file mode 100755
index 0000000..690a06d
--- /dev/null
+++ b/script.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+GIT_HTTPS_URL="$1"
+
+cat /dev/null > /Users/christian.segundo/git/moz-glab-local-edit/log
+echo "Received URL: $GIT_HTTPS_URL" >> /Users/christian.segundo/git/moz-glab-local-edit/log
+repo_path=$(echo "$GIT_HTTPS_URL" | sed -E 's/https\+vim:\/\/gitlab.otters.xyz\/(.*)\/-\/.*/\1/')
+echo "Repo Path: $repo_path" >> /Users/christian.segundo/git/moz-glab-local-edit/log
+# if the path exists in ~/git/Cabify
+if [ -d "/Users/christian.segundo/git/Cabify/$repo_path" ]; then
+ echo "Repo exists in local" >> /Users/christian.segundo/git/moz-glab-local-edit/log
+else
+ echo "Repo doesn't exists in local" >> /Users/christian.segundo/git/moz-glab-local-edit/log
+fi
+
+# open vim in the 0 tmux sessions in a new tab
+tmux new-window -t 0 -n "$repo_path" "cd ~/git/Cabify/$repo_path && nvim ."
diff --git a/storage.js b/storage.js
new file mode 100644
index 0000000..d8964bf
--- /dev/null
+++ b/storage.js
@@ -0,0 +1,12 @@
+async function StorageGetDomains() {
+ const data = await browser.storage.sync.get('domains');
+ if (data.domains.length === 0) {
+ StorageUpdateDomainList(["https://gitlab.com"]);
+ return StorageGetDomains();
+ }
+ return data.domains;
+};
+
+async function StorageUpdateDomainList(domains) {
+ return browser.storage.sync.set({ 'domains': domains });
+}
--
cgit v1.2.3