Giter Club home page Giter Club logo

ep_codingdojo's Introduction

Etherpad Coding Dojo

Screenshot

What is this?

An Etherpad Plugin to run a command on the server using the pad's text as an input (file).

Warning: This plugin does execute the (compiler) command unchecked, and without any kind of protection. You can corrupt your system easily. Do not enable this plugin on an Etherpad for users which can't be trusted. It is highly recommended to protect the web server with features like a virtual machine, container, jail when running this plugin. See the section 'Docker container' below how to build a docker container with this software.

History

2021-12-08 start development

License

Apache 2

Author

Dirk Jagdmann [email protected]

Funding

If you want to support the development of this plugin, consider making a payment to the author's PayPal account: https://paypal.me/dojcubic

Links

https://github.com/doj/ep_codingdojo https://github.com/ether/etherpad-lite https://github.com/ether/etherpad-lite/wiki/Creating-a-plugin https://nodejs.org/dist/latest-v17.x/docs/api/documentation.html

Development Install

This etherpad plugin needs the current "develop" branch of the etherpad-lite source code.

mkdir /opt/
cd /opt/
git clone https://github.com/doj/ep_codingdojo.git
git clone https://github.com/ether/etherpad-lite.git
cd ep_codingdojo
make run

Docker container

The following instructions build a docker container:

git clone https://github.com/ether/etherpad-lite.git
cd etherpad-lite
wget https://github.com/doj/ep_codingdojo/raw/main/Dockerfile
# you may need to edit src/package-lock.json and change "lockfileVersion" to 2
docker build --tag $USER/etherpad .

For more instructions how to build a docker container for Etherpad see https://github.com/ether/etherpad-lite/blob/develop/doc/docker.md

To run the docker container:

docker run --publish 9001:9001 -e ADMIN_PASSWORD=admin -e PAD_OPTIONS_USE_MONOSPACE_FONT=true -e COMMIT_RATE_LIMIT_POINTS=20 $USER/etherpad

And use the following URL http://localhost:9001

To clean up the docker container and image:

docker container prune -f
docker image rm $USER/etherpad
docker image prune -f

Examples

This section lists examples how to use many programming languages with the plugin. These examples are all working with the docker image of the previous section.

Ada

with Text_IO; use Text_IO;
procedure hello is
begin
   Put_Line("Hello Ada");
end hello;

=====gnatmake @hello.adb@ && ./hello=====

Algol 68

printf(($gl$, "Hello Algol"))

=====a68g @a.alg@=====

Assembly x86-64

global _start
section .text
_start:
  mov rax, 1
  mov rdi, 1
  mov rsi, msg
  mov rdx, msglen
  syscall
  mov rax, 60
  mov rdi, 0
  syscall
section .rodata
  msg: db "Hello x86", 10
  msglen: equ $ - msg
=====nasm -f elf64 -o a.o @a.s@ && ld -o a.out a.o && ./a.out=====

Bourne Again Shell

echo "Hello Bourne Again Shell"

=====bash @a.sh@=====

C++

#include <cstdio>
int main() {
    printf("Hello C++\n");
    return 0;
}

=====c++ -Wall -std=c++20 @a.cpp@ && ./a.out=====

C#

Console.WriteLine("Hello C#");

=====csharp @a.cs@=====

C Shell

echo Hello C Shell

=====tcsh @c.sh@=====

D

import std.stdio;
void main()
{
  writeln("Hello D");
}

=====gdc @a.d@ && ./a.out=====

Fortran

program hello
  print *, 'Hello Fortran'
end program hello

=====gfortran @a.f90@ && ./a.out=====

Go

package main
import "fmt"
func main() {
  fmt.Println("Hello Go")
}

=====go run @a.go@=====

Groovy

println "Hello Groovy"

=====groovy @a.groovy@=====

Lisp, Scheme, Guile

(display "Hello Lisp")
(newline)

=====guile @a.scm@ 2>/dev/null=====

Java

public class Main {
  public static void main(String[] args) {
    System.out.println("Hello Java");
  }
}

=====javac @Main.java@ && java Main=====

JavaScript

console.log('Hello JavaScript')

=====node @a.js@=====

Lua

print 'Hello Lua\n';

=====lua @a.lua@=====

Makefile

The default Etherpad configuration doesn't allow tab characters in pads. Etherpad typically replaces tab characters with spaces. Makefiles however require commands to start with a tab character. This example compile command works around this by replaceing 2 or more space characters at the start of the line with a single tab character. This allows to edit a Makefile in Etherpad and have it compile.

Alternatively you can install the ep_special_characters plugin, which allows to insert any unicode character into the pad. However the first 32 control characters are shown with a blank square. To insert the tab character, select the 9th square.

all: Hello World

Hello:
    @echo -n 'Hello '

World:
    @echo 'World'

=====perl -i -pe 's/^\s{2,}/\t/' a.mak ; make -f @a.mak@=====

Matlab, GNU Octave

disp('Hello Matlab')

=====octave @a.m@=====

Objective C

#include <stdio.h>
int main(void)
{
   printf("Hello World\n");
}

=====gcc -lang objc @a.m@ && ./a.out=====

OCaml

print_string "Hello OCaml\n"

=====ocaml @a.ml@=====

Pascal

program Hello;
begin
  writeln('Hello Pascal');
end.

=====fpc @a.pas@ && ./a=====

Perl

use strict;
print "Hello Perl\n";

=====perl @a.pl@=====
Hello World

PHP

<html>
 <body>
 <?php echo '<p>Hello World</p>'; ?>
 </body>
</html>

=====php @a.php@=====

Prolog

:- initialization hello_world, halt.
hello_world :-
    write('Hello Prolog'), nl.

=====swipl -q -l @a.pl@=====

Python

print "Hello Python";

=====python @a.py@=====

R

print("Hello R")

=====Rscript @a.r@=====

Ruby

puts "Hello Ruby"

=====ruby @a.rb@=====

Rust

fn main() {
  println!("Hello Rust");
}

=====rustc @a.rs@ && ./a=====

SQL

create table t(a varchar(20));
insert into t(a) values('Hello'),('SQL');
select * from t;

=====sqlite3 a.db < @a.sql@=====

TCL

puts {Hello TCL}

=====tclsh @a.tcl@=====

XSLT

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="p">Hello XSLT</xsl:template>
</xsl:stylesheet>
=====true @a.xslt@=====
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="a.xslt"?>
<p>this is replaced</p>
=====xsltproc a.xslt @a.xml@=====

Z Shell

print Hello Z Shell

=====zsh @z.sh@=====

TODO

Maybe support for the following languages can be added to the docker image:

Compiler command line

The ep_codingdojo plugin will search in the pad's text for a line starting with 5 or more equal characters and ending with 5 or more equal characters. If the plugin finds such a line, it will attempt to parse it as a compile command. If the parsing is successful, the compile command will be used to compile the pad's text preceeding the compile line and the compile's output will be appended to the pad after the compile line.

The compile line can have any (unix) command line, which is executed with the system's native shell. The plugin will look for a special filename placeholder. The filename must be enclosed in ampersand characters. The plugin will write the source code (pad text above the compiler line) to the specified file name.

writing multiple files

Multiple compile lines can be present in the Etherpad text. Every time a compile line is found, the text preceeding the line will be written to a file and the command will be executed. Use a command which doesn't do anything like "true" to only write a file. See the XSLT example above.

show column numbers

If the compile command is 'showcols', a header with column numbers is added to the output text.

=====showcols=====

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.