Skip to content

Commit

Permalink
Merge pull request #45 from Quorafind/chore/rename-plugin
Browse files Browse the repository at this point in the history
chore: rename another web browser to surfing
  • Loading branch information
Quorafind authored Nov 26, 2022
2 parents c73fba7 + 1b325b7 commit 2bb495a
Show file tree
Hide file tree
Showing 19 changed files with 238 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [ created ]

env:
PLUGIN_NAME: another-web-browser
PLUGIN_NAME: obsidian-surfing

jobs:
build:
Expand Down
127 changes: 66 additions & 61 deletions README-ZH.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,66 @@
## Another Web Browser

> 这个分支由 Boninall 维护,仅作个人使用。如果你想用该插件,使用 `quorafind/obsidian-web-browser` 分支而不是以前的;
> 原始分支来自[这里](https://github.com/Trikzon/obsidian-web-browser)
[English Doc](README.md)

## 简介

这是一款 Obsidian 插件,允许你在 Obsidian v1.0 的标签页中浏览任意网址。

这个插件的核心功能——渲染一个 webview ,离不开 [Ellpeck's Obsidian Custom Frames](https://github.com/Ellpeck/ObsidianCustomFrames) 插件。

![](assets/obsidian-web-browser.png)

## 功能介绍

- 核心功能
- 浏览任意网页:该插件会劫持Obsidian的 file、http、https 协议,使得链接能直接在Obsidian里打开,而不是外部浏览器。对,本地HTML等资源也支持。
- 编辑器网页搜索你可以在编辑器选中关键字后,右键在 web-browser 中打开,使用默认的搜索引擎搜索。
- 网页内网页搜索:同样的,你可以在网页内右键使用默认的搜索引擎搜索。
- 复制指向高亮的链接:同浏览器一样,你可以选中文字,复制指向该处的链接。
- 在浏览器中使用书签直接在 Obsidian 中打开网址。
- 复制视频时间戳(实验性功能:目前仅支持bilibili):右键文字弹出复制时间戳的菜单,目前有些bug,已知有时弹不出菜单。
- 辅助功能
- 用外部浏览器打开当前URL:右键菜单
- 默认搜索引擎:设置项
- 默认复制高亮的模板:设置项(目前仅支持非常简单的模板),请避免使用一些特殊字符
- 支持浏览历史记录:前后跳转网页
- 清除浏览历史记录:命令面板
- 所有链接都在右侧同一个面板中打开:设置项
- 切换是否在右侧同一面板中打开:命令面板
- 简单的夜间模式:主要是为了bilibili的夜间观感,有些瑕疵,问题不大

## 使用方法

### 利用浏览器书签在obsidain中打开网站

插件注册了一个 Obsidain uri 协议,该协议允许你使用`obsidian://web-open?url=<url>`的网址在 Obsidian 中打开 Web-broswer 。其中`<url>`指网页地址链接。配合 [bookmarklets](https://www.ruanyifeng.com/blog/2011/06/a_guide_for_writing_bookmarklet.html) 便能实现点击浏览器的一个书签,在ob内打开当前浏览器网址。

1. 在插件设置里打开`Open URL In Obsidian Web`选项
2. 该选项下有一个链接,拖拽这个链接到你外部浏览器的书签栏处,会生成一个书签; 你也可以点击这个链接复制 bookmarklets 代码,自己新建一个书签
3. 现在可以点击书签,将浏览器当前页面在 Obsidian 打开了

## 安装

- 目前尚未准备好上架市场
- 可以通过 [Brat](https://github.com/TfTHacker/obsidian42-brat) 插件安装
- 手动安装

1. 在该github页面找到release页面并点击
2. 下载最新的一次release压缩包
3. 解压,复制解压后的文件夹到obsidian插件文件夹下,确保该文件夹里有main.js和manifest.json文件
4. 重启obsidian(不重启也行,得刷新),在设置界面启用该插件
5. 欧了

## Support

You can support original author `Trikzon` :

[<img src="https://user-images.githubusercontent.com/14358394/115450238-f39e8100-a21b-11eb-89d0-fa4b82cdbce8.png" width="200">](https://ko-fi.com/trikzon)
## Surfing

> 这个分支由 Boninall 维护,仅作个人使用。如果你想用该插件,使用 `quorafind/obsidian-web-browser` 分支而不是以前的;
> 原始分支来自[这里](https://github.com/Trikzon/obsidian-web-browser)
[English Doc](README.md)

## 简介

这是一款 Obsidian 插件,允许你在 Obsidian v1.0 的标签页中浏览任意网址。

这个插件的核心功能——渲染一个 webview
,离不开 [Ellpeck's Obsidian Custom Frames](https://github.com/Ellpeck/ObsidianCustomFrames) 插件。

![](assets/obsidian-web-browser.png)

## 功能介绍

- 核心功能
- 浏览任意网页:该插件会劫持Obsidian的 file、http、https 协议,使得链接能直接在Obsidian里打开,而不是外部浏览器。对,本地HTML等资源也支持。
- 编辑器网页搜索你可以在编辑器选中关键字后,右键在 web-browser 中打开,使用默认的搜索引擎搜索。
- 网页内网页搜索:同样的,你可以在网页内右键使用默认的搜索引擎搜索。
- 复制指向高亮的链接:同浏览器一样,你可以选中文字,复制指向该处的链接。
- 在浏览器中使用书签直接在 Obsidian 中打开网址。
- 复制视频时间戳(实验性功能:目前仅支持bilibili):右键文字弹出复制时间戳的菜单,目前有些bug,已知有时弹不出菜单。
- 辅助功能
- 用外部浏览器打开当前URL:右键菜单
- 默认搜索引擎:设置项
- 默认复制高亮的模板:设置项(目前仅支持非常简单的模板),请避免使用一些特殊字符
- 支持浏览历史记录:前后跳转网页
- 清除浏览历史记录:命令面板
- 所有链接都在右侧同一个面板中打开:设置项
- 切换是否在右侧同一面板中打开:命令面板
- 简单的夜间模式:主要是为了bilibili的夜间观感,有些瑕疵,问题不大

## 使用方法

### 利用浏览器书签在obsidain中打开网站

插件注册了一个 Obsidain uri 协议,该协议允许你使用`obsidian://web-open?url=<url>`的网址在 Obsidian 中打开 Web-broswer
。其中`<url>`
指网页地址链接。配合 [bookmarklets](https://www.ruanyifeng.com/blog/2011/06/a_guide_for_writing_bookmarklet.html)
便能实现点击浏览器的一个书签,在ob内打开当前浏览器网址。

1. 在插件设置里打开`Open URL In Obsidian Web`选项
2. 该选项下有一个链接,拖拽这个链接到你外部浏览器的书签栏处,会生成一个书签; 你也可以点击这个链接复制 bookmarklets
代码,自己新建一个书签
3. 现在可以点击书签,将浏览器当前页面在 Obsidian 打开了

## 安装

- 目前尚未准备好上架市场
- 可以通过 [Brat](https://github.com/TfTHacker/obsidian42-brat) 插件安装
- 手动安装

1. 在该github页面找到release页面并点击
2. 下载最新的一次release压缩包
3. 解压,复制解压后的文件夹到obsidian插件文件夹下,确保该文件夹里有main.js和manifest.json文件
4. 重启obsidian(不重启也行,得刷新),在设置界面启用该插件
5. 欧了

## Support

You can support original author `Trikzon` :

[<img src="https://user-images.githubusercontent.com/14358394/115450238-f39e8100-a21b-11eb-89d0-fa4b82cdbce8.png" width="200">](https://ko-fi.com/trikzon)
55 changes: 33 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Another Web Browser
## Surfing

> This fork is maintained by Boninall, it is for personal use only. If you want to use it,
> add `quorafind/obsidian-web-browser` rather than original one.
> add `quorafind/obsidian-web-browser` rather than original one.
> Original fork is [here](https://github.com/Trikzon/obsidian-web-browser).
[中文文档](README-ZH.md)[English Doc](README.md)
Expand All @@ -19,30 +19,39 @@ have be possible without it.
## Feature

- Core Feature
- Browse arbitrary web pages: The plugin hijacks Obsidian's file, http, https protocols, enabling links to be opened directly in Obsidian, rather than in external browsers. Yes, local HTML and other resources are also supported.
- Editor web search: You can select keywords in the editor and then right-click to open them in web-browser and search using the default search engine.
- In-page web search: Again, you can right-click within a web page to use the default search engine search.
- Copy links pointing to highlights: As with the browser, you can select text and copy the links pointing to it.
- Use BookmarkLets in your browser to open the URL directly in Obsidian.
- Copy video timestamp (experimental feature: currently only bilibili is supported): right click on the text to pop up the menu to copy the timestamp, currently there are some bugs, it is known that sometimes the menu does not pop up.
- Browse arbitrary web pages: The plugin hijacks Obsidian's file, http, https protocols, enabling links to be opened
directly in Obsidian, rather than in external browsers. Yes, local HTML and other resources are also supported.
- Editor web search: You can select keywords in the editor and then right-click to open them in web-browser and
search using the default search engine.
- In-page web search: Again, you can right-click within a web page to use the default search engine search.
- Copy links pointing to highlights: As with the browser, you can select text and copy the links pointing to it.
- Use BookmarkLets in your browser to open the URL directly in Obsidian.
- Copy video timestamp (experimental feature: currently only bilibili is supported): right click on the text to pop
up the menu to copy the timestamp, currently there are some bugs, it is known that sometimes the menu does not pop
up.
- Auxiliary Feature
- Open current URL with external browser: right-click menu
- Default search engine: setting item
- Default copy highlighted template: setting item (currently only supports very simple templates), please avoid using some special characters
- Support browsing history: Jump back and forth to the page
- Clear browsing history: command panel
- All links are opened in the same panel on the right: Settings
- Toggle whether to open in the same panel on the right: command panel
- Simple dark mode: just simple
- Open current URL with external browser: right-click menu
- Default search engine: setting item
- Default copy highlighted template: setting item (currently only supports very simple templates), please avoid
using some special characters
- Support browsing history: Jump back and forth to the page
- Clear browsing history: command panel
- All links are opened in the same panel on the right: Settings
- Toggle whether to open in the same panel on the right: command panel
- Simple dark mode: just simple

## Usage

### Use BookmarkLets Open URL

The plugin registers an Obsidain uri protocol that allows you to open eb-broswer in Obsidian using the URL `obsidian://web-open?url=<url>`. Where `<url>` refers to the web address link. Match [bookmarklets](https://en.wikipedia.org/wiki/Bookmarklet) will be able to click a bookmark in the browser to open the current browser URL within Obsidain.
The plugin registers an Obsidain uri protocol that allows you to open eb-broswer in Obsidian using the
URL `obsidian://web-open?url=<url>`. Where `<url>` refers to the web address link.
Match [bookmarklets](https://en.wikipedia.org/wiki/Bookmarklet) will be able to click a bookmark in the browser to open
the current browser URL within Obsidain.

1. Open the `Open URL In Obsidian Web` option in the plugin settings.
2. Under this option there is a link of bookmarklets, drag this link into your browser's bookmark bar. You can also click this link(will copy bookmarklets code), then create bookmarklets by yourself.
1. Open the `Open URL In Obsidian Web` option in the plugin settings.
2. Under this option there is a link of bookmarklets, drag this link into your browser's bookmark bar. You can also
click this link(will copy bookmarklets code), then create bookmarklets by yourself.
3. Now you can click on the bookmark to open the current page of your browser in Obsidian.

## Installation
Expand All @@ -53,8 +62,10 @@ The plugin registers an Obsidain uri protocol that allows you to open eb-broswe

1. Find the release page on this github page and click
2. Download the latest release zip file
3. Unzip it, copy the unzipped folder to the obsidian plugin folder, make sure there are main.js and manifest.json files in the folder
4. Restart obsidian (do not restart also, you have to refresh plugin list), in the settings interface to enable the plugin
3. Unzip it, copy the unzipped folder to the obsidian plugin folder, make sure there are main.js and manifest.json files
in the folder
4. Restart obsidian (do not restart also, you have to refresh plugin list), in the settings interface to enable the
plugin
5. Done!

## Support
Expand Down
2 changes: 1 addition & 1 deletion esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ esbuild.build({
banner: {
js: banner,
},
entryPoints: ['src/anotherWebBrowserIndex.ts'],
entryPoints: ['src/surfingIndex.ts'],
bundle: true,
external: [
'obsidian',
Expand Down
10 changes: 5 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"id": "another-web-browser",
"name": "Another Web Browser",
"id": "surfing",
"name": "Surfing",
"version": "0.2.4",
"minAppVersion": "1.0.0",
"description": "Lets you browse the web within Obsidian with some neat features.",
"author": "Dion Tryban (Trikzon) && Boninall",
"authorUrl": "https://github.com/Trikzon",
"author": "Boninall",
"authorUrl": "https://github.com/Quorafind",
"isDesktopOnly": true
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "another-web-browser",
"name": "surfing",
"version": "0.2.4",
"description": "Lets you browse the web within Obsidian with some neat features.",
"main": "main.js",
Expand All @@ -12,7 +12,7 @@
"prepare": "husky install"
},
"keywords": [],
"author": "Dion Tryban (Trikzon) && Boninall",
"author": "Boninall",
"license": "MIT",
"devDependencies": {
"@codemirror/language": "^6.2.1",
Expand Down
6 changes: 3 additions & 3 deletions src/component/headerBar.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import AnotherWebBrowserPlugin from "../anotherWebBrowserIndex";
import SurfingPlugin from "../surfingIndex";
import { t } from "../translations/helper";

export class HeaderBar {
plugin: AnotherWebBrowserPlugin;
plugin: SurfingPlugin;
private searchBar: HTMLInputElement;
private onSearchBarEnterListener = new Array<(url: string) => void>;
removeChild = true;

constructor(parent: Element, plugin: AnotherWebBrowserPlugin, removeChild?: boolean) {
constructor(parent: Element, plugin: SurfingPlugin, removeChild?: boolean) {
this.plugin = plugin;
if (removeChild !== undefined) this.removeChild = removeChild;
// CSS class removes the gradient at the right of the header bar.
Expand Down
8 changes: 4 additions & 4 deletions src/component/inPageSearchBar.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import AnotherWebBrowserPlugin from "../anotherWebBrowserIndex";
import SurfingPlugin from "../surfingIndex";
import { t } from "../translations/helper";

export class InPageSearchBar {
plugin: AnotherWebBrowserPlugin;
plugin: SurfingPlugin;
private inPageSearchBarEl: HTMLInputElement;
private inPageSearchBarContainerEl: HTMLDivElement;
private onSearchBarEnterListener = new Array<(url: string) => void>;

constructor(parent: Element, plugin: AnotherWebBrowserPlugin) {
constructor(parent: Element, plugin: SurfingPlugin) {
this.plugin = plugin;
// CSS class removes the gradient at the right of the header bar.
parent.addClass("wb-page-search-bar");
Expand All @@ -19,7 +19,7 @@ export class InPageSearchBar {
});

this.inPageSearchBarContainerEl.createEl("div", {
text: "Surf It",
text: "Surfing",
cls: "wb-page-search-bar-text"
})

Expand Down
6 changes: 3 additions & 3 deletions src/component/searchBox.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { setIcon, WorkspaceLeaf } from "obsidian";
import AnotherWebBrowserPlugin from "../anotherWebBrowserIndex";
import SurfingPlugin from "../surfingIndex";

export default class searchBox {
plugin: AnotherWebBrowserPlugin;
plugin: SurfingPlugin;
leaf: WorkspaceLeaf;

webContents: any;
Expand All @@ -13,7 +13,7 @@ export default class searchBox {
searchBoxEl: HTMLElement;
clicked: boolean;

constructor(leaf: WorkspaceLeaf, webContents: any, plugin: AnotherWebBrowserPlugin, removeChild?: boolean) {
constructor(leaf: WorkspaceLeaf, webContents: any, plugin: SurfingPlugin, removeChild?: boolean) {
this.leaf = leaf;
this.webContents = webContents;
this.plugin = plugin;
Expand Down
8 changes: 4 additions & 4 deletions src/web_browser_file_view.ts → src/surfingFileView.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { FileSystemAdapter, FileView, TFile, WorkspaceLeaf } from "obsidian";
import { AnotherWebBrowserView } from "./web_browser_view";
import { SurfingView } from "./surfingView";

export const HTML_FILE_EXTENSIONS = ["html", "htm"];
export const WEB_BROWSER_FILE_VIEW_ID = "another-web-browser-file-view";
export const WEB_BROWSER_FILE_VIEW_ID = "surfing-file-view";

export class AnotherWebBrowserFileView extends FileView {
export class SurfingFileView extends FileView {
allowNoFile: false;

constructor(leaf: WorkspaceLeaf) {
Expand All @@ -14,7 +14,7 @@ export class AnotherWebBrowserFileView extends FileView {
async onLoadFile(file: TFile): Promise<void> {
const adapter = this.app.vault.adapter as FileSystemAdapter;
const urlString = "file:///" + (adapter.getBasePath() + "/" + file.path).toString().replace(/\s/g, "%20");
AnotherWebBrowserView.spawnWebBrowserView(true, { url: urlString });
SurfingView.spawnWebBrowserView(true, { url: urlString });
if (this.leaf) this.leaf.detach();
}

Expand Down
Loading

0 comments on commit 2bb495a

Please sign in to comment.