-
-
Notifications
You must be signed in to change notification settings - Fork 49
Tried writing a reference server using jdk httpServer #1026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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. 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. |
Hi @Vaivaswat2244 Thank you for your work on this, looking good! The current version of Processing is available to you in your code through |
hey @SableRaf @Stefterv , 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) |
Hey @Vaivaswat2244 that is correct, those are the values that are expected in the development build 😅 |
So should I commit the changes? |
There was a problem hiding this comment.
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. |
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