Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usability tweak #140

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jarr/api/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
'date': fields.DateTime()})
content_model = cluster_ns.model('ComplexContent', {
'type': fields.String(required=True),
'title': fields.String(),
'content': fields.String(),
'comments': fields.String(),
'link': fields.String(),
Expand Down
1 change: 0 additions & 1 deletion jarr/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# required imports and code exection for basic functionning

import logging
import random
from redis import Redis

from sqlalchemy import create_engine
Expand Down
3 changes: 0 additions & 3 deletions jarr/controllers/user.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import logging
from datetime import timedelta

from werkzeug.security import check_password_hash, generate_password_hash

from jarr.bootstrap import conf
from jarr.lib.utils import utc_now
from jarr.models import User

from .abstract import AbstractController
Expand Down
4 changes: 4 additions & 0 deletions jarr/lib/content_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
from functools import lru_cache

import requests
from goose3 import Goose
from lxml import etree
import urllib.parse
Expand Down Expand Up @@ -82,6 +83,7 @@ def generate(self):
text = self.article.title or self.article.content
content = {'type': self.article.article_type.value,
'alt': html.escape(text[:IMG_ALT_MAX_LENGTH]),
'title': self.article.title,
'src': self.article.link}
return True, content

Expand All @@ -99,6 +101,7 @@ def generate(self):
'from article', self.article)
try:
return True, {'type': self.article.article_type.value,
'title': self.article.title,
'player': 'youtube',
'videoId': yt_match.group(5)}
except IndexError:
Expand All @@ -118,6 +121,7 @@ def generate(self):
try:
content['content'] = self._from_goose_to_html()
content['link'] = self._page.final_url
content['title'] = getattr(self._page, 'title', self.article.title)
success = True
except Exception:
logger.exception("Could not rebuild parsed content for %r",
Expand Down
2 changes: 1 addition & 1 deletion jarr/lib/html_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from jarr.bootstrap import conf
from jarr.lib.const import FEED_MIMETYPES
from jarr.lib.utils import clean_lang, jarr_get, rebuild_url
from jarr.lib.utils import jarr_get, rebuild_url

logger = logging.getLogger(__name__)
CHARSET_TAG = b'<meta charset='
Expand Down
2 changes: 1 addition & 1 deletion jsclient/src/Jarr.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const jarrColors = {
contrastText: "#ffffff"
},
background: {
default: "rgb(95,158,160, 0.6)"
default: "rgb(95, 158, 160, 0.6)"
},
danger: {
main: "#F08080",
Expand Down
1 change: 1 addition & 0 deletions jsclient/src/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export const apiUrl = process.env.REACT_APP_API_URL ? process.env.REACT_APP_API_
export const feedListWidth = 300;
export const editPanelWidth = 500;
export const pageLength = 30;
export const headerHeight = 64;
20 changes: 17 additions & 3 deletions jsclient/src/features/clusterlist/components/Article.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import React from "react";
import React, { useEffect, useRef } from "react";
import PropTypes from "prop-types";
import Typography from "@material-ui/core/Typography";
import Link from "@material-ui/core/Link";
import Divider from "@material-ui/core/Divider";
import { headerHeight } from "../../../const";

import makeStyles from "./style";

function Article({ article, hidden }) {
function Article({ article, hidden, showTitle }) {
const classes = makeStyles();
const ref = useRef(null);
useEffect(() => {
if (ref.current && ref.current.offsetTop && ref.current.offsetParent) {
window.scrollTo({ left: 0,
top: ref.current.offsetTop
+ ref.current.offsetParent.offsetTop
- headerHeight * 2.3,
behavior: "smooth" });
}
}, [ref]);
let comments;
if (article.comments) {
comments = (<p><span>Comments</span>
Expand All @@ -17,7 +28,8 @@ function Article({ article, hidden }) {
</Link></p>);
}
return (
<div hidden={hidden} className={classes.article}>
<div hidden={hidden} className={classes.article} ref={ref}>
<h3 hidden={!showTitle}>{article.title}</h3>
<p>
<span>Link</span>
<Link color="secondary" target="_blank"
Expand All @@ -38,10 +50,12 @@ function Article({ article, hidden }) {

Article.propTypes = {
article: PropTypes.shape({
title: PropTypes.string.isRequired,
link: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
comments: PropTypes.string,
}),
showTitle: PropTypes.bool.isRequired,
hidden: PropTypes.bool.isRequired,
};

Expand Down
23 changes: 10 additions & 13 deletions jsclient/src/features/clusterlist/components/Articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,40 @@ function Articles({ articles, icons, content }) {

let contentTitle, contentTab;
if (articles.length === 1 && !content) {
return <Article article={articles[0]} hidden={false} />;
return <Article article={articles[0]} hidden={false} showTitle={false} />;
} else if (content) {
contentTitle = (
<Tab key="t-0"
<Tab key="t-0" label=""
className={classes.tabs}
//
icon={<img src={jarrIcon} alt={proccessedContentTitle}
title={proccessedContentTitle} />}
label={proccessedContentTitle}
value={0} aria-controls="a-0"
/>
);
contentTab = <Content content={content} hidden={0 !== currentIndex} />;
}
const isOnlyOneTitle = [...new Set(articles.map((a) => a.title))].length === 1;
return (
<>
<Tabs indicatorColor="primary" textColor="primary"
variant="scrollable" scrollButtons="auto"
value={currentIndex}
onChange={(e, v) => setCurrentIndex(v)}>
{contentTitle}
{articles.map((article, index) => {
index = content ? index + 1 : index;
return (<Tab key={`t-${index}`}
className={classes.tabs}
icon={<ClusterIcon iconUrl={icons[article["feed_id"]]} />}
label={isOnlyOneTitle ? null : article.title}
value={index}
aria-controls={`a-${index}`}
/>);
return (<Tab key={`t-${index}`} label=""
className={classes.tabs}
icon={<ClusterIcon iconUrl={icons[article["feed_id"]]} />}
value={index}
aria-controls={`a-${index}`}
/>);
})}
</Tabs>
{contentTab}
{articles.map((article, index) => {
index = content ? index + 1 : index;
return (
<Article
<Article showTitle
key={`a-${index}-${index !== currentIndex ? "h" : ""}`}
id={`a-${index}`}
article={article}
Expand Down
22 changes: 8 additions & 14 deletions jsclient/src/features/clusterlist/components/Cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const makeMapStateToProps = () => {
}

const mapDispatchToProps = (dispatch) => ({
handleClickOnPanel(e, cluster, unreadOnClose, expanded) {
handleClickOnPanel(cluster, unreadOnClose, expanded) {
if (!expanded) {
// panel is folded, we fetch the cluster
dispatch(doFetchCluster(cluster.id));
Expand All @@ -58,9 +58,8 @@ const mapDispatchToProps = (dispatch) => ({
dispatch(removeClusterSelection());
dispatch(doEditCluster(cluster.id,
{ read: false, "read_reason": null }));
dispatch(changeReadCount(
{ feedsId: cluster["feeds_id"],
action: "unread" }));
dispatch(changeReadCount({ feedsId: cluster["feeds_id"],
action: "unread" }));
} else {
// filters says everybody is displayed
// so we"re not triggering changes in cluster list
Expand Down Expand Up @@ -118,8 +117,7 @@ const Cluster = ({ index, cluster, loadedCluster,
content = <div className={classes.loadingWrap}><CircularProgress /></div>;
}
content = (
<ExpansionPanelDetails className={classes.content}
key={`cl-${cluster.id}`}>
<ExpansionPanelDetails className={classes.content} key={`cl-${cluster.id}`}>
{content}
</ExpansionPanelDetails>
);
Expand All @@ -130,13 +128,9 @@ const Cluster = ({ index, cluster, loadedCluster,
expanded={expanded}
elevation={expanded ? 10: 2}
TransitionProps={{ unmountOnExit: true }}
key={"c"
+ (expanded ? "e" : "")
+ (cluster.read ? "r" : "")
+ (cluster.liked ? "l" : "")
+ cluster.id}
onChange={(e) => handleClickOnPanel(e, cluster,
unreadOnClose, expanded)}
key={`c${expanded ? "e" : ""}${cluster.read ? "r" : ""}${cluster.liked ? "l" : ""}${cluster.id}`}
onChange={() => handleClickOnPanel(cluster,
unreadOnClose, expanded)}
>
<ExpansionPanelSummary
expandIcon={<ExpandMoreIcon />}
Expand All @@ -149,7 +143,7 @@ const Cluster = ({ index, cluster, loadedCluster,
<Link href={cluster["main_link"]} target="_blank" color="secondary"
onMouseUp={(e) => {
// only middle click
if(e.button === 1) {readOnRedirect(e, cluster)}
if(e.button === 1) {readOnRedirect(e, cluster)};
}}
onClick={(e) => readOnRedirect(e, cluster)}>
{[ ...new Set(cluster["feeds_id"])].filter((feedId) => icons[feedId])
Expand Down
1 change: 1 addition & 0 deletions jsclient/src/features/clusterlist/components/Content.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function Content({ content, hidden }) {
}
return (
<div hidden={hidden} className={classes.article}>
<h3>{content.title}</h3>
{head}
{comments}
<Divider />
Expand Down
6 changes: 3 additions & 3 deletions jsclient/src/features/clusterlist/components/style.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeStyles, Theme, createStyles } from "@material-ui/core/styles";
import { feedListWidth, editPanelWidth } from "../../../const";
import { feedListWidth, editPanelWidth, headerHeight } from "../../../const";

export default makeStyles((theme: Theme) =>
createStyles({
Expand Down Expand Up @@ -90,7 +90,7 @@ export default makeStyles((theme: Theme) =>
},
main: {
flexGrow: 1,
paddingTop: 64+ theme.spacing(2),
paddingTop: headerHeight + theme.spacing(2),
transition: theme.transitions.create("margin", {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
Expand Down Expand Up @@ -129,7 +129,7 @@ export default makeStyles((theme: Theme) =>
width: "45%",
},
clusterListInner: {
maxHeight: "calc(100vh - (64px + 32px))",
maxHeight: `calc(100vh - (${headerHeight}px + 32px))`,
maxWidth: "100%",
overflowY: "auto",
overflowX: "hidden",
Expand Down
4 changes: 4 additions & 0 deletions jsclient/src/features/feedlist/FeedRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ const mapDispatchToProps = (dispatch) => ({
},
listClusters(e, filters, isDesktop, isFolded, selectedCategoryId) {
e.stopPropagation();
// hide menu if in splitted mode and we're openning a un-opened category or feed
if(!isDesktop && (filters.feedId || (filters.categoryId && isFolded))) {
dispatch(toggleMenu(false));
}
// toggling folding of category on selection
/*
if(isFolded && filters.categoryId){
dispatch(toggleFolding(filters.categoryId));
} else if (!isFolded && filters.categoryId && filters.categoryId === selectedCategoryId) {
dispatch(toggleFolding(filters.categoryId));
}
*/
dispatch(doListClusters(filters));
},
});
Expand Down
1 change: 0 additions & 1 deletion migrations/versions/20200603_improving_main_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""
import logging
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = 'f5978c8a8740'
Expand Down