显示 HN:简单的 org-mode 网络适配器
Show HN: Simple org-mode web adapter

原始链接: https://github.com/SpaceTurth/Org-Web-Adapter

这是一个用Python、HTML和CSS构建的轻量级本地Web应用程序,用于浏览和编辑Org文件。它提供一个3面板的用户界面——一个用于导航的侧边栏、一个主要内容区域和一个反向链接面板——通过扫描指定的“notes”目录中的`.org`文件来实现。 该应用程序动态解析内部链接(基于文件和ID),并显示反向链接,提供搜索、排序(按反向链接或日期)、随机排序以及跳转到当前笔记按钮等功能。编辑功能直接在浏览器中支持,具有保存功能和状态消息。 主要功能包括内联MathJax渲染、亮色/暗色主题以及针对桌面和移动设备优化的响应式布局。配置(绑定地址/端口)通过`config.yaml`管理,并提供命令行覆盖选项。**重要提示:**该应用程序缺乏身份验证和加密,因此应仅在受信任的网络上使用。它旨在保持简单和新鲜,每次请求都会重新扫描文件,而不是针对极大的笔记集合进行优化。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 展示 HN: 简单的 org-mode 网络适配器 (github.com/spaceturth) 12 分,由 turth 发表于 41 分钟前 | 隐藏 | 过去 | 收藏 | 讨论 我喜欢使用 org 文件,但我想在手机上浏览和编辑它们。昨天我用 Codex 制作了这个简单的单文件 Web 服务器,它只是显示所有带有反向链接的 org 文件。因为它只在我的 WireGuard VPN 上运行,所以没有身份验证。我玩得很开心,希望对其他人有用! 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系方式 搜索:
相关文章

原文

A lightweight local web app for browsing and editing Org files.

The app is implemented as a single Python server (main.py) plus one HTML template (templates/index.html) and one stylesheet (static/style.css). It scans a notes directory for .org files and renders a 3-pane UI.

⚠️ There is no authentication or encryption, only run this service on trusted networks. ⚠️

Desktop view

Mobile view

  1. Symlink your notes directory to notes.
  2. Edit the bind address and port in config.yaml if desired.
  3. python3 main.py.
  1. main.py starts an HTTP server.
  2. On each page request (GET /), it rescans the notes directory for .org files.
  3. It resolves links/backlinks and builds HTML fragments.
  4. It injects those fragments into templates/index.html placeholders:
    • {{NAV_ITEMS}}
    • {{MAIN_CONTENT}}
    • {{BACKLINKS}}
  5. Browser JS in templates/index.html handles client-side interactions (search, shuffle, sorting, jump-to-current, theme toggle).

Server-side components (main.py)

  • File discovery and parsing:
    • scan_org_files(...) recursively finds .org files.
    • Extracts title from #+TITLE: and ID from :ID:.
  • Org link/backlink handling:
    • resolve_link_target(...) supports file:... and id:... links.
    • find_backlinks(...) computes notes linking to the selected note.
    • build_backlink_counts(...) computes backlink totals for sorting.
  • Rendering:
    • render_org_to_html(...) converts headings (*, **, ...) and paragraphs to simple HTML.
    • render_line_with_links(...) converts org links in text to clickable app links where resolvable.
    • truncate_label(...) caps sidebar labels to 32 chars with ....
  • Editing:
    • POST /edit updates a selected .org file and redirects back with status flags.
  • Static files:
    • serve_static(...) serves files under static/ with path traversal protection.
  • templates/index.html:
    • Base layout markup.
    • Sidebar controls.
    • Small JS controller for filtering/sorting/shuffling nav links.
    • MathJax initialization for inline $...$ rendering.
  • static/style.css:
    • 3-column desktop grid and stacked mobile layout.
    • Independent scroll regions for note list and backlinks.
    • Mobile note-list cap (about 5 notes visible before scrolling).

Startup config is read from config.yaml by default.

  • bind_addr: host/IP to bind
  • bind_port: TCP port (must be 1..65535)

Notes:

  • If config.yaml is missing, defaults are 127.0.0.1:8000.
  • CLI flags --host and --port override config values.
  • You can choose a different config file with --config /path/to/config.yaml.
python3 main.py --dir notes
python3 main.py --host 127.0.0.1 --port 9000
python3 main.py --config ./config.yaml
python3 main.py --no-browser
  • Recursive .org file discovery.
  • Sidebar note list with active-note highlighting.
  • Title/path search filter.

Sidebar ordering controls

  • Shuffle notes.
  • Sort by backlink count (descending).
  • Sort by created date (ascending).
    • Notes without timestamps are treated as older than notes with timestamps.
  • Jump to current note button.
  • Right sidebar lists notes linking to the current note.
  • Supports both file: and id: link resolution.
  • Toggle Preview/Edit for the selected note.
  • Save changes from browser to disk.
  • Inline status messages for save success/errors.
  • Inline math rendering via MathJax using $...$ delimiters.
  • Light/dark theme toggle (persisted in localStorage).
  • Desktop: independent scrollable sidebars.
  • Mobile: notes list capped with its own scroll area.
  • Sidebar text truncation with ellipsis and tooltip for full text.
  • main.py: server, parsing, rendering, routing.
  • templates/index.html: page template + UI behavior JS.
  • static/style.css: styling and responsive layout.
  • config.yaml: bind config.
  • notes/: notes directory (can be a symlink).
  • old_notes/: alternate local notes snapshot.
  • Not a full Org parser; rendering is intentionally simple.
  • Notes are rescanned on each request (simple and fresh, but not optimized for huge note sets).
  • Math rendering depends on loading MathJax from CDN.
联系我们 contact @ memedata.com