Skip to content

Commit

Permalink
Update to v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Dotnaught committed Sep 15, 2021
1 parent ee81e79 commit 9c25cb1
Show file tree
Hide file tree
Showing 9 changed files with 1,995 additions and 1,019 deletions.
15 changes: 8 additions & 7 deletions html/feedWindow.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
</head>

<body>
<p>
The <b>feed</b> field can be edited for new entries. The
<b>visible</b> field can be toggled by clicking on it. The
<b>filterList</b> field can be edited for new and existing entries. The
<b>filterList</b> should contain space-separated words that must be
present in any feed article displayed. <b>Delete Entry</b> will remove the
associated feed from the database.
<p align="center">
The <b>feed</b> field can be edited for new entries. <br>
The <b>visible</b> field can be toggled by clicking on it.<br>
Change the <b>color</b> field to make entries more distinctive.<br>
The <b>filterList</b> field can be edited for new and existing entries.<br>
Click on <b>mode</b> to toggle between "publication", "aggregator", and "docket."<br>
The <b>filterList</b> displays only entries with any of the space-separated words in the Title or Author fields.<br>
<b>Delete Entry</b> will remove the associated feed from the database.
</p>
<div id="tableDiv">
<table>
Expand Down
13 changes: 12 additions & 1 deletion html/mainWindow.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
></h2>
</span>
<span>



<div class="relative flex w-full flex-wrap items-stretch mb-3">
<div id="queryAndButton" class="relative flex w-full flex-wrap items-stretch mb-3">
<!--
<span
class="z-10 h-full leading-snug font-normal absolute text-center text-gray-400 absolute bg-transparent rounded text-base items-center justify-center w-8 pl-3 py-3"
Expand All @@ -59,10 +61,19 @@
>
Clear
</button>

<div class="form-control">
<label class="inline-flex items-center mt-5 ml-8">
<input id="checkbox" type="checkbox" class="form-checkbox h-5 w-5 text-red-600" checked><span class="ml-2 text-gray-700">Docket View</span>
</label>

</div>
</div>

<!--<input placeholder="Search" id="query" type="text" class="validate" /> -->



<!--- <a id="clear" href="#">Clear</a>-->
</span>

Expand Down
41 changes: 20 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ const userData = app.getPath("userData") + "/rssputinDB.json";
//const rssdb = require(userData);
const rsslib = require("./js/rsslib");
const jsonSchema = require("./js/schema");

/*
const gh = require("./js/github");
//
app.whenReady().then(() => {
const { net } = require("electron");
//const { net } = require("electron");
const request = net.request(
"https://github.com/minimaxir/aitextgen/issues?q=is%3Aissue+is%3Aopen+sort%3Acomments-desc"
);
Expand All @@ -63,7 +63,7 @@ app.whenReady().then(() => {
});
request.end();
});
//
*/

unhandled();
debug();
Expand All @@ -82,6 +82,7 @@ const resp = fs.readFileSync(userData, "utf8", (err, data) => {
const rssdb = JSON.parse(resp);
*/
const Ajv = require("ajv");
const { SocketAddress } = require("net");
const ajv = new Ajv();
const validate = ajv.compile(schema);
//const valid = validate(rssdb);
Expand Down Expand Up @@ -136,6 +137,7 @@ const createMainWindow = async () => {
enableRemoteModule: false, // Turn off remote
worldSafeExecuteJavaScript: true, // Sanitize JavaScript
preload: path.join(__dirname, "./js/preload.js"), // Use a preload script
nativeWindowOpen: true,
},
});

Expand Down Expand Up @@ -175,6 +177,7 @@ const createFeedWindow = async () => {
enableRemoteModule: false, // Turn off remote
worldSafeExecuteJavaScript: true, // Sanitize JavaScript
preload: path.join(__dirname, "./js/preload.js"), // Use a preload script
nativeWindowOpen: true,
},
});

Expand All @@ -199,10 +202,6 @@ const createFeedWindow = async () => {
return feedWindow;
};

const createGHWindow = async () => {
console.log("ghWindow");
};

app.on("second-instance", () => {
if (mainWindow) {
if (mainWindow.isMinimized()) {
Expand Down Expand Up @@ -230,6 +229,12 @@ ipcMain.on("requestFeeds", (event, args) => {
feedWindow.webContents.send("sendFeeds", feeds);
});

ipcMain.on("setDocket", (event, args) => {
store.set("docketOnly", args);
mainWindow.close();
setMainWindow();
});

ipcMain.on("setTimeWindow", (event, args) => {
store.set("timeWindow", args);
if (mainWindow) {
Expand Down Expand Up @@ -305,6 +310,8 @@ function setDefaults() {
store.set("Author", Author);
let Source = store.get("Source") || "15%";
store.set("Source", Source);
let docketOnly = store.get("docketOnly") || false;
store.set("docketOnly", docketOnly);
}

function resetColumnWidths() {
Expand Down Expand Up @@ -516,18 +523,6 @@ const macosTemplate = [
{
type: "separator",
},
{
label: "Show Issues",
accelerator: "CmdOrCtrl+I",
async click() {
if (mainWindow) {
createGHWindow();
}
},
},
{
type: "separator",
},
{
label: "Import Database",
accelerator: "CmdOrCtrl+=",
Expand Down Expand Up @@ -687,6 +682,8 @@ const setMainWindow = async () => {
const handleRedirect = (event, url) => {
if (url !== event.sender.getURL()) {
shell.openExternal(url);
mainWindow.webContents.send("updateLinks", url);

event.preventDefault();
}
};
Expand All @@ -699,12 +696,14 @@ const setMainWindow = async () => {
//setDefaults
setDefaults();
let timeWindow = store.get("timeWindow");
let docketOnly = store.get("docketOnly");
// Create the mainWindow
mainWindow = await createMainWindow();
// Intercept navigation event so the URL opens in the browser
mainWindow.webContents.on("will-navigate", handleRedirect);
let defaultsObj = {
timeWindow: timeWindow,
docketOnly: docketOnly,
hoursAgo: store.get("hours"),
Title: store.get("Title"),
Author: store.get("Author"),
Expand All @@ -715,7 +714,7 @@ const setMainWindow = async () => {
// Fetch and process RSS feeds
rsslib
.getAllFeeds(feedData.getFeeds(), mainWindow)
.then((feeds) => rsslib.processFeeds(feeds, timeWindow))
.then((feeds) => rsslib.processFeeds(feeds, timeWindow, docketOnly))
.then((result) => mainWindow.webContents.send("fromMain", result))
.catch((error) => console.error(error.message));
});
Expand Down
29 changes: 26 additions & 3 deletions js/feedWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,20 @@ let flipString = (e) => {
let key = e.target.getAttribute("data-key");
let val, newval;
val = e.target.textContent;
newval = val === "publication" ? "aggregator" : "publication";
switch (val) {
case "publication":
newval = "aggregator";
break;
case "aggregator":
newval = "docket";
break;
case "docket":
newval = "publication";
break;
}
//newval = val === "publication" ? "aggregator" : "publication";
e.target.textContent = newval.toString();
console.log(newval, val);
saveItem(key, newval, val, id);
};

Expand Down Expand Up @@ -300,8 +312,19 @@ let addRow = (e) => {

if (row[i]["attributes"]["data-key"].value === "mode") {
// eslint-disable-next-line no-unused-vars
mode =
row[i]["textContent"] == "publication" ? "publication" : "aggregator";
switch (row[i]["textContent"]) {
case "publication":
mode = "publication";
break;
case "aggregator":
mode = "aggregator";
break;
case "docket":
mode = "docket";
break;
}

//mode = row[i]["textContent"] == "publication" ? "publication" : "aggregator";
}
}

Expand Down
61 changes: 54 additions & 7 deletions js/mainWindow.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

let table = document.querySelector("table");
let checkbox = document.getElementById("checkbox");

window.api.receive("updateBar", (args) => {
let bar = document.getElementById("bar");
Expand All @@ -17,6 +18,20 @@ let defaultsObj;

window.api.receive("receiveDefaults", (defaults) => {
defaultsObj = defaults;
if (defaultsObj.docketOnly) {
checkbox.setAttribute("checked", "checked");
} else {
checkbox.removeAttribute("checked");
}
});

window.api.receive("updateLinks", (links) => {
let lnk = document.getElementById(links);
try {
lnk.setAttribute("style", "color: red");
} catch (e) {
console.log(e);
}
});

window.api.receive("fromMain", (arr) => {
Expand All @@ -41,19 +56,44 @@ window.addEventListener("DOMContentLoaded", () => {
query.addEventListener("focus", displayCancelShow);
query.addEventListener("keyup", searchFunction);

let clear = document.querySelector("#clear");
//let clear = document.querySelector("#clear");
let clear = document.getElementById("clear");
clear.addEventListener("click", displayCancelHide);
clear.style.visibility = "hidden";
//clear.style.visibility = "hidden";
//clear.setAttribute("style", "opacity: 0.5");
//clear.style.opacity = 0.5;

checkbox.addEventListener("change", filterDocket);
});

function filterDocket(event) {
defaultsObj.docketOnly = event.target.checked;
console.log(defaultsObj.docketOnly);

if (event.target.checked) {
checkbox.removeAttribute("checked");
window.api.send("setDocket", checkbox.checked);
console.log(checkbox.checked);
} else {
checkbox.setAttribute("checked", "checked");
window.api.send("setDocket", checkbox.checked);
console.log(checkbox.checked);
}
}

function displayCancelShow() {
let cancelButton = document.getElementById("clear");
cancelButton.style.visibility = "visible";
//let clear = document.getElementById("clear");
//cancelButton.style.visibility = "visible";
//clear.setAttribute("style", "opacity: 0.5");
//clear.style.opacity = 1;
}

function displayCancelHide() {
let cancelButton = document.getElementById("clear");
cancelButton.style.visibility = "hidden";
//let clear = document.getElementById("clear");
//cancelButton.style.visibility = "hidden";
//clear.setAttribute("style", "opacity: 0.5");
//clear.style.opacity = 0.5;

document.getElementById("query").value = "";
searchFunction();
}
Expand Down Expand Up @@ -157,7 +197,7 @@ function generateTable(table, data) {
const a = document.createElement("a");

a.setAttribute("href", element.link); //'#'

a.setAttribute("id", element.link);
if (element.title.length > 159) {
a.setAttribute("title", element.title);
}
Expand All @@ -176,6 +216,7 @@ function generateTable(table, data) {
: element.sourceLink;
a.setAttribute("href", link);

a.setAttribute("id", row.rowIndex);
a.style.color = element.color;
a.appendChild(text);
cell.appendChild(a);
Expand Down Expand Up @@ -238,7 +279,13 @@ function resizableGrid(table) {
});

document.addEventListener("mouseup", function (e) {
let cols = ["hoursAgo", "Title", "Author", "Source"];
let tgt = e.target.parentElement?.id || "None";
if (!cols.includes(tgt)) {
return;
}
curCol = e.target.parentElement;
console.log(e.target.parentElement.id);
nxtCol = curCol.nextElementSibling;
// console.log("parent");
// console.log(e.target.parentElement);
Expand Down
2 changes: 2 additions & 0 deletions js/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ contextBridge.exposeInMainWorld("api", {
let validChannels = [
"requestFeeds",
"setTimeWindow",
"setDocket",
"setFeedItem",
"addFeeds",
"deleteFeed",
Expand All @@ -27,6 +28,7 @@ contextBridge.exposeInMainWorld("api", {
"updateBar",
"sendFeeds",
"receiveDefaults",
"updateLinks",
];
if (validChannels.includes(channel)) {
// Deliberately strip event as it includes `sender`
Expand Down
10 changes: 9 additions & 1 deletion js/rsslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function removeXMLInvalidChars(str, removeDiscouragedChars) {
return str;
}

function processFeeds(feeds, timeWindow) {
function processFeeds(feeds, timeWindow, docketOnly) {
if (feeds[0] === undefined) feeds.shift();

let arr = [];
Expand All @@ -140,6 +140,10 @@ function processFeeds(feeds, timeWindow) {
feeds.forEach((feed) => {
if (feed === undefined) {
return;
} else if (docketOnly && feed.meta.mode !== "docket") {
return;
} else if (!docketOnly && feed.meta.mode === "docket") {
return;
}

//filter for articles with words in list
Expand Down Expand Up @@ -185,6 +189,7 @@ function processFeeds(feeds, timeWindow) {
altLink = feed.meta.mode === "aggregator" ? altURLs[linkIndex] : i.link;
aggregatorLink = altURLs[aggIndex];
}

//create the feed object to be displayed
let obj = {};

Expand All @@ -210,6 +215,9 @@ function processFeeds(feeds, timeWindow) {
} else if (i.creator !== undefined) {
//for arXiv
obj.author = i.creator;
} else if (feed.meta.mode === "docket") {
//add type of court filing to unused author column
obj.author = i.content.substring(1, i.content.indexOf("]"));
} else {
obj.author = "";
}
Expand Down
Loading

0 comments on commit 9c25cb1

Please sign in to comment.