Skip to content

Commit 80b25be

Browse files
authored
Merge pull request #193 from visualpython/release
Release v2.3.0 (Integrated version of all extension environments)
2 parents 0d0558c + 5c773cf commit 80b25be

File tree

468 files changed

+42509
-1081
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

468 files changed

+42509
-1081
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
jupyterlab/lib/visualpython

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Visual Python is an extension to Jupyter Lab, so you must have Jupyter Lab insta
3131

3232
### 2. How to Install
3333

34-
**1) Install package from**
34+
**1) Install package from PyPI**
3535
```
3636
pip install jupyterlab-visualpython
3737
```
@@ -50,7 +50,7 @@ Visual Python is an extension to Jupyter Notebook, so you must have Jupyter Note
5050

5151
### 2. How to Install
5252

53-
**1) Install package from**
53+
**1) Install package from PyPI**
5454
```
5555
pip install visualpython
5656
```
@@ -113,4 +113,4 @@ To create an environment where everyone can learn and use big data analytical sk
113113
Love Visual Python? <br>
114114
Your support will help us continue to actively develop and improve Visual Python.☕
115115

116-
<a href="https://www.buymeacoffee.com/visualpython" target="_blank"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=visualpython&button_colour=ffa238&font_colour=000000&font_family=Comic&outline_colour=000000&coffee_colour=FFDD00"></a>
116+
<a href="https://www.buymeacoffee.com/visualpython" target="_blank"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=visualpython&button_colour=ffa238&font_colour=000000&font_family=Comic&outline_colour=000000&coffee_colour=FFDD00"></a>

build.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
# Project Name : Visual Python
3+
# Description : GUI-based Python code generator
4+
# File Name : build.sh
5+
# Author : Black Logic - Minju
6+
# Note : Build Visual Python for All
7+
# License : GPLv3 (GNU General Public License v3.0)
8+
# Date : 2023. 02. 08
9+
# Change Date :
10+
#
11+
#=============================================================================
12+
# Set version and replace it
13+
#=============================================================================
14+
VP_ORG_VER=2.2.12
15+
VP_NEW_VER=2.3.0
16+
17+
# update version info
18+
grep -REil "VP_ORG_VER=.+$" colab/build.colab.sh jupyterlab/build.jupyterlab.sh jupyternotebook/build.jupyternotebook.sh | xargs sed -i "s/VP_ORG_VER=.\+$/VP_ORG_VER=${VP_ORG_VER}/g"
19+
grep -REil "VP_NEW_VER=.+$" colab/build.colab.sh jupyterlab/build.jupyterlab.sh jupyternotebook/build.jupyternotebook.sh | xargs sed -i "s/VP_NEW_VER=.\+$/VP_NEW_VER=${VP_NEW_VER}/g"
20+
21+
TEMP_PWD=$PWD
22+
23+
#=============================================================================
24+
# Build Visual Python for Colab
25+
#=============================================================================
26+
cd $TEMP_PWD/colab
27+
./build.colab.sh
28+
29+
#=============================================================================
30+
# Build Visual Python for Jupyter Notebook
31+
#=============================================================================
32+
cd $TEMP_PWD/jupyternotebook
33+
./build.jupyternotebook.sh
34+
35+
#=============================================================================
36+
# Build Visual Python for Jupyter Lab
37+
#=============================================================================
38+
cd $TEMP_PWD/jupyterlab
39+
./build.jupyterlab.sh
40+
41+
#=============================================================================
42+
# Upload (for maintainer only)
43+
#=============================================================================
44+
## jupyternotebook
45+
# python -m twine upload dist/jupyternotebook/dist/*
46+
47+
## jupyterlab
48+
# python -m twine upload dist/jupyterlab/*
49+
50+
## colab
51+
## upload on chrome web store with blacklogic.dev
52+
53+
exit 0
54+
55+
# End of file

colab/background.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//======================================================================
2+
// Event for extension icon - toggle
3+
//======================================================================
4+
chrome.action.onClicked.addListener((tab) => {
5+
// check origin if its url is matching our rule
6+
let checkOrigin = tab.url.startsWith('https://colab.research.google.com/');
7+
if (checkOrigin) {
8+
console.log('send toggle', checkOrigin, tab.id, tab);
9+
// send toggle action to content
10+
chrome.tabs.sendMessage(tab.id, { type: 'toggle' }).then(function(result) {
11+
// success
12+
console.log('ok', result);
13+
}).catch(function(result) {
14+
// error: if no content script, execute script again
15+
console.log('error', result);
16+
// execute script manually
17+
chrome.scripting.executeScript({
18+
target: { tabId: tab.id },
19+
files: ['content.js']
20+
}).then(function(result) {
21+
// toggle again
22+
chrome.tabs.sendMessage(tab.id, { type: 'toggle' });
23+
});
24+
});
25+
} else {
26+
console.log("it's not colab site...");
27+
}
28+
});
29+
30+
//======================================================================
31+
// Event for check tab to disable or enable extension
32+
//======================================================================
33+
// check status on tab activated and check colab exist
34+
chrome.tabs.onActivated.addListener(function() {
35+
chrome.tabs.query({ active: true, lastFocusedWindow: true }, function(tabs) {
36+
if (tabs && tabs.length > 0) {
37+
let tabUrl = tabs[0].url;
38+
let isColabExist = tabUrl.startsWith('https://colab.research.google.com/');
39+
if (isColabExist == true) {
40+
// reset
41+
// chrome.action.setBadgeText({ text: '' });
42+
chrome.action.setPopup({ popup: '' });
43+
} else {
44+
// set badge and popup
45+
// chrome.action.setBadgeBackgroundColor({ color: 'red' });
46+
// chrome.action.setBadgeText({ text: ':(' });
47+
chrome.action.setPopup({ popup: 'popup.html' });
48+
}
49+
}
50+
51+
});
52+
});
53+
// check status on tab updated
54+
chrome.tabs.onUpdated.addListener(function() {
55+
chrome.tabs.query({ active: true, lastFocusedWindow: true }, function(tabs) {
56+
if (tabs && tabs.length > 0) {
57+
let tabUrl = tabs[0].url;
58+
let isColabExist = tabUrl.startsWith('https://colab.research.google.com/');
59+
if (isColabExist == true) {
60+
// reset
61+
// chrome.action.setBadgeText({ text: '' });
62+
chrome.action.setPopup({ popup: '' });
63+
} else {
64+
// set badge and popup
65+
// chrome.action.setBadgeBackgroundColor({ color: 'red' });
66+
// chrome.action.setBadgeText({ text: ':(' });
67+
chrome.action.setPopup({ popup: 'popup.html' });
68+
}
69+
}
70+
71+
});
72+
});
73+
74+
// End of file

colab/build.colab.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# Project Name : Visual Python
3+
# Description : GUI-based Python code generator
4+
# File Name : build.colab.sh
5+
# Author : Black Logic - Minju
6+
# Note : Build Visual Python for Colab
7+
# License : GPLv3 (GNU General Public License v3.0)
8+
# Date : 2023. 02. 08
9+
# Change Date :
10+
#
11+
#=============================================================================
12+
# Replace Version
13+
#=============================================================================
14+
VP_ORG_VER=2.2.12
15+
VP_NEW_VER=2.3.0
16+
17+
# update version info
18+
# update manifest version with new numbering for new version
19+
grep -REil ${VP_ORG_VER//\./\\.}\.[0-9] manifest.json | xargs sed -i "s/${VP_ORG_VER//\./\\.}\.[0-9]/${VP_NEW_VER}.1/g"
20+
# update version inside visualpython package
21+
grep -REil ${VP_ORG_VER//\./\\.} visualpython/* | xargs sed -i --follow-symlinks "s/${VP_ORG_VER//\./\\.}/${VP_NEW_VER}/g"
22+
23+
#=============================================================================
24+
# Build output for Colab
25+
#=============================================================================
26+
# make directories to save build output
27+
mkdir -p ../dist/colab
28+
29+
# build package
30+
# sudo apt-get install zip
31+
zip -r ../dist/colab/visualpython-v$VP_NEW_VER.zip background.js content.js icon.png inject.js manifest.json visualpython
32+
33+
exit 0
34+
# End of file

colab/content.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//======================================================================
2+
// Inner functions
3+
//======================================================================
4+
/**
5+
* Send event to inject script
6+
* @param {*} type event type defined on inject script
7+
* @param {*} data data to send
8+
*/
9+
function sendEvent(type, data='') {
10+
let detailObj = { type: type, data: data };
11+
let evt = new CustomEvent('vpcomm', { bubbles: true, detail: detailObj });
12+
console.log('[vp content] send from content - ', type, data, evt);
13+
document.dispatchEvent(evt);
14+
15+
}
16+
function checkScriptExists(url) {
17+
return document.querySelectorAll(`script[src="${url}"]`).length > 0;
18+
}
19+
/**
20+
* Inject file
21+
*/
22+
function injectFile() {
23+
let url = chrome.runtime.getURL('inject.js');
24+
console.log('[vp content] check inject file...')
25+
if (checkScriptExists(url)) {
26+
console.log('[vp content] inject file already exist!');
27+
return false;
28+
}
29+
console.log('[vp content] inject file!');
30+
// inject script
31+
var s = document.createElement('script');
32+
s.src = url;
33+
s.onload = function() {
34+
// send event to inject.js to send its url
35+
var url = chrome.runtime.getURL('');
36+
// var evt = new CustomEvent('vpcomm', { bubbles: true, detail: { type: 'sendBase', data: url } });
37+
// document.dispatchEvent(evt);
38+
sendEvent('sendBase', url);
39+
};
40+
(document.head || document.documentElement).appendChild(s);
41+
return true;
42+
}
43+
44+
//======================================================================
45+
// Event listener - background <-> (content -> inject)
46+
//======================================================================
47+
function msgHandler(msg, sender) {
48+
if (msg && msg.type) {
49+
switch(msg.type) {
50+
case "toggle":
51+
injectFile();
52+
sendEvent('toggle');
53+
break;
54+
default:
55+
break;
56+
}
57+
}
58+
}
59+
chrome.runtime.onMessage.removeListener(msgHandler);
60+
chrome.runtime.onMessage.addListener(msgHandler);
61+
62+
console.log('[vp content] content script executed!');
63+
64+
// End of file

colab/icon-disable.png

1.67 KB
Loading
File renamed without changes.

colab/icon128.png

574 Bytes
Loading

0 commit comments

Comments
 (0)