Skip to content

Commit

Permalink
Patched version
Browse files Browse the repository at this point in the history
  • Loading branch information
jayantur13 committed Feb 18, 2023
1 parent 50b4c5f commit 00d40f8
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 41 deletions.
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

| Version | Date | Changelog |
| ------- | :------: | --------------: |
| 0.0.1 | 10-01-23 | Initial Release |
## 0.0.2 - _18.02.2023_

**Patched**

- justforlaughs.ext.setmyURL should work
- Only a single tab will show memes

## 0.0.1 - _10.01.2023_

**Release**

- Initial Release
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<a href="https://github.com/jayantur13/just-for-laughs-vsc-extension/issues"><img alt="GitHub issues" src="https://img.shields.io/github/issues/jayantur13/just-for-laughs-vsc-extension?style=flat-square"></a>
<a href="https://github.com/jayantur13/just-for-laughs-vsc-extension/pulls"><img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/jayantur13/just-for-laughs-vsc-extension?style=flat-square"></a>
<a href="https://github.com/jayantur13/just-for-laughs-vsc-extension/graphs/contributors"><img alt="GitHub contributors" src="https://img.shields.io/github/contributors/jayantur13/just-for-laughs-vsc-extension?style=flat-square"></a>
<h3 align="center"><b>Dive-in now and watch memes from around the world right into your VSCode workspace from reddit.</b></h3>
<h3 align="center"><b>Memes right into your VSCode workspace from reddit.</b></h3>
</p>
<p align="center"><a href="#features">Features</a> • <a href="#extension-settings">Settings</a> • <a href="#humble-note">Note</a> • <a href="#changelog">Changelog</a> • <a href="#contributing">Contributing</a></p>
</p>
Expand All @@ -16,15 +16,15 @@
## Features

- Memes based on set subreddit (using webviews)
- Memes based on set reddit (using webviews)
- In command palette type:
- `Just For Laughs: Meme` to get a meme
- `Just For Laughs: Set current URL` to update subreddit URL
- `Just For Laughs: Get current URL` to get current set URL
- `Just For Laughs: Get current URL` to get current set subreddit URL
- You may use keybinding Ctrl+P to get a meme (changeable)

> Demo
<img src="https://i.ibb.co/dGjh04B/demo.gif" alt="My cool logo"/>
> <img src="https://i.ibb.co/dGjh04B/demo.gif" alt="My cool logo"/>
## Extension Settings

Expand All @@ -40,6 +40,7 @@ Restart the extension for changes to take effect or use `Developer: Reload Windo

| Version | Date | Changelog |
| ------- | :------: | --------------: |
| 0.0.2 | 18-02-23 | Patched Version |
| 0.0.1 | 10-01-23 | Initial Release |

## Changelog
Expand All @@ -56,7 +57,6 @@ Please adhere to this project's [Code Of Conduct](https://github.com/jayantur13/

## Issues

- Need to manually close the meme tab(s) (Not a bug,VSCode api limitation)
- Write tests the ones present here sometimes fail (Contribute!)

## Support the project
Expand Down
68 changes: 47 additions & 21 deletions main/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {
} = require("vscode");
const { api } = require("./api");
let i = 0;
let panel;

// This method is called when your extension is activated
// Your extension is activated the very first time the command is executed
Expand All @@ -18,11 +19,14 @@ let i = 0;
* @param {vscode.ExtensionContext} context
*/
async function activate(context) {
const config = workspace.getConfiguration("justforlaughs.ext");
//In case if justforlaughs.get.URL: "" set it to default one
const config = workspace.getConfiguration(
"justforlaughs.ext",
ConfigurationTarget.Global
);
//In case if justforlaughs.get.subredditURL: "" set it to default one
if (config.has("subredditURL") && config.get("subredditURL") === "") {
config.update(
"URL",
"subredditURL",
"https://www.reddit.com/r/memes/new.json",
ConfigurationTarget.Global
);
Expand Down Expand Up @@ -64,15 +68,32 @@ async function activate(context) {
const getOne = data[i];
if (data[i] <= data[data.length - 1]) {
// Display a webview tab to the user
const panel = window.createWebviewPanel(
"memedose",
"Just for Laughs",
ViewColumn.One,
{} // Webview options. More on these later.
);

if (panel) {
// If we already have a panel, show it in the target column
panel.reveal();
} else {
// Otherwise, create a new panel
panel = window.createWebviewPanel(
"memedose",
"Just for Laughs",
ViewColumn.One,
{} // Webview options. More on these later.
);
}

//Favicon
panel.iconPath = Uri.joinPath(context.extensionUri, "", "images/logo.png");
panel.iconPath = Uri.joinPath(
context.extensionUri,
"",
"images/logo.png"
);

// Handle the webview being closed
panel.onDidDispose(() => {
panel = undefined;
});

//The actual webview that is shown to the user
panel.webview.html = `<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -115,7 +136,7 @@ async function activate(context) {
</html>`;
i++;
} else {
await window.showInformationMessage("Restarting..count.");
await window.showInformationMessage("Restart!");
i = 0;
}
}
Expand All @@ -124,8 +145,11 @@ async function activate(context) {
let getSetURL = commands.registerCommand(
"justforlaughs.ext.getsetURL",
async function () {
if (url !== "") {
await window.showInformationMessage("Your current url ", url);
if (config.has("subredditURL") && config.get("subredditURL") !== "") {
let url = await config.get("subredditURL");
if (url) {
await window.showInformationMessage("Your current url ", url);
}
}
}
);
Expand All @@ -140,19 +164,21 @@ async function activate(context) {
})
.then((val) => {
if (val) {
const config = workspace.getConfiguration("justforlaughs.ext");
const config = workspace.getConfiguration(
"justforlaughs.ext",
ConfigurationTarget.Global
);
//In case if in settings.json justforlaughs.get.URL: "",set to default url
//And if URL text field is empty and Enter key pressed,set to default url
if (config.has("subredditURL") && config.get("subredditURL") === "") {
config.update(
"URL",
"https://www.reddit.com/r/memes/new.json",
ConfigurationTarget.Global
);
if (
config.has("subredditURL") &&
config.get("subredditURL") !== ""
) {
config.update("subredditURL", val, ConfigurationTarget.Global);
window.showInformationMessage("Subreddit updated to " + val);
}
} else {
//Update nothing;ESC key pressed
window.showInformationMessage("Cancelled!");
}
});
}
Expand Down
27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "justforlaughs",
"displayName": "Just For Laughs",
"publisher": "JayantNavrange",
"description": "A slice of fun from subreddit",
"version": "0.0.1",
"description": "A slice of fun from reddit",
"version": "0.0.2",
"engines": {
"vscode": "^1.74.0"
"vscode": "^1.75.0"
},
"author": {
"name": "Jayant Navrange",
Expand All @@ -22,6 +22,9 @@
"bugs": {
"url": "https://github.com/jayantur13/just-for-laughs-vsc-extension/issues"
},
"sponsor": {
"url": "https://github.com/sponsors/jayantur13"
},
"keywords": [
"vscode-extension",
"extension",
Expand Down Expand Up @@ -58,7 +61,7 @@
"commands": [
{
"command": "justforlaughs.ext.getmeme",
"title": "Just For Laughs: Meme"
"title": "Just For Laughs: Get Meme"
},
{
"command": "justforlaughs.ext.getsetURL",
Expand All @@ -85,18 +88,18 @@
"test-coverage": "nyc --reporter=html --reporter=text mocha"
},
"devDependencies": {
"@types/glob": "^8.0.0",
"@types/glob": "^8.0.1",
"@types/mocha": "^10.0.1",
"@types/node": "18.11.18",
"@types/vscode": "^1.74.0",
"@vscode/test-electron": "^2.2.2",
"eslint": "^8.31.0",
"glob": "^8.0.3",
"@types/node": "18.14.0",
"@types/vscode": "^1.75.1",
"@vscode/test-electron": "^2.2.3",
"eslint": "^8.34.0",
"glob": "^8.1.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"typescript": "^4.9.4"
"typescript": "^4.9.5"
},
"dependencies": {
"axios": "^1.2.2"
"axios": "^1.3.3"
}
}

0 comments on commit 00d40f8

Please sign in to comment.