feat: add overleaf-create-file to create new project documents#33
Open
tigerjack wants to merge 4 commits into
Open
feat: add overleaf-create-file to create new project documents#33tigerjack wants to merge 4 commits into
tigerjack wants to merge 4 commits into
Conversation
Adds an interactive command `overleaf-create-file' that creates a new document on the Overleaf server (via the web API) and connects the current buffer to it, so a brand-new local file can be pushed to a project without first creating it in the web UI. - Cache each project's root folder id (captured from joinProjectResponse) in `overleaf--project-root-folders', used as the parent folder for new documents. - Add web-API helpers `overleaf--fetch-project-meta' (scrapes the CSRF token and root folder id from the project page) and `overleaf--http-post-json' (POST with informative status/body return). - Bind the command to `n' in `overleaf-command-map', add a menu entry, and document it in the README. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MCRf4hfJxiH76ic1TE4riS
After creating a new document and connecting, write the file-local variables (overleaf-url, overleaf-project-id, overleaf-document-id) as soon as the connection is established instead of waiting for the first edit, so a newly created file is bound and persisted right away. Adds `overleaf--persist-when-connected', a small poll-until-connected helper used by `overleaf-create-file'. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MCRf4hfJxiH76ic1TE4riS
Owner
|
hey sorry for the late response. my standards regarding AI submissions is that you have to be sure that /you/ understand the code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
I created this pull request because I find it useful. I don't know what your
policies are regarding AI-generated code, and I used a lot of assistance from
Claude.
Summary
Adds an interactive command
overleaf-create-filethat creates a new documentin the current Overleaf project and connects the current buffer to it. This lets
you author a file locally and push it to Overleaf without first creating it in
the web UI.
Motivation
Today a buffer can only connect to a document that already exists in the project
(the "Select file" prompt is built from the existing
rootFolder), so adding anew file means creating it in the browser first. This command closes that gap.
What it does
M-x overleaf-create-file(bound toninoverleaf-command-map) prompts fora name, creates the document on the server (
POST /project/<id>/doc), setsoverleaf-document-idto the returned id, and connects the buffer.overleaf-url,overleaf-project-id,overleaf-document-id) are written as soon as the connection is established, sothe new file is bound and persisted immediately.
Implementation
overleaf--project-root-folderscaches each project's root folder id, capturedfrom
joinProjectResponse, and is used as theparentFolderIdfor new docs.(The command therefore requires having connected to the project once in the
session; it errors with a clear message otherwise.)
overleaf--fetch-project-metareads the CSRF token (ol-csrfToken) from theproject page (and tries the root folder id from the page as a fallback).
overleaf--http-post-jsonperforms the POST and returns(status . body)sofailures surface the server response.
n.Testing
Verified against overleaf.com:
POST /project/<id>/docwith body{"name": ..., "parentFolderId": <rootFolderId>}and anX-Csrf-Tokenheaderreturns
200with{"name": ..., "_id": "<24-hex>"}, the file appears in theproject tree, and the buffer connects and syncs.
Notes
the
joinProjectResponsecache is the primary source.