CG Local


#1

Hey there,

Some time ago I created a comment in the CG Sync discussion about Chrome moving away from Chrome Apps, and eventually removing the ability to run Chrome Apps on non-Chrome OS systems. This would mean that CG Sync would stop working, because it uses a Chrome App to watch the selected file for changes.

Therefore, I created CG Local. It is basically a copy of CG Sync that works with both Chrome and Firefox, and instead of a Chrome App it uses a Java app to watch the selected file for changes. Besides that, it also makes it easier to work in different files for different puzzles and is completely open-source.

Installation

CG Local consists of a browser extension and a Java application. The browser extension can be downloaded via the following links:

The application requires Java 8 (because of TornadoFX) and JavaFX. When using Linux, SDKMAN is a handy tool to manage various Java versions on one system.

The application can be downloaded here.

When using OpenJDK (instead of the Oracle JDK), note that OpenJDK does not come with JavaFX, which is required to run the application. On Ubuntu, you can install JavaFX with the following command:

sudo apt-get install openjfx

How to use

The first step to using CG Local is to make sure that the CG Local App is running. Then, open a puzzle and click on Settings in the sidebar. In the settings panel, toggle Use an external code editor on.

Now, you need to select a local file to synchronize with the CodinGame IDE. Open the CG Local App and choose whether you want to select a file, or use a previously selected file. The latter is only available when you have previously selected a file.

When you have selected a file, it is time to choose the first action. The three options are self-explanatory.

That’s it! You can now start working in your personal editor.

Settings

An explanation of the available settings, available via the gear icon in the top-right of the application.

Use one file for all puzzles (default: No)
When set to No, the “Previously selected file” will be different for every puzzle. This makes it easier to have a workflow where you use one file per puzzle. If you prefer to use one file for all puzzles, I recommend to set this to Yes.

Auto Play (default: Off)
When set to On, the current puzzle will automatically be played when the local file is changed.

Enable 2-way data binding (default: No)
When set to Yes, the CodinGame IDE will not be set to read-only mode so you can still use it. Changes in the CodinGame IDE will simultaneously be reflected in the local file. When Auto Play is also set to On, the puzzle will only be automatically played if you manually edit the local file.

Default first action (default: Ask me)
This specifies what happens when you select a file. When set to Download or Upload, the First Action part after you select a file is skipped. When set to Ask me, you will be asked what to do with the selected file every time you select a file.

Source

The source for both the extension and the application can be found on GitHub. Contributions are welcome.

Extension changelog

1.0.1 - January 3rd, 2018

  • Fix Chrome Web Store compatibility

1.0.0 - January 3rd, 2018

  • Initial release

Application changelog

1.1.0 - October 6th, 2018

  • Removed the FXLauncher dependency, which previously handled the auto-updating. Since the application is considered stable, this is no longer necessary. By removing FXLauncher, I am not required to keep up a webhost to host the files on, and the application will launch faster because it doesn’t have to do an up-to-date check.
  • Fixed font rendering issues on Linux
  • Fixed the “Open CodinGame” button on Linux

1.0.1 - January 4th, 2018

  • Fixed an issue where changes in vim and gedit were not detected properly

1.0.0 - January 3rd, 2018

  • Initial release

Known limitations

  • When you go from a non-CodinGame website straight to the IDE, CG Local does not work. Click on Back in the left sidebar and navigate back into the IDE via the CodinGame website.

#2

How do I run the jar file? I'm on Linux and the auto-launch fails and I get Could not find or load main class fxlauncher.Launcher if I do java -jar CG\ Local.jar

openjdk version "1.8.0_151"

Same thing happens with newest JRE.


#3

I have the local one running now -- using the newest JRE and not message up the path helps. :slight_smile:

But the connection isn't working in CodingGame.

Can I see logs anywhere?

The CGLocal client says "Listening on port 53135"


#4

Alright, I don't know why this happens exactly, but I was able to reproduce the bug in an Ubuntu VM and it seems to be the case that CG Local does not work with OpenJDK, but does work with the Oracle JDK.

I will look into the issue and update the launcher when it does work with OpenJDK, but till then the only advice I can give is to use the Oracle JDK (I tested it with 1.8.0_161).

By the way, logs should appear when running with java -jar CG\ Local.jar like this:


#5

I have it working after a few hiccups. I like it. This will help a lot.

A few notes for others:

  • It connects to 127.0.0.1, thus if using a proxy be sure that isn't proxied
  • Java keeps listening to the local address after ending (Ctrl+C) the program, thus wait a before launching again
  • If something goes wrong reload the CodinGame page and editor, then toggle the external edtiro on/off
  • If the connection works the external editor will turn to "On", if it stays "Off" or nothing is highlighted it isn't working.
  • The "Synchrnonizing " means the initial download worked,
  • Test that it works now by typing in the local file and pressing save.

#6

The issue with OpenJDK is that OpenJDK does not include JavaFX. When running on Ubuntu, that bug can be fixed by running the following:

sudo apt-get install openjfx

On other systems a similar command should be possible.


#7

Not directly related but:

With the Java Platform Module System in place since Java SE 9, it now more viable to decouple JavaFX from the JDK, in order to make it available as a separate download. This will make it easier for developers using JavaFX to have more freedom and flexibility with the framework. Moreover, with our focus on increasing the release cadence of OpenJDK, JavaFX needs to be able to move forward at a pace driven by the contributions from Oracle and others in the OpenJFX community. Oracle plans to implement this decoupling starting with Java 11 (18.9 LTS).

JavaFX was not the best choice :stuck_out_tongue: Will require a extra download in all OS in the future.

But thanks, I was searching this plugin for some time.


#8

Open JFX isn't that hard to install (on Ubuntu it's a simple sudo apt-get install openjfx), so I don't think it'll be a huge problem. The bigger problem is that, currently, CG Local is not compatible with Java versions greater than 8 because of the launcher that is being used.


#9

Hi, finally got your tool working @Jasperr! On ubuntu I went for the oracle-java instead of openJdk+openFX (I followed this tuto on medium to handle the different versions of Java). Thank you, my efficiency is already improving :slight_smile:


#10

No problem! The project is kinda on hold (it works, so there's no need to edit it), but if I ever find some motivation again I will look into packaging a compatible JRE + JavaFX with the application to get rid of the extra dependency.

If you want a better Java version manager, SDKMAN might be interesting for you. When installed, you can simply install Oracle Java 8 with sdk install java 8.0.181-oracle (and similarly with other versions/distributions/JVM-related software).


#11

Hi Jasperr,
I’m trying to install CG Local on Firefox on a Windows system. The extension seems to work well but I can’t download the CG App. The link https://jaspervanmerle.com/cg-local/files/CG%20Local.jar is broken. The site seems to be suspended. Like I’m not a Java devlopper I haven’t any tool to compile the source. Is there another link to download the jar file ?


#12

Whoops. I forgot that those files were still on that website, which I stopped paying for because I wasn’t using it anymore.

I will update the application this weekend (probably saturday, got other priorities at the moment) and release the jar file on GitHub. I’ll add a post to this topic once that’s done.

If you want to use it before that, you can clone https://github.com/jmerle/cg-local-app, move into the directory with your preferred commandline and run the application with the gradlew run command.


#13

I released version 1.1.0 of the application which fixes the issue. The application is now distributed as a single jar with all dependencies inside, instead of the previous version which was merely a launcher which downloaded all necessary files at runtime.

You can download the new jar file on the repository’s GitHub releases page. The readme of the repository and the initial post of this topic are updated to reflect those changes.


#14

Cool, thank you!