Giter Site home page Giter Site logo

dlang-tour / core Goto Github PK

View Code? Open in Web Editor NEW
115.0 20.0 48.0 1.38 MB

D Language online tour (https://tour.dlang.org/) and online editor (https://run.dlang.io/)

License: Boost Software License 1.0

CSS 11.96% JavaScript 21.03% D 62.71% Shell 0.86% Dockerfile 2.36% NCL 0.58% Nix 0.50%
dlang-tour tour language learning introduction guide tutorial

core's Introduction

The Dlang Online Tour

Build Status

This is the D language online tour which provides an online introduction to this great system programming language with examples that can be edited, compiled and run online.

The most recent version of this tour can be seen here: http://tour.dlang.org.

Running offline

The tour can be downloaded for offline access:

git clone --recursive https://github.com/dlang-tour/core && cd core
git submodule foreach git pull origin master
dub

This requires DUB - D's package manager. DUB is part of the release installer and archives.

Specifying a language directory

For translator it's often convenient to clone their directory and run the tour only with their language. A custom language can be loaded directly using the -l / --lang-dir option with the path to the directoy of the to be loaded language:

dub fetch dlang-tour # only once
dub run dlang-tour -- --lang-dir .

Add Content

This repository contains the application that runs the tour. Please refer to english content or another language.

Further information on how to add or change existing content can also be found in the CONTRIBUTING.md.

Compile & Run

On a minimal Ubuntu system the following command will install the system packages needed to run all examples:

apt update && apt install \
    curl xz-utils unzip gnupg `# Needed for the install.sh script` \
    build-essential `# C toolchain for compiling and linking` \
    libssl-dev libevent-dev `# Vibe-d network dependencies`\
    libopenblas-dev `# lubeck computer library dependency` \
    libxml++2.6-2v5 zlib1g-dev `# LDC dependencies`

Make sure dub is installed and simply run dub in the dlang-tour folder:

git clone --recursive https://github.com/dlang-tour/core && cd core
dub

You might want to change the settings in config.yml to change the ports the tour is listening to.

OpenSSL 1.1

If you see linker errors regarding OpenSSL/1.1, try:

dub --override-config="vibe-d:tls/openssl-1.1"

Compiling & running of user source code

The source code on the tour can be compiled and then executed online and its output returned to the user. Therefore three different types of execution drivers have been implemented within the dlang-tour:

  • off: no online compilation allowed. If the user hits Runs an error message will be returned.
  • stupidlocal: an unsafe method that just runs rdmd on the local host system and returns its output. Very unsafe and musn't ever be used in production!
  • docker: runs dmd within a special Docker container (core-exec) and returns its output. The driver imposes the Docker container memory and execution time limits. Additional configurations options available in config.yml.

The execution driver is set in config.yml.

Caching of the program output can also be enabled in config.yml (exec.cache = true). Caching will only be enabled for the built-in default examples however.

Docker image

A Docker image is automatically built by Travis CI and pushed to the repository at https://hub.docker.com/r/dlangtour/core. The Dlang-Tour Docker container is configured to use Docker itself to compile and run D source code in the online editor. For that to work the host system's Docker /var/run/docker.sock Unix domain socket has to be mounted to work inside the container. A sandbox for compiling will then be started on the host system actually, and not within the DLang Tour Docker container itself.

The code for running the D compilers in a Docker sandbox can be found here: core-exec.

So to run the latest dlang-tour version in a Docker container, run the following command:

docker run -d --rm -p 80:8080 -e GOOGLE_ANALYTICS_ID=123 -v /var/run/docker.sock:/var/run/docker.sock \
	--name dlang-tour dlangtour/core

The tour will be available at your host system on port 80. To stop the container again just run:

docker stop dlang-tour

For further Docker foo please refer to the Docker documentation.

Note: The docker version inside the container must be compatible to that on the host system! Generally a newer version might run on the host system than within the container.

The Docker container is also the suggested way of dlang-tour's deployment.

Dlang Tour Bot

There is a friendly bot in place that listens to the events of all language repositories and triggers rebuilds and thus automatic deploments on a new change. More information about it can be found at it's repository.

Environment variables

GOOGLE_ANALYTICS_ID

default: (empty)

To enable Google Analytics please specify the environment variable GOOGLE_ANALYTICS_ID and set it to the tracking ID provided for your Analytics account.

GITHUB_TOKEN

default: (empty)

Required for exporting Gists to GitHub. Follow these instrutions to generate a CLI GitHub token.

EXEC_DOCKER_MEMORY_LIMIT

default: 256

Memory limit per started rdmd Docker container which compiles and runs the user code.

EXEC_DOCKER_MAX_QUEUE_SIZE

default: 10

Maximum number of parallel executions of the rdmd user code Docker container.

EXEC_DOCKER_TIME_LIMIT

default: 20

Time limit in seconds the rdmd Docker container with the user code is allowed to take until it is killed.

EXEC_DOCKER_MAX_OUTPUT_SIZE

default: 4096

Maximum allowed size in bytes of the generated user program's output.

Deployment

A deployment guide can be found in the deploy folder.

License

Boost License. See LICENSE.txt for more details.

core's People

Contributors

9il avatar andrejmitrovic avatar asib avatar bbasile avatar dependabot[bot] avatar dkorpel avatar dlang-bot avatar dmi7ry avatar geod24 avatar gitter-badger avatar jackstouffer avatar jinshil avatar kubo39 avatar ljmf00 avatar llaine avatar lodo1995 avatar looked-at-me avatar markuslaker avatar martinnowak avatar mtrenkmann avatar petarkirov avatar sergiors avatar stonemaster avatar uvtc avatar vladdesv avatar wilzbach avatar zek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

core's Issues

Store current editor content

When the user changed the source code in the editor the content will be lost as soon as another section is navigated to. The source code editor content should be saved somehow and restored to allow changing source and navigating through the content at the same time.
The Go Tour implements this by having a full stack Angular JS application that keeps the data on the client side. But this means more logic on client side and not on server/vibe.d side.

make text and code box fixed height and allow scrolling

again this is just an idea.
The idea is that both the left text and the right text box have a fixed height, so that the reader can always see the navigation menu at the bottom.
Moreover decoupling the two views allows to scroll in the code box without the text moving with your scrolling.
We could map the common navigation key (key {up,down}, page {up, down}) to currently focussed box and by default to left text box.

Allow navigation with keyboard controls

As per Mark Isaacson in the D mailing list:

An easy(?) suggestion that would make this easier to browse:
make the left/right arrow keys control advancing to the next
page.

send feedback about this page button

Make program output nicer

The program output looks awkward. Its size should be adapted and should fit the rest of the layout.

Use overflow: scroll property accordingly to support scrolling on long outputs.

Validate user output

In the node world Nodeschool is pretty popular:
http://nodeschool.io/#workshopper-list

You can see its online version here: http://generalhenry.com/

Their idea is pretty simple - download this guide and verification tool. Run it afterwards on your output to validate whether you did the right thing. Maybe the dlang-tour could do something similar to all those
algorithm contest websites (e.g. hackerrank supports D) and check the user output.

Cache next/previous links

The links to the next and previous section (or chapter) are calculated on each request. This could be cached easily with memoize or something similar from the standard library.

Support mobile devices correctly

The Dlang Tour is using Bootstrap but the layout should be tweaked to at least support mobiles devices like IPads. I have an IPad Mini and the layout break the content and the source code editor in two rows which looks weird. I would be in favour of also having the source side by side to the content.

Interactive tutorial for third-party libraries?

Hi! I'm developing a library that generalizes ranges so they can be used in more contexts like for example async IO and metaprogramming. In the long term I plan to propose it for std.experimental, but first I need to introduce people to some new concepts and techniques, before I can convince them that it's a worthwhile addition.

So, obviously I was thinking about making a tutorial for my library, but then I noticed your project and I thought that it would be great if I could use it to present my library and to let others play with it.

What do you think about letting other people make tutorials about their libraries and to publish them on dlang-tour (of course, after your permission)? This would require some basic dub support (in order to specify external dependencies) and maybe some small reorganization (maybe adding a third-party drop-down, next to vibe-d).

Speaking of DUB, I'm willing to contribute a tutorial for it, but I haven't looked at your backend code, so I don't if it would be a large effort to support it in addition to rdmd.

Don't make bottom fixed in browser

As per Bubbasaur's suggestions, don't make the bottom bar fixed as it is a waste of space. The behaviour just has been copied from the Go tour.

Collect telemetry about usage

Collect visits per section, number of compiles (incl. failures) and create overview page to show usage stats of the tour.

Add link to GitHub repository in webinterface

Add something like a "Fork me on GitHub" or report issues on GitHub button somewhere on the webpage (without being too intrusive) so that users can report issues and send pull requests directly to the right place.

Expand source code editor if space is left

According to Mark Isaacson's comment:

My one complaint is that the section of the screen that contains the code doesn't scale well vertically when my browser window is large. The written explanations scale to fit the content, the code editor does not. I'd just make it stretch vertically to fill the screen :). At that point you might also consider putting the Run/Reset buttons at the top.

Use SSL

It seems to be a general trend to use ssl and nowadays Google puts that into their ranking too. Thanks to the letsencrypt project we can have ssl for free :)

Hide empty source code editor directly in DIET Template

Instead of using AngularJS to show or hide the source code editor this should be done statically with D syntax of DIET templates. Currently there the source editor might quickly flash when loading the page and this could be prevented by just not rendering the source code editor when not needed.

Larger font size for bottom controls

To increase usability of bottom bar maybe the section titles could be added to the next and forward links. This sould only be done if the mobile layout isn't broken by this feature!

More links to API documention

I think it would be nice if a method is mentioned that we provide links for the reader to deeper dive into the docs - they support anchors ;-)

I think just linking inline should be okay.
If possible a "Resources" list at the bottom (or "Dive deeper") would be cool too for a couple of pages.

Use CDNs where appropriate

Bootstrap, Angular and maybe other libs used support using CDNs. So more bandwidth is saved on the servers running the tour because basic libraries are loaded from e.g. Google CDN. And loading the tour should be faster because the client either has those libs cached already and is able to open more concurrent connections.

Docker: make sandbox configuration available through env variables

The following configuration block should be configurable through environment variables in the Docker container:

    # For docker driver
    config:
        memory_limit: 256
        maximum_queue_size: 10
        time_limit: 10
        maximum_output_size: 4096

This is needed to adapt to different production servers.

Allow language selection

The content and the internal content representation have been designed to allow translations but this should be also reflected in the frontend and made available to users.

Adapt fonts

In an effort to make it similar to dlang.org ...

content left, code right

As we all are used to read content from the left to right, it makes sense to have the explanation and description on the left as the GoLang Tour does.

edit this page button

Would be convenient if we would have an edit this page button, s.t. people can easily reach this repo and help to improve the content.

Cache program output

As we don't allow networking or file writes, pretty much anything could be cached. We might of course search for exception (e.g. time if we can't fix this like on the GoTour, see below). The reason for this is obvious, most of the time the user directly click on run without changing the file, so spawning a new docker container and compiling the file just takes unnecessary time.

Btw citing from the GoTour.

In the playground the time begins at 2009-11-10 23:00:00 UTC (determining the significance of this date is an exercise for the reader). This makes it easier to cache programs by giving them deterministic output.

provide dfmt via format

just an idea: automatic code formatting could be quite a help for newbies. For D the tool is called dfmt.

use tour.dlang.io

I already created an A entry to 46.101.210.109, so feel to change your server config.

contributing.md file

Github will display a link to this file on every issue & PR - might be a good opportunity to highlight some key points and link to other README's (e.g. the one at public/content)

Mobile-friendly/responsive view

After having had a look at the Go and Rust tour, which are both nice to read on one's phone - I think we can do a better than this

screenshot_20160513-100120

Some ideas

  • move the example code below the text on mobile
  • use the responsive dlang.org menu
    -...

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.