Skip to content
This repository has been archived by the owner on Feb 24, 2022. It is now read-only.

Commit

Permalink
Version 1.4.0 (#24)
Browse files Browse the repository at this point in the history
* - added login panel
- added session
- added session checking
- added logout
- highlight OP in comments (#19)
- show root comments on default (#21)
- increase timeout for axios request (#22)
- added timeout setting
- added username to logout
- added user page
 - added collections to landing page
- added basic collection
- added media warning
- changed background color to default
  • Loading branch information
ekarbe authored Aug 29, 2019
1 parent 5d4e1c3 commit 9868683
Show file tree
Hide file tree
Showing 18 changed files with 704 additions and 131 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,17 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
## [1.3.4]

- Migrated to new vscode package structure
- Removed unused tests
- Removed unused tests

## [1.4.0]

- Added login panel
- Session cookie saves to globalState
- Added session checking
- Added logout
- Added request timeout setting
- Added user page
- Added option to disable user management
- Added basic collections
- Added media warning
- Changed background color
36 changes: 29 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,31 @@

### Sort the Subreddit

<img src="https://raw.githubusercontent.com/ekarbe/reddit-viewer/master/public/images/sort.gif" alt="Search gif">
<img src="https://raw.githubusercontent.com/ekarbe/reddit-viewer/master/public/images/sort.gif" alt="Sort gif">

### Open an article

<img src="https://raw.githubusercontent.com/ekarbe/reddit-viewer/master/public/images/article.gif" alt="Search gif">
<img src="https://raw.githubusercontent.com/ekarbe/reddit-viewer/master/public/images/article.gif" alt="Article gif">

### Browse comments

<img src="https://raw.githubusercontent.com/ekarbe/reddit-viewer/master/public/images/comment.gif" alt="Comment gif">

### Browse user pages

<img src="https://raw.githubusercontent.com/ekarbe/reddit-viewer/master/public/images/user.gif" alt="User gif">

### Choose a trending Subreddit

<img src="https://raw.githubusercontent.com/ekarbe/reddit-viewer/master/public/images/trend.gif" alt="Search gif">
<img src="https://raw.githubusercontent.com/ekarbe/reddit-viewer/master/public/images/trend.gif" alt="Trend gif">

### Login with your account

<img src="https://raw.githubusercontent.com/ekarbe/reddit-viewer/master/public/images/login.gif" alt="Login gif">

### Browse your collections

<img src="https://raw.githubusercontent.com/ekarbe/reddit-viewer/master/public/images/collection.gif" alt="Collection gif">

## Extension Settings

Expand All @@ -38,17 +54,17 @@ This extension contributes the following settings:
- `redditviewer.limitation`: Set the amount of articles to be loaded in a subreddit page
- `redditviewer.help`: enable/disable the help panel on the landing page
- `redditviewer.landingPage`: enable/disable the landing page
- `redditviewer.requestTimeout`: set the timeout for requests in ms
- `redditviewer.userManagement`: Set if the user management should be active. Deactivating this will disable login and all user related actions

## Known Issues

- Videos don't work
- Videos/Media don't work and cause crash
- Handle text formatting(Line break, inline) better

## Planned features

- Full video support
- Account Management -> Login, Voting etc.
- Extended comment loading
- Version 2.0 planning

## Release Notes

Expand Down Expand Up @@ -77,6 +93,12 @@ Initial release of Reddit-Viewer
- Added pagination
- Highlighting of sortation

### 1.4.0

- Added timeout setting
- Added user pages
- Added user management including login and collections

## Shoutout

Inspired/forked from [Gage77](https://github.com/Gage77)'s project [RedVis](https://github.com/Gage77/redvis)
133 changes: 124 additions & 9 deletions extension.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const vscode = require("vscode");
const path = require("path");
const creator = require("./src/creator");
const api = require("./src/api");
const logger = require("./src/logger");

let config = vscode.workspace.getConfiguration("redditviewer");
Expand All @@ -19,6 +20,27 @@ function activate(context) {
let disposable = vscode.commands.registerCommand(
"extension.reddit",
function() {
// create session object
let session = {
active: false,
username: context.globalState.get("activeUser"),
cookie: context.globalState.get("cookie")
};
// only if user management is active check for active session
if (config.userManagement) {
api
.checkSession(session.cookie)
.then(() => {
session.active = true;
})
.catch(() => {
session.active = false;
});
} else {
session.username = undefined;
session.cookie = undefined;
}

// create the window with title from config
let panel = vscode.window.createWebviewPanel(
"redditviewer",
Expand All @@ -41,7 +63,7 @@ function activate(context) {
// create the landing page if it's enabled in config
if (config.landingPage) {
creator
.createLandingpageView(config)
.createLandingpageView(config, session)
.then(response => {
panel.webview.html = response;
})
Expand All @@ -58,7 +80,8 @@ function activate(context) {
limit: config.limitation,
count: currentCount,
after: null,
before: null
before: null,
session: session
})
.then(response => {
panel.webview.html = response;
Expand All @@ -71,6 +94,8 @@ function activate(context) {
// handle messages from extension frontend
panel.webview.onDidReceiveMessage(
message => {
let explodedString;
let username;
switch (message.command) {
// go back to landing page by creating it new
case "homeView":
Expand All @@ -80,7 +105,7 @@ function activate(context) {
currentCount = 0;

creator
.createLandingpageView(config)
.createLandingpageView(config, session)
.then(response => {
panel.webview.html = response;
})
Expand All @@ -98,7 +123,21 @@ function activate(context) {
limit: config.limitation,
count: currentCount,
after: currentAfter,
before: currentBefore
before: currentBefore,
session: session
})
.then(response => {
panel.webview.html = response;
})
.catch(error => {
logger.error(error);
});
break;
case "collectionView":
creator
.createCollectionView({
collection: message.text,
cookie: session.cookie
})
.then(response => {
panel.webview.html = response;
Expand Down Expand Up @@ -126,7 +165,8 @@ function activate(context) {
limit: config.limitation,
count: currentCount,
after: currentAfter,
before: currentBefore
before: currentBefore,
session: session
})
.then(response => {
panel.webview.html = response;
Expand All @@ -152,7 +192,8 @@ function activate(context) {
limit: config.limitation,
count: currentCount,
after: currentAfter,
before: currentBefore
before: currentBefore,
session: session
})
.then(response => {
panel.webview.html = response;
Expand All @@ -178,7 +219,8 @@ function activate(context) {
limit: config.limitation,
count: currentCount,
after: currentAfter,
before: currentBefore
before: currentBefore,
session: session
})
.then(response => {
panel.webview.html = response;
Expand All @@ -191,6 +233,9 @@ function activate(context) {
case "article":
// message is subreddit,articleID
let data = message.text.split(",");
if (data[0] === "") {
data[0] = currentSubreddit;
}
creator
.createArticleView(data[0], data[1])
.then(response => {
Expand Down Expand Up @@ -218,7 +263,8 @@ function activate(context) {
limit: config.limitation,
count: currentCount,
after: currentAfter,
before: currentBefore
before: currentBefore,
session: session
})
.then(response => {
panel.webview.html = response;
Expand All @@ -241,10 +287,78 @@ function activate(context) {
limit: config.limitation,
count: currentCount,
after: currentAfter,
before: currentBefore
before: currentBefore,
session: session
})
.then(response => {
panel.webview.html = response;
})
.catch(error => {
logger.error(error);
});
break;
case "user":
// parse ref data
explodedString = message.text.split(",");
username = explodedString[0];
let view = explodedString[1];
let refLocation = explodedString[2];
let refID = explodedString[3];
creator
.createUserView({
username: username,
view: view,
refLocation: refLocation,
refID: refID
})
.then(response => {
panel.webview.html = response;
})
.catch(error => {
logger.error(error);
});
break;
case "login":
// parse login data
explodedString = message.text.split(",");
username = explodedString[0];
let password = explodedString[1];
api
.userLogin(username, password)
.then(response => {
// write cookie to globalState
session.active = true;
context.globalState.update("cookie", response);
session.cookie = response;
context.globalState.update("activeUser", username);
session.username = username;
creator
.createLandingpageView(config, session)
.then(response => {
panel.webview.html = response;
logger.info("Login successful");
})
.catch(error => {
logger.error(error);
});
})
.catch(() => {
logger.error("Login failed!");
});
break;
case "logout":
// remove cookie from globalState
session.active = false;
context.globalState.update("cookie", "");
session.cookie = undefined;
context.globalState.update("activeUser", undefined);
session.username = undefined;
// create Landingpage again
creator
.createLandingpageView(config, session)
.then(response => {
panel.webview.html = response;
logger.info("Logout successful");
})
.catch(error => {
logger.error(error);
Expand All @@ -268,6 +382,7 @@ function activate(context) {
currentAfter = null;
currentBefore = null;
currentCount = 0;
session.active = false;
});
// update configuration on change
vscode.workspace.onDidChangeConfiguration(change => {
Expand Down
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "reddit-viewer",
"displayName": "Reddit Viewer",
"description": "Browse Reddit in code style",
"version": "1.3.4",
"version": "1.4.0",
"publisher": "ekarbe",
"author": "Eike Christian Karbe <[email protected]>",
"engines": {
Expand Down Expand Up @@ -94,6 +94,18 @@
"type": "boolean",
"default": true,
"description": "Set if the landing page should be loaded on activation or the default subreddit should be loaded"
},
"redditviewer.requestTimeout": {
"type": "integer",
"default": 10000,
"minimum": 1000,
"maximum": 60000,
"description": "Set the timeout for requests in ms"
},
"redditviewer.userManagement": {
"type": "boolean",
"default": true,
"description": "Set if the user management should be active. Deactivating this will disable login and all user related actions"
}
}
}
Expand Down
Binary file modified public/images/article.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/collection.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/comment.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/login.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/search.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/sort.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/trend.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/user.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/reddit-viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ body {
letter-spacing: 0px;
font-size: 14px;
color: #cdd3de;
background-color: #1b2b34;
background-color: rgb(37,37,38);
}

::selection {
Expand Down
Loading

0 comments on commit 9868683

Please sign in to comment.