Tried writing a reference server using jdk httpServer by Vaivaswat2244 · Pull Request #1026 · processing/processing4
This PR introduces ReferenceServer.java, a lightweight HTTP server to serve Processing's reference documentation locally. It replaces the previous approach with a more maintainable and efficient solution using Java's built-in HttpServer.
Changes Implemented
-
Used com.sun.net.httpserver.HttpServer from the JDK
-
Handles different MIME types (HTML, CSS, JS, images, etc.).
-
Runs on a separate thread to avoid blocking the main Processing IDE.
Later in this pr I will add the download modifications in the JavaEditor.java file, which is the only file find I found where the WebServer was being used
Maintainer edit: Fixes #980
- To see the specific tasks where the Asana app for GitHub is being used, see below:
Nice work @Vaivaswat2244!
I didn't have a close look at the code but the server runs fine for me. I left a minor comment about the JDK version. Feel free to mark this as a draft PR and switch it back when it's ready for a review.
Looking forward to seeing the download part!
Thanks for your contribution 💙
I updated the source link for the download and also replaced the WebServer class.
The download is getting completed and the reference zip folder is getting stored on
/home/[username]/sketchbook/reference.zip (using ubuntu)
Now I'm not sure how to automate this version checking system. I researched a bit and found that using Github apis is the most suitable way for tracking version. I can try that.
Also wanted to know if this is what we intended with the issue originally
Hi @Vaivaswat2244 Thank you for your work on this, looking good! The current version of Processing is available to you in your code through Base.getRevision() and Base.getVersionName()
hey @SableRaf @Stefterv ,
I made this function as suggested using Base.getVersionName(); and Base.getRevision() and used it in the
private void downloadReference() { try { URL source = new URL(getReferenceDownloadUrl());
private String getReferenceDownloadUrl() { String versionName = Base.getVersionName(); String revision = String.valueOf(Base.getRevision()); System.out.println("Processing Version Name: " + versionName); System.out.println("Processing Revision: " + revision); if (versionName != null && !versionName.isEmpty() && revision != null && !revision.isEmpty()) { String url = String.format( "https://github.com/processing/processing4/releases/download/processing-%s-%s/processing-%s-reference.zip", revision, versionName, versionName); System.out.println("Generated URL: " + url); return url; } else { System.out.println("Using fallback URL"); return "https://github.com/processing/processing4/releases/download/processing-1300-4.4.0/processing-4.4.0-reference.zip"; } }
In logs I got Version Name: "unspecified" and Revision: 2147483647 (which is Integer.MAX_VALUE)
I'm not sure as though why is it happening. Is it because the development build doesn't have proper version info or something else
Hey @Vaivaswat2244 that is correct, those are the values that are expected in the development build 😅
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you!
If you can delete the old WebServer.java as well that would be great, otherwise we'll delete it later.
Sure @Stefterv, I have deleted the WebServer class as well.
Hi @Vaivaswat2244 Thank you for reaching out! The PR looks good and will be included in the next version of Processing when we're ready to ship the next beta.
If you are interested in contributing further feel free to ask to be assigned to any other issue.