Giter Club home page Giter Club logo

treema's Introduction

CodeCombat

Build Status Coverage Status

CodeCombat is a multiplayer programming game for learning how to code. See the Archmage (coder) developer wiki for a dev setup guide, extensive documentation, and much more to get started hacking!

It's both a startup and a community project, completely open source under the MIT and Creative Commons licenses. Since it's a game (with really cool tech), it's really fun to hack on. Join us in teaching the world to code! Your contribution will go on to show millions of players how cool programming can be.

Whether you're novice or pro, the CodeCombat team is ready to help you implement your ideas. Reach out on our forum, our issue tracker, or our developer chat room on Slack, or see the docs for more on how to contribute.

MIT for the code, and CC-BY for the art and music. Please also sign the CodeCombat contributor license agreement so we can accept your pull requests. It is easy.

Note: the levels on codecombat.com are not open source.

API

We offer a partner API for SSO, user management, progress data, etc., with API docs here and SDKs here. You'll need client credentials, so get in touch with us if you have a use case for that.

For the very simplest case that can power some data integrations with your CodeCombat account, you can fetch https://codecombat.com/db/user/your-user-name-or-id to get some user progress stats. For example, Beeminder uses this API to help you commit to learning to code.

Nick Winter George Saines Scott Erickson Matt Lott Catherine Weresow Maka Gradin Rob Blanckaert Josh Callebaut Michael Schmatz Josh Lee Dan TDM Alex Cotsarelis Alex Crooks Alexandru Caciulescu Andreas Linn Andrew Witcher Axandre Oge Bang Honam Benjamin Stern Brad Dickason Carlos Maia Chloe Fan Dan Ristic Danny Whittaker David Liu David Pendray Deepak1556 Derek Wong Dominik Kundel Glen De Cauwsemaecker Ian Li Jeremy Arns Joachim Brehmer Jose Antonini Katharine Chan Ken Stanley Kevin Holland Laura Watiker Michael Heasell Michael Polyak Mischa Lewis-Norelle Nathan Gosset Oleg Ulyanicky Paul Buser Pavel Konstantynov Popey Gilbert Prabhsimran Baweja Rachel Xiang Rebecca Saines Robert Moreton Ronnie Cheng Ruben Vereecken Russ Fan Shiying Zheng Sébastien Moratinos Thanish Muhammed Tom Steinbrecher Yang Shun Tay Zach Martin

treema's People

Contributors

dkundel avatar gintau avatar jayantj avatar nwinter avatar sderickson 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  avatar

treema's Issues

Removing array members doesn't trigger change callback

If I select some Treema nodes and hit delete to delete them, my "change" callback on the root Treema node (their parent array node) doesn't fire. (It does fire when I edit any of the values in any node.)

You can see what I mean by deleting any Thangs from the current CodeCombat level editor. They don't disappear from the map until some other change is made which makes the World reload or the Treema change callback fire.

Split logic for specific node into a strategy class, rather than subclasses

Each Treema node represents one property in the json data. There are some things that are universal about a node, like how it handles navigation or that it has a working schema, or its state and path. There's also logic mixed in that is to be overridden by subclasses, like how to edit or render the value. Possibly split this logic into the generic Treema node class and the Treema strategy class. This will mainly be good for cases when a node changes its working schema; you don't have to swap in the Treema node object instance if you can just swap in a strategy object. Consider having the strategy object be a singleton that gets passed in all relevant state, and leaving the generic node class to maintain state.

Create utility function for determining child working schemas

When Treema creates the child of a node, it needs to determine the working schema of that child. Working schemas are denormalized versions of a JSON-schema where the combinatorial schema definitions (anyOf, allOf, oneOf) and references are respectively flattened and dereferenced into a series of simpler schemas Treema can choose from and build based off. See buildWorkingSchemas for how it does this. Most of the time, the working schema is just the schema in the properties array for the given key, or the schema of the items property, but there are these more complicated cases.

Currently the system determines working schemas in the static function make, but choosing working schemas would be useful on its own. Pull out a utility function that, given a parent schema, a tv4 instance (needed for dereferencing) and a key (or index), returns an array of working schemas. This will allow any system to walk through json data and determine, for each property, the working schemas for that property and, through tv4 validation of the extant value, figure out on its own which working schema to use.

Support "autoPopulate" in addition to "default" and "required"

For objects, it will be really handy to have an autoPopulate array so that one could do schemas like this:

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "name": {
        "type": "string",
        "default": "My Project"
      },
      "description": {
        "type": "string",
        "default": "A project I worked on.",
      },
      "picture": {
        "type": "string",
        "format": "image-file",
      },
      "link": {
        "type": "string",
        "default": "http://example.com"
      }
    },
    "required": [
      "name",
      "description",
      "picture"
    ],
    "autoPopulate": ['link']
  }
}

instead of like this:

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "name": {
        "type": "string",
        "default": "My Project"
      },
      "description": {
        "type": "string",
        "default": "A project I worked on.",
      },
      "picture": {
        "type": "string",
        "format": "image-file",
      },
      "link": {
        "type": "string",
        "default": "http://example.com"
      }
    },
    "required": [
      "name",
      "description",
      "picture"
    ],
    "default": {
      "name": "My Project",
      "description": "A project I worked on.",
      "link": "http://example.com",
      "picture": ""
    }
  }
}

The difference is that we don't need to mirror the default values in two places–the autoPopulate will specify that by default, we will include the link property, and the default value can be grabbed from the leaf just like when we auto-populate required properties.

Selection behavior on delete is broken

28d0ead

This test has been disabled. Probably it was broken due to changes to how refreshing works. Will need to be careful bringing this back, since it will probably conflict with other fixes.

Defaulted boolean fields can get into a weird focus-absorbing selected state

If I have a defaulted boolean Treema like either of these:

screenshot 2014-09-16 11 22 20

If I click on the key (exists) to select it:

screenshot 2014-09-16 11 22 31

Then press tab (which will also happen whenever tabbing through fields and hitting a defaulted boolean value), I get into this weird state:

screenshot 2014-09-16 11 22 39

Now pressing tab (or anything other than enter, t, or f) will have no effect. Also, I can't get rid of that state by clicking anywhere except the value (not even the key or another Treema). It also continues to absorb keypresses. For example, I can't type a commit message in here because that state is still absorbing all focus:

screenshot 2014-09-16 11 23 41

Treema can't update parent containers when setting null values by changing schema selection

screenshot 2013-11-16 21 27 31

There's no way to get the parent to update after I change worldEndsAfter from type: float to type: null.

I often used to have the same problem trying to save containers where I have changed a boolean, but at least then certain keyboard interactions to change the value will update the parent, so I could work around it. For null, there's no way to toggle a value change, so I can't save it.

Change the add child piece into a treema-row

Right now the DOM element for adding an item to an array or a property to an object receives a unique focus. Instead, give it a Treema node row so that it can be selected like any full fledged Treema row. Not sure how best to share that logic. Possibly have the add property/item row be a subclass to a common superclass with the Treema node. When it's done, update the navigation systems (pressing tab, enter, or arrow keys) to make sure they still work.

Read-Only Treema allows changing sound

I was checking out a bug from codecombat where there was trouble uploading sound files. I managed to select a different sound file in the Treema for a Thang Type that was read-only (verified by trying to edit other fields), using the dropdown menu. The dropdown toggle that displays this menu should have been disabled as well.

Alright, looks like I've come to the wrong place. Sound files are an add-on by Code Combat implemented by the class SoundFileTreema.

However there's something else I found can be toggled that is native to Treema: Treema Booleans.
Will look into this.

Enter key doesn't work in Systems

In Level editor, under Systems tab, while adding a configuration under UI v0, config is not added if Enter/Return Key is pressed unlike other cases, while it works if Tab key is pressed.

Add a checking callback before deleting a node.

Hello @sderickson,

According to CodeCombat #507, components should care about their dependencies before being deleted. Currently the deleting action is handled by treema, but dependencies are found by thang editor. So I'm thinking about adding a callback (passed by constructor) in onDeletePressed() or in removeSelectedNodes(). If the callback exists and return false, then treema should prevent deletion from proceeding. How do you think?

Figure out better, generic ways to have strategies get context data

Take for example the point node in the level editor. It knows to open a modal for the given level through data options that are passed in on the creation of the root Treema node. Is there a better way to do this? Can Treema nodes be made to be more context independent? The less we have to pass in contextually, the better. Possibly this just has to be done node by node, using things like backbone mediator to send out generic notifications or by sharing data such as component names through globally accessible routes. The benefit is that for views like the delta view, it can get complete data on the properties that are changed.

Keybindings like ctrl+c and ctrl+v doesn't work

While editing components, I was not able to copy some content of a field and paste it onto another using common key-bindings ctrl+c and ctrl+v.
Though right clicks work in the fields which solved the purpose.
-Karan Dhamele

Improve insert/deletion performance

Right now when refreshing an array or object property, the children are updated in the least efficient way, by closing and reopening the property, thus rebuilding each and every child node. This is a really dumb but effective way to do this. Find a smarter but still effective method.

Clear text button

Cool interfaces for the win but the Treema needs a clear text button.

Schema select button intercepts clicks on value field

When you have a property that can have multiple schemas, if you go to click on the value field to edit it, the schema select button intercepts the click instead. In order to edit the value, you have to click the key and then tab over to the value. Instead, you should be able to just click the value.

screenshot 2014-03-08 08 28 48

In this screenshot, if I click "radians", it's as if I clicked on the "S" to the left of it:

screenshot 2014-03-08 08 29 41

Updating a boolean field in the tree is not updating the data

To reproduce the issue:

  • get the latest version of treema from github
  • open the file in a browser(chrome) treema/dev/demo.html
  • in the section, "Basics: A Contact Book", expand "Google" and add the field "friend" and choose false.
  • look at the Data tab, it shows: friend = false
  • go back to the Treema tab, update the friend value to true
  • go to the Data tab, the friend value was not updated

By looking at the source code, it seems that somehow, updating a BooleanNode does not trigger the refresh of the data of its parent node.
It might not be the best way to fix that but adding the following call in the method BooleanNode.toggleValue:
this.flushChanges();
seems to fix the issue.

Adding elements to arrays.

Sorry to bother with howto questions in issues section, but couldn't find any other place to ask it.
I'm using DatabaseSearchTreemaNode.extend(MyTreemaNode); to create a list of available values to add as a new array element.
After click on one of search result rows - it's being added as a
<div class="treema-value treema-search treema-display">"element name"</div> But to really push this element to array - user must activate this new row by mouse clicking on it (creates input element atm) and than press enter key to submit it.
I tried simulate same events with $, but it ain't work.
Is there any native way to skip this 'double-submit' and add new elements to array right after clicking on search result rows?

Doesn't really load on HTTPS because it includes brunch ws:// websockets

From the forum: if you directly load http://codecombat.com/play/ladder/gold-rush, it's okay. But if you use https, it throws an error because TreemaNode wasn't loaded properly: http://codecombat.com/play/ladder/gold-rush

screenshot 2014-12-31 11 36 18

Looks like Treema is somehow still trying to connect to brunch even in production use in CodeCombat, and when in HTTPS, this fails due to an insecure web socket. Now with the new module loader, this makes Treema not load at all.

Make it easier to leave defaults defaulted after having merely selected a field

With the new defaults, we often end up with a situation like this:

screenshot 2014-09-16 11 15 43

If I press tab or enter in order to save my edit by navigating away from the field, then I get this:

screenshot 2014-09-16 11 16 36

Now there's nothing I can do to avoid the maxAcceleration becoming set to 100 instead of being left as a default of 100:

screenshot 2014-09-16 11 17 29

After which I have to click on the field name (not value) and hit "delete" to restore it to default state. The only other workaround is to deselect the field by clicking with the mouse.

The result is that we get a lot of accidentally overwritten defaults.

What if instead we don't assign the values of fields if they are the same as the default? Or if we only do so when pressing enter, not tab?

limit choices doesnt work under safari

Ive been trying to use Treema under phonegap for an iphone app - I have found that both phonegap (based on WKwebkit and therefore safari) and desktop safari on Mac OS10 seem to break the limitChoices function. Ie if a schema is defined - say a number - and you enter instead some letters and press return instead of rejecting the input the entire node disappears. You can verify this via the demos on http://codecombat.github.io/treema/demo.html - go to the Custom Node demo and instead of 3 or 4 as the coordinates, enter a few letters and hit return - the entire node disappears. BTW this is a really useful plugin thank you.

canAddProperty errors out if the schema has no properties field

I have a schema that defines a certain object like this:

{
 "type": "object",
 "patternProperties": "<someRegex>",
 "additionalProperties": true
}

Notice that there's no properties field but there is a patternProperties field.

However, when I try to add an object to that node, treema errors out with Uncaught TypeError: Cannot read property '<property>' of undefined with the culprit being in the following generated check on the canAddProperty method (line 3097 on my file):

      if (this.workingSchema.properties[key] != null) {
        return true;
      }

I changed the above check to

      if (this.workingSchema.properties && this.workingSchema.properties[key] != null)

and it worked nicely. I don't coffescript so I can't send a PR with the fix.

patternProperty content type isn't checked correctly

I need a patternProperty for my Mongo query, which can hold just about any keys. Currently I'm testing with

patternProperties:
    '^[-a-zA-Z0-9_]*$': { type: 'string' }

Yet treema allows me to pick any type (with its little menu thingie).
However, if I hardcode my test property called 'levelID', it gets recognized correctly, like so.

properties
    'levelID': { type: 'string' }

I don't mind checking this myself at all but I have to be off for a bit and I was hoping anyone could point me in the right direction of where a property's contents are verified against.

Recap: patternProperties ignore the type I define them with even though they get matched. Moreover, I put some faulty stuff in there which Treema threw errors at, so it does get checked.

Fix select multiple row logic

Right now if you select one row and then shift click another row, it doesn't properly select the rows between inclusive.

Schema select not working?

screenshot 2014-05-29 15 36 23

In this example, you can click str, but it doesn't let you open the schema select. Here is the config schema property for offset:

screenshot 2014-05-29 15 38 06

Add an option whether to show the root Treema node

Migrating from codecombat/codecombat#1259:

Oh, it's because the root node is always hidden. It's assumed to be a collection (an array or object) and that's why we don't usually show treemas in the patches for anything but collections. Think of all the treemas throughout the site, all of them have top-level collection nodes which are kept out of sight but always open.

I would add an option to treema which would add a class to the root node that triggers a rule to override the &.treema-root > .treema-row .treema-value, &.treema-root > .treema-row .treema-type-select rule at the top of base.sass

Holding "backspace" in a text field continues to delete nodes in Treema

On Windows Chrome, if you create a node in Treema that takes text input, select the input field, and hold the backspace key, you will delete everything in the Thang type. Basically, holding "backspace" doesn't stop when you have removed the string from an input field, and assumes you want to delete the next item up the data structure.

After doing this, you are unable to upload new .js files, even after using the "x" button and reloading the page. Interestingly, if you return to the list of thang types and then return to the thang type in question, you can successfully upload js files again.

Allow for secure websockets

The current implementation of treema has ws:// built in for websockets, however this fails for all browsers but Chrome when displaying a HTTPS page.
On HTTPS, we want to use wss:// as protocol instead.
We could use something like

if ("https:" == document.location.protocol) {
    /* secure */
} else {
    /* unsecure */
}

as seen in:
http://stackoverflow.com/questions/282444/how-can-i-use-javascript-on-the-client-side-to-detect-if-the-page-was-encrypted
or pass the option in as a parameter (firebase seems to go that path).
/edit: It seems firebase is also parsing the url, just somewhere else

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.