Newsfeeds

Agaric Collective: Using CKEditor plugins in Drupal 8

Planet Drupal - 3 November 2017 - 10:21am

CKEditor is well-known software with a big community behind it and it already has a ton of useful plugins ready to be used. It is the WYSIWYG text editor which ships with Drupal 8 core.

Unfortunately, the many plugins provided by the CKEditor community can't be used directly in the CKEditor that comes with Drupal 8. It is necessary to let Drupal know that we are going to add a new button to the CKEditor.

Why Drupal needs to know about our plugins

Drupal allows us to create different text formats, where depending on the role of the user (and so what text formats they have available) they can use different HTML tags in the content. Also, we can decide if the text format will use the CKEditor at all and, if it does, which buttons will be available for that text format.

That is why Drupal needs to know about any new button, so it can build the correct configuration per text format.

Adding a new button to CKEditor

We are going to add the Media Embed plugin, which adds a button to our editor that opens a dialog where you can paste an embed code from YouTube, Vimeo, and other providers of online video hosting.

First of all, let's create a new module which will contain the code of this new button, so inside the /modules/contrib/ folder let's create a folder called wysiwyg_mediaembed. (If you're not intending to share your module, you should put it in /modules/custom/— but please share your modules, especially ones making CKEditor plugins available to Drupal!)

cd modules/contrib/ mkdir wysiwyg_mediaembed

And inside let's create the info file: wysiwyg_mediaembed.info.yml

name: CKEditor Media Embed Button (wysiwyg_mediaembed) type: module description: "Adds the Media Embed Button plugin to CKEditor." package: CKEditor core: '8.x' dependencies: - ckeditor

Adding this file will Drupal allows us to install the module, if you want to read more about how to create a custom module, you can read about it here.

Once we have our info file we just need to create a Drupal plugin which will give info to the CKEditor about this new plugin, we do that creating the following class:

touch src/Plugin/CkEditorPlugin/MediaEmbedButton.php

With this content:

namespace Drupal\wysiwyg_mediaembed\Plugin\CKEditorPlugin; use Drupal\ckeditor\CKEditorPluginBase; use Drupal\editor\Entity\Editor; /** * Defines the "wysiwyg_mediaembed" plugin. * * @CKEditorPlugin( * id = "mediaembed", * label = @Translation("CKEditor Media Embed Button") * ) */ class MediaEmbedButton extends CKEditorPluginBase { /** * Get path to library folder. * The path where the library is, usually all the libraries are * inside the '/libraries/' folder in the Drupal root. */ public function getLibraryPath() { $path = '/libraries/mediaembed'; return $path; } /** * {@inheritdoc} * Which other plugins require our plugin, in our case none. */ public function getDependencies(Editor $editor) { return []; } /** * {@inheritdoc} * The path where CKEditor will look for our plugin. */ public function getFile() { return $this->getLibraryPath() . '/plugin.js'; } /** * {@inheritdoc} * * We can provide extra configuration if our plugin requires * it, in our case we no need it. */ public function getConfig(Editor $editor) { return []; } /** * {@inheritdoc} * Where Drupal will look for the image of the button. */ public function getButtons() { $path = $this->getLibraryPath(); return [ 'MediaEmbed' => [ 'label' => $this->t('Media Embed'), 'image' => $path . '/icons/mediaembed.png', ], ]; } }

The class's code is pretty straightforward: it is just a matter of letting Drupal know where the library is and where the button image is and that's it.

The rest is just download the library and put it in the correct place and activate the module. If all went ok we will see our new button in the Drupal Text Format Page (usually at: /admin/config/content/formats).

This module was ported because we needed it in a project, so if you want to know how this code looks all together, you can download the module from here.

Now that you know how to port a CKEditor plugin to Drupal 8 the next time you can save time using Drupal Console with the following command:

drupal generate:plugin:ckeditorbutton

What CKEditor plugin are you going to port?

Categories: Drupal

At GDC 2018, For Honor devs share lessons learned sustaining a live game

Social/Online Games - Gamasutra - 3 November 2017 - 10:03am

At GDC 2018 For Honor creative director Roman Campos Oriola and game director Damien Kieken will tell the tale of their game, its post-launch troubles, and how they addressed them. ...

Categories: Game Theory & Design

Kitty Quest Board Game Up On Kickstarter

Tabletop Gaming News - 3 November 2017 - 10:00am
Well, I guess that headline should technically say, “Kitty Quest No-Board Game Up On Kickstarter,” as the game does not have a board in the traditional sense. Instead, players will create the board as they go along, in this twist on the classic form of board games. You can check it out on Kickstarter now. […]
Categories: Game Theory & Design

Galactic Warlords: Battle for Dominion Board Game Coming to Kickstarter

Tabletop Gaming News - 3 November 2017 - 9:00am
You know what’s fun? Being in charge. And I don’t just mean of your home or your job. I’m talking of being in charge of an entire section of a galaxy. That’s what you’ll be trying to do in Galactic Warlords: Battle for Dominion, a new tactical board game that’s coming to Kickstarter in just […]
Categories: Game Theory & Design

Lullabot: Decoupled Drupal Hard Problems: Schemas

Planet Drupal - 3 November 2017 - 8:59am

The Schemata module is our best approach so far in order to provide schemas for our API resources. Unfortunately, this solution is often not good enough. That is because the serialization component in Drupal is so flexible that we can’t anticipate the final form our API responses will take, meaning the schema that our consumers depend on might be inaccurate. How can we improve this situation?

This article is part of the Decoupled hard problems series. In past articles we talked about request aggregation solutions for performance reasons, and how to leverage image styles in decoupled architectures.

TL;DR
  • Schemas are key for an API's self-generated documentation
  • Schemas are key for the maintainability of the consumer’s data model.
  • Schemas are generated from Typed Data definitions using the Schemata module. They are expressed in the JSON Schema format.
  • Schemas are statically generated but normalizers are determined at runtime.
Why Do We Need Schemas?

A database schema is a description of the data a particular table can hold. Similarly an API resource schema is a description of the data a particular resource can hold. In other words, a schema describes the shape of a resource and the datatype of each particular property.

Consumers of data need schemas in order to set their expectations. For instance, the schema tells the consumer that the body property is a JSON object that contains a value that is a string. A schema also tells us that the mail property in the user resource is a string in the e-mail format. This knowledge empowers consumers to add client-side form validation for the mail property. In general, a schema will help consumers to have prior understanding of the data they will be fetching from the API, and what data objects they can write to the API.

We are using the resource schemas in the Docson and Open API to generate automatic documentation. When we enable JSON API and  Open API you get a fully functional and accurately documented HTTP API for your data model. Whenever we make changes to a content type, that will be reflected in the HTTP API and the documentation automatically. All thanks to the schemas.

A consumer could fetch the schemas for all the resources it needs at compile time or fetch them once and cache them for a long time. With that information, the consumer can generate its models automatically without developer intervention. That means that with a single implementation once, all of our consumers’ models are done forever. Probably, there is a library for our consumer’s framework that does this already.

More interestingly, since our schema comes with type information our schemas can be type safe. That is important to many languages like Swift, Java, TypeScript, Flow, Elm, etc. Moreover if the model in the consumer is auto-generated from the schema (one model per resource) then minor updates to the resource are automatically reflected in the model. We can start to use the new model properties in Angular, iOS, Android, etc.

In summary, having schemas for our resources is a huge improvement for the developer experience. This is because they provide auto-generated documentation of the API, and auto-generated models for the consumer application.

How We Are Generating Schemas In Drupal?

One of Drupal 8's API improvements was the introduction of the Typed Data API. We use this API to declare the data types for a particular content structure. For instance, there is a data type for a Timestamp that extends an Integer. The Entity and Field APIs combine these into more complex structures, like a Node.

JSON API and REST in core can expose entity types as resources out of the box. When these modules expose an entity type they do it based on typed data and field API. Since the process to expose entities is known, we can anticipate schemas for those resources.

In fact, assuming resources are a serialization of field API and typed data is the only thing we can do. The base for JSON API and REST in core is Symfony's serialization component. This component is broken into normalizers, as explained in my previous series. These normalizers transform Drupal's inner data structures into other simpler structures. After this transformation, all knowledge of the data type, or structure is lost. This happens because the normalizer classes do not return the new types and new shapes the typed data has been transformed to. This loss of information is where the big problem lies with the current state of schemas.

The Schemata module provides schemas for JSON API and core REST. It does it by serializing the entity and typed data. It is only able to do this because it knows about the implementation details of these two modules. It knows that the nid property is an integer and it has to be nested under data.attributes in JSON API, but not for core REST. If we were to support another format in Schemata we would need to add an ad-hoc implementation for it.

The big problem is that schemas are static information. That means that they can't change during the execution of the program. However, the serialization process (which transforms the Drupal entities into JSON objects) is a runtime operation. It is possible to write a normalizer that turns the number four into 4 or "four" depending if the date of execution ends in an even minute or not. Even though this example is bizarre, it shows that determining the schema upfront without other considerations can lead to errors. Unfortunately, we can’t assume anything about the data after its serialized.

We can either make normalization less flexible—forcing data types to stay true to the pre-generated schemas—or we can allow the schemas to change during runtime. The second option clearly defeats the purpose of setting expectations, because it would allow a resource to potentially differ from the original data type specified by the schema.

The GraphQL community is opinionated on this and drives the web service from their schema. Thus, they ensure that the web service and schema are always in sync.

How Do We Go Forward From Here

Happily, we are already trying to come up with a better way to normalize our data and infer the schema transformations along the way. Nevertheless, whenever a normalizer is injected by a third party contrib module or because of improved normalizations with backwards compatibility the Schemata module cannot anticipate it. Schemata will potentially provide the wrong schema in those scenarios. If we are to base the consumer models on our schemas, then they need to be reliable. At the moment they are reliable in JSON API, but only at the cost of losing flexibility with third party normalizers.

One of the attempts to support data transformations and the impact they have on the schemas are Field Enhancers in JSON API Extras. They represent simple transformations via plugins. Each plugin defines how the data is transformed, and how the schema is affected. This happens for both directions, when the data goes out and when the consumers write back to the API and the transformation needs to be reversed. Whenever we need a custom transformation for a field, we can write a field enhancer instead of a normalizer. That way schemas will remain correct even if the data change implies a change in the schema.

undefined

We are very close to being able to validate responses in JSON API against schemas when Schemata is present. It will only happen in development environments (where PHP’s asserts are enabled). Site owners will be able to validate that schemas are correct for their site, with all their custom normalizers. That way, when a site owner builds an API or makes changes they'll be able to validate the normalized resource against the purported schema. If there is any misalignment, a log message will be recorded.

Ideally, we want the certainty that schemas are correct all the time. While the community agrees on the best solution, we have these intermediate measures to have reasonable certainty that your schemas are in sync with your responses.

Join the discussion in the #contenta Slack channel or come to the next API-First Meeting and show your interest there!

Hero photo by Oliver Thomas Klein on Unsplash.

Categories: Drupal

King Cat Board Game Coming To Kickstarter Soon

Tabletop Gaming News - 3 November 2017 - 8:00am
I wouldn’t specifically say I’m a cat person. I’m certainly not against cats, though. They’re fine. Mitten, the semi-feral cat for my apartment building, is nice. I feed her sometimes. But I certainly know of “cat people” (and I don’t mean the Ninja Division type). I also know a couple “definitely not-cat people.” If you’re […]
Categories: Game Theory & Design

Dragons Conquer America RPG Up On Kickstarter

Tabletop Gaming News - 3 November 2017 - 7:00am
I’m a big fan of unique settings and stories for games. There’s lots of fantasy settings and sci-fi settings and such. But there’s not many that I can think of that include 16th century Central America and various dragons and mythical creatures that have started roaming the land. But that’s just what you’ll find in […]
Categories: Game Theory & Design

Porting a PC game to Nintendo Switch - Part 1: Controls - by Matias Kindermann

Gamasutra.com Blogs - 3 November 2017 - 6:51am
Porting a PC game to Nintendo Switch, and how to redesign keyboard + mouse controls to actually work on a controller.
Categories: Game Theory & Design

Who pays the piper? - by Rich Woods

Gamasutra.com Blogs - 3 November 2017 - 6:51am
You have a great game idea but how do you turn that into a commercial product? I look at the most common monetisation strategies and discuss their merits and risks.
Categories: Game Theory & Design

What makes a good game tester? - by Johan Hoberg

Gamasutra.com Blogs - 3 November 2017 - 6:50am
In this article I will explore what I feel are the most important skills and attributes of a good game tester, and what type of mindset I believe a good game tester should have.
Categories: Game Theory & Design

Financial Slam Dunk: The Numbers Behind Virtual Currency in NBA2K - by Johnny Uzan

Gamasutra.com Blogs - 3 November 2017 - 6:50am
In this article we’re going to take a close look at the annual reports that Take Two released to their investors over the years and analyze how the success of microtransactions has completely changed their business, with a focus on the NBA2K franchise.
Categories: Game Theory & Design

Soldiers of Fortune Expansion Announced for Aristeia

Tabletop Gaming News - 3 November 2017 - 6:00am
Corvus Belli’s Aristeia, their new sci-fi sports action miniatures game, is still on its way to people’s tabletops, but with just about any game, as soon as it comes out, people are wondering, “so… expansions?” CB’s not wasting any time and has announced the first one, Soldiers of Fortune. From the announcement: The line-up of […]
Categories: Game Theory & Design

InternetDevels: Responsive images in Drupal 8: beautiful on every device!

Planet Drupal - 3 November 2017 - 5:48am

When does “smaller” mean “bigger”? When your images grow smaller to perfectly adjust themselves to various devices, while your user satisfaction, audience coverage, website’s speed, and profits grow bigger. A nice formula, isn’t it? This magic ability of images to adjust themselves to screens is how responsive web design works. And it works especially well in the latest Drupal version, Drupal 8, which has built-in support for responsive images.

Read more
Categories: Drupal

Agiledrop.com Blog: AGILEDROP: Why should agencies focus on building ambitious websites

Planet Drupal - 3 November 2017 - 4:35am
Dries Buytaert, the founder of Drupal, gave great session this year at Drupalcon Vienna. Watch the part where he talks about who is Drupal for. Instead of focusing on big and small websites, or SME and enterprise clients, Dries describes the type of a website Drupal is made for as ambitious.  What is not an ambitious website A business that used to have a simple brochure website is now better off being served by SaaS (software as a service) solutions like Wix and Squarespace. Facebook, Google, and Amazon are providing services that not only cover what a good-old-website did in the past, but… READ MORE
Categories: Drupal

Mailjet sign up

New Drupal Modules - 3 November 2017 - 4:17am

This simple module provides a form block allowing users to subscribe to a Mailjet contact list.

It needs the mailjet-apiv3-php library, which will be automagically downloaded if you install the module via Composer.

Categories: Drupal

Miniature Painting While Colorblind

Gnome Stew - 3 November 2017 - 2:20am

 

Today’s Guest Article comes from Brandon Barnes, who talks about his experiences learning to paint while dealing with Red-Green Colorblindness. It’s an awesome look at learning to paint and what tools can make it easier to work around issues you might have. – John Arcadian

A gaming pub opened in our area and started providing free events like learning how to play Dungeons and Dragons, trivia nights, and even gaming mini take-and-paint. The later was presented with some short instruction on painting. It was run by the owner, a former professional painter for several companies. However, when I was about six years old I was diagnosed as red-green colorblind. But, my wife wanted to go and I thought I’d tag along. The worst outcome would have been a crappy painted mini and a couple beers, so why not.

I ended up finding the whole thing therapeutic and I wanted to do more. The mini everyone practiced on was your basic Stormcast Eternal from Warhammer.

The one that started it all. Remember newbies: Thin your paints.

I didn’t get too crazy with my color selection, going with a white base, yellow (wanted gold) trim, and brown leather. Largely I was too timid to get adventurous with colors that I sometimes can’t tell the difference in. What I didn’t realize at first was that even for the colorblind, there are quite a few tools that will help anyone to paint.

A Box of Crayons

Base colors. No shading or layers.

The class introduced me to Citadel’s paints as that was what the instructor always used. My wife had previously bought some of their paints and brushes, but we didn’t have a wide selection. We then made a trip to our FLGS and picked up some starter kits. The kits were for different steps in the painting process, which helps beginners like me ease into the process. The kits we got happened to be Citadel paints, so the colors were all themed from the Warhammer universe. That’s not to say there isn’t a “blue” or a “red.” In fact, there are several versions of various colors included in each kit. Like my giant box of crayons I had as a kid, they’re labeled with descriptive names, which helped me immensely.

Some of the names help colorblind people pick the right color even if they might otherwise have issues differentiating them. Names like Eldar (one of the elves of Warhammer) Flesh indicates a pale skin tone, which helps differentiate from (what I’m told) are redder based flesh tone paints like Ratskin Flesh. Having clear names can help if you have an idea of what the colors should be in context. I did picked up a set of minis and got a troop of wood elves, so I had to find the proper paints to use. Having evocative color names like Death World Forest and Mornfang Fur Brown helped me to pick the ideal combination of colors to represent the characters. Other manufacturers like Vallejo, Privateer Press, and Reaper have more general names that denote the colors, which is beneficial when you are mixing your own color palette. For someone with color-blindness, using paints with less descriptive names might mean having someone with full-color vision around to double check the color choices.

It’s Not All About That Base

That’s just the base colors. Once you get to the next steps, you need to find the right paints to go with your base colors. The next two steps  in most painting are shading and then highlighting (also known as layering).

Shading and some terrible layering.

This is where some tools like charts come into play. Charts like this, helped me pick out what colors to use along with the base colors.

Before I found these tools, I struggled at the store. It was always a concern that some of the pigments might contain red or green and I wouldn’t even notice. Another tool that helped me was the app that helped out in paint selection. These tools show you, “if you used x base, use y shade, and z layer.” Since the apps I used were warhammer specific, it helped tell me what specific colors to use on what parts. For other miniatures, an app or chart like this can help you reference paint schemes from different miniatures to use on the miniature you are painting.

Further along the digital route, there are apps out there that will utilize your phone or tablet’s camera to “read” the color you point it at. These apps may also give you a breakdown of the colors in the RGB format usually used on computers. That can help you with mixing if you can find the ratios to red, green, and blue and map them to how the colors look to you. This can be handy if a person with full-color vision is not readily available.

Well, I Screwed Up, But It’s Not The End

 I should have started a long time ago and followed my own advice I give to my kids, “Never let your diagnosis be a barrier to what you want to do. Just do it.” If you feel you got your color combinations wrong and you feel you ruined your favorite mini, it’s not the end of it. With the right tools, you can strip the mini with something you might already have under your sink. Soaking your mini in Simple Green is one of the ways to remove paint from something they want to redo because you didn’t get it quite right. Of course, any super glue joined parts may come apart as well, and some paint thinners  may react to the plastic or metal that the miniature is made of. Knowing you can redo the work if it doesn’t come out right can be a confidence booster when dealing with color-blindness.

JUST… DO IT!

“Dad, why is there a mini in pickle juice?” – My daughter observing the Stormcast Eternal soaking in Simple Green.

There are many options out there for painting your minis while colorblind. Certain products can make it easy to find the right color, like charts and digital tools telling you what colors fit best with others, and then there’s the reset button of just stripping it and starting all over. Finding what works best for you is a matter of personal preference, but there is nothing wrong in attempting it to see what works for you. My advice – if you have been curious, go for it. It doesn’t matter if you’re colorblind. With anything, practice will make you better so long as you’re willing to learn from your mistakes. I should have started a long time ago and followed my own advice I give to my kids, “Never let your diagnosis be a barrier to what you want to do. Just do it.”

This isn’t a comprehensive tutorial on mini painting by any means, just an exploration of what I’ve done to help overcome my disability. I’d be curious to know what tools others might use to overcome personal obstacles, mini painting or not. Please share your story!

Categories: Game Theory & Design

Autocomplete Multiselect Cc and BCc Users Contact form

New Drupal Modules - 3 November 2017 - 12:03am

This module adds up functionality to include CC and BCC fields.This will add up an option in Contact form where user can select user profiles to Cc and Bcc from within its drupal setup.It has an Autocomplete option and Remove functionality.

Categories: Drupal

Xbox One X: A hands-on analysis of Microsoft's powerful new console - by Kris Graft

Gamasutra.com Blogs - 3 November 2017 - 12:01am
Xbox One X, formerly known as the more astrologically-inclined Project Scorpio, is arriving on November 7 for $499, and Gamasutra got to spend some up-close time with the console.
Categories: Game Theory & Design

Tales from the Rocket House: Which Bonus Part 2: AC vs HP

RPGNet - 3 November 2017 - 12:00am
What\'s better, +1 HP or +1 AC?
Categories: Game Theory & Design

Appnovation Technologies: Appnovator Spotlight: Meet Victoria Marcos

Planet Drupal - 3 November 2017 - 12:00am
Appnovator Spotlight: Meet Victoria Marcos Who are you? What's your story? My name is Victoria Marcos, I’m from Venezuela and moved to England 8 years ago. I’m married and have a beautiful dog called Bonnie. I’ve been working in Appnovation for 3.5 years as Project Manager. I have a degree in Computer Engineering and a Master in Computer Science. I used to work as Business Analy...
Categories: Drupal

Pages

Subscribe to As If Productions aggregator