Skip to content

Commit

Permalink
Merge pull request #18 from UdaraJay/link-previews
Browse files Browse the repository at this point in the history
Link previews
  • Loading branch information
UdaraJay committed Nov 12, 2023
2 parents 3c2b9c8 + e17502c commit bc60588
Show file tree
Hide file tree
Showing 44 changed files with 1,613 additions and 219 deletions.
7 changes: 6 additions & 1 deletion .erb/configs/webpack.config.renderer.dev.dll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ const configuration: webpack.Configuration = {
module: require('./webpack.config.renderer.dev').default.module,

entry: {
renderer: Object.keys(dependencies || {}),
// webpack has some issue importing a path from @tiptap/pm
// so we're going to exclude it from the entry point bundle
// as we don't need it there anyways.
renderer: Object.keys(dependencies || {}).filter(
(it) => it !== '@tiptap/pm'
),
},

output: {
Expand Down
45 changes: 45 additions & 0 deletions .yarnclean
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# test directories
__tests__
test
tests
powered-test

# asset directories
docs
doc
website
images
assets

# examples
example
examples

# code coverage directories
coverage
.nyc_output

# build scripts
Makefile
Gulpfile.js
Gruntfile.js

# configs
appveyor.yml
circle.yml
codeship-services.yml
codeship-steps.yml
wercker.yml
.tern-project
.gitattributes
.editorconfig
.*ignore
.eslintrc
.jshintrc
.flowconfig
.documentup.json
.yarn-metadata.json
.travis.yml

# misc
*.md
Binary file added assets/garden.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 16 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"build:renderer": "cross-env NODE_ENV=production TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.prod.ts",
"postinstall": "ts-node .erb/scripts/check-native-dep.js && electron-builder install-app-deps && cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.ts",
"lint": "cross-env NODE_ENV=development eslint . --ext .js,.jsx,.ts,.tsx",
"package": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build --publish never",
"package": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build --mac --win --publish never",
"rebuild": "electron-rebuild --parallel --types prod,dev,optional --module-dir release/app",
"start": "ts-node ./.erb/scripts/check-port-in-use.js && npm run start:renderer",
"start:main": "cross-env NODE_ENV=development electronmon -r ts-node/register/transpile-only .",
Expand Down Expand Up @@ -91,12 +91,15 @@
"@radix-ui/react-alert-dialog": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@tiptap/extension-character-count": "^2.0.3",
"@tiptap/extension-character-count": "^2.1.12",
"@tiptap/extension-link": "^2.1.12",
"@tiptap/extension-placeholder": "^2.0.3",
"@tiptap/extension-typography": "^2.0.4",
"@tiptap/pm": "^2.0.3",
"@tiptap/react": "^2.0.3",
"@tiptap/starter-kit": "^2.0.3",
"axios": "^1.6.0",
"cheerio": "^1.0.0-rc.12",
"dotenv": "^16.3.1",
"electron-debug": "^3.2.0",
"electron-log": "^4.4.8",
Expand All @@ -105,12 +108,10 @@
"gray-matter": "^4.0.3",
"luxon": "^3.3.0",
"million": "^2.6.4",
"nanoid": "^4.0.2",
"openai": "4.0.0-beta.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.11.2",
"use-count-up": "^3.0.1"
"react-router-dom": "^6.11.2"
},
"devDependencies": {
"@adobe/css-tools": "^4.3.1",
Expand Down Expand Up @@ -140,7 +141,7 @@
"css-minimizer-webpack-plugin": "^5.0.0",
"detect-port": "^1.5.1",
"electron": "^25.8.4",
"electron-builder": "^24.2.1",
"electron-builder": "^24.7.0",
"electron-devtools-installer": "^3.2.0",
"electronmon": "^2.0.2",
"eslint": "^8.42.0",
Expand Down Expand Up @@ -226,8 +227,15 @@
]
},
"win": {
"publisherName": "Pile",
"target": [
"portable"
{
"target": "nsis",
"arch": [
"x64",
"ia32"
]
}
]
},
"linux": {
Expand Down Expand Up @@ -262,4 +270,4 @@
],
"logLevel": "quiet"
}
}
}
4 changes: 2 additions & 2 deletions release/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pile",
"version": "0.7.50",
"version": "0.8.1",
"description": "Pile: Everyday journal and thought companion.",
"license": "MIT",
"author": {
Expand Down
53 changes: 46 additions & 7 deletions src/main/ipc.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ipcMain, app, dialog } from 'electron';
import path from 'path';
import fs from 'fs';
import pileHelper from './utils/PileHelper';
import pileIndex from './utils/PileIndex';
import pileTags from './utils/PileTags';
import pileHelper from './utils/pileHelper';
import pileIndex from './utils/pileIndex';
import pileTags from './utils/pileTags';
import pileLinks from './utils/pileLinks';
import pileHighlights from './utils/pileHighlights';
import keytar from 'keytar';
import { getLinkPreview, getLinkContent } from './utils/linkPreview';
const os = require('os');

const matter = require('gray-matter');

// AI key
Expand All @@ -19,6 +20,29 @@ ipcMain.handle('set-ai-key', async (event, secretKey) => {
return await keytar.setPassword('pile', 'aikey', secretKey);
});

ipcMain.handle('delete-ai-key', async (event) => {
return await keytar.deletePassword('pile', 'aikey');
});

// Link preview
ipcMain.handle('get-link-preview', async (event, url) => {
const preview = await getLinkPreview(url)
.then((data) => {
return data;
})
.catch(() => null);
return preview;
});

ipcMain.handle('get-link-content', async (event, url) => {
const preview = await getLinkContent(url)
.then((data) => {
return data;
})
.catch(() => null);
return preview;
});

// Index operations
ipcMain.handle('index-load', (event, pilePath) => {
const index = pileIndex.load(pilePath);
Expand All @@ -40,6 +64,17 @@ ipcMain.handle('index-remove', (event, filePath) => {
return index;
});

// Links operations
ipcMain.handle('links-get', (event, pilePath, url) => {
const data = pileLinks.get(pilePath, url);
return data;
});

ipcMain.handle('links-set', (event, pilePath, url, data) => {
const status = pileLinks.set(pilePath, url, data);
return status;
});

// Highlight operations
ipcMain.handle('highlights-load', (event, pilePath) => {
const highlights = pileHighlights.load(pilePath);
Expand Down Expand Up @@ -92,8 +127,12 @@ ipcMain.on('change-folder', (event, newPath) => {
});

ipcMain.handle('matter-parse', async (event, file) => {
const post = matter(file);
return post;
try {
const post = matter(file);
return post;
} catch (error) {
return null;
}
});

ipcMain.handle('matter-stringify', async (event, { content, data }) => {
Expand All @@ -107,7 +146,7 @@ ipcMain.handle('get-files', async (event, dirPath) => {
});

ipcMain.handle('get-file', async (event, filePath) => {
const content = await pileHelper.getFile(filePath);
const content = await pileHelper.getFile(filePath).catch(() => null);
return content;
});

Expand Down
Loading

0 comments on commit bc60588

Please sign in to comment.