Newsfeeds

Drupal Association blog: Investing In the Promote Drupal Fund

Planet Drupal - 4 May 2018 - 9:13am

Donate today

Drupal has so much to be proud of:

Together, let's show the world just how amazing Drupal - and your business - is for organizations.

Invest today in the Promote Drupal Initiative. The Promote Drupal Initiative

The Promote Drupal Initiative is your opportunity to make Drupal - and your business - known and loved by new decision makers. Led by the Drupal Association, we will work with the Drupal business community to hone Drupal’s messaging and create the promotional materials we can all use to amplify the power of Drupal in the marketplace.

Step one is lining up the resources to make this initiative impactful and long lasting. 

Donate to the Promote Drupal Fund today. Help us help you grow your business. $100,000 - the Promote Drupal Fund

We need your support now to get started.

To launch the Promote Drupal Initiative, the right resources need to be in place. $100,000 will support:

  • Staff to coordinate  work

  • Marketing sprints

  • Resource support

If we all give a little, we can make a big impact promoting Drupal, together.

Donate today

Categories: Drupal

Plaid Hat Previews New Hunters for Specter Ops: Broken Covenant

Tabletop Gaming News - 4 May 2018 - 9:00am
In the cyberpunk sci-fi world of Specter Ops, Hunters come in all shapes and sizes. Each one has honed their skills and augmented their bodies for peak performance of their assigned tasks. In Broken Covenant, four new Hunters will step up to find out what’s going on with Raxxon’s history, and make sure the public […]
Categories: Game Theory & Design

Confirm Leave

New Drupal Modules - 4 May 2018 - 8:40am

This module warns users when they're about to navigate away from an unsaved node edit page.

Categories: Drupal

Lullabot: Eat This, It’s Safe: How to Manage Side Effects with Redux-Saga

Planet Drupal - 4 May 2018 - 8:01am

Functional programming is all the rage, and for good reason. By introducing type systems, immutable values, and enforcing purity in our functions, to name just a few advantages, we can reduce the complexity of our code while bolstering our confidence that it will run with minimal errors. It was only a matter of time before these concepts crept their way into the increasingly sophisticated front-end technologies that power the web.

Projects like ClojureScript, Reason, and Elm seek to fulfill the promise of a more-functional web by allowing us to write our applications with functional programming restraints that compile down to regular ol’ JavaScript for use in the browser. Learning a new syntax and having to rely on a less-mature package ecosystem, however, are a couple roadblocks for many who might be interested in using compile-to-JS languages. Fortunately, great strides have been made in creating libraries to introduce powerful functional programming tenets directly into JavaScript codebases with a gentler learning curve.

One such library is Redux, which is a state-management tool heavily inspired by the aforementioned Elm programming language. Redux allows you to create a single store that holds the state of your entire app, rather than managing that state at the component level. This store is globally-available, allowing you to access the pieces of it that you need in whichever components need them without worrying about the shape of your component tree. The process of updating the store involves passing the store object and a descriptive string, called an action, into a special function called a reducer. This function then creates and returns a new store object with the changes described by the action.

This process is very reliable. We can be sure that the store will be updated in exactly the same way every single time so long as we pass the same action to the reducer. This predictable nature is critical in functional programming. But there’s a problem: what if we want our action to fire-off an API call? We can’t be sure what that call will return or that it’ll even succeed. This is known as a side effect and it’s a big no-no in the FP world. Thankfully, there’s a nice solution for managing these side effects in a predictable way: Redux-Saga. In this article, we’ll take a deeper look at the various problems one might run into while building their Redux-powered app and how Redux-Saga can help mitigate them.

Prerequisites

In this article, we’ll be building an application to store a list of monthly bills. We’ll focus specifically on the part that handles fetching the bills from a remote server. The pattern we’ll look at works just the same with POST requests. We’ll bootstrap this app with create-react-app, which will cover most of the code I don’t explicitly walkthrough.

What is Redux-Saga?

Redux-Saga is a Redux middleware, which means it has access to your app’s store and can dispatch its own actions. Similar to regular reducers, sagas are functions that listen for dispatched actions. Additionally, they perform side effects and return their own actions back to a normal reducer.

undefined

By intercepting actions that cause side effects and handling them in their own way, we maintain the purity of Redux reducers. This implementation uses JS generators, which allows us to write asynchronous code that reads like synchronous code. We don’t need to worry about callbacks or race conditions since the generator function will automatically pause on each yield statement until complete before continuing. This improves the overall readability of our code. Let’s take a look at what a saga for loading bills from an API would look like.

1 import { put, call, takeLatest } from 'redux-saga/effects'; 2 3 export function callAPI(method = 'GET', body) { 4 const options = { 5 headers, 6 method 7 } 8 9 if (body !== undefined) { 10 options.body = body; 11 } 12 13 return fetch(apiEndpoint, options) 14 .then(res => res.json()) 15 .catch(err => { throw new Error(err.statusText) }); 16 } 17 18 export function* loadBills() { 19 try { 20 const bills = yield call(callAPI); 21 yield put({ type: 'LOAD_BILLS_SUCCESS', payload: bills }); 22 } catch (error) { 23 yield put({ type: 'LOAD_BILLS_FAILURE', payload: error }); 24 } 25 } 26 27 export function* loadBillsSaga() { 28 yield takeLatest('LOAD_BILLS', loadBills); 29 }

Let’s tackle it line-by-line:

  • Line 1: We import several methods from redux-saga/effects. We’ll use takeLatest to listen for the action that kicks-off our fetch operation, call to perform said fetch operation, and put to fire the action back to our reducer upon either success or failure.
  • Line 3-16: We’ve got a helper function that handles the calls to the server using the fetch API.
  • Line 18: Here, we’re using a generator function, as denoted by the asterisk next to the function keyword.
  • Line 19: Inside, we’re using a try/catch to first try the API call and catch if there’s an error. This generator function will run until it encounters the first yield statement, then it will pause execution and yield out a value.
  • Line 20: Our first yield is our API call, which, appropriately, uses the call method. Though this is an asynchronous operation, since we’re using the yield keyword, we effectively wait until it’s complete before moving on.
  • Line 21: Once it’s done, we move on to the next yield, which makes use of the put method to send a new action to our reducer. Its type describes it as a successful fetch and contains a payload of the data fetched.
  • Line 23: If there’s an error with our API call, we’ll hit the catch block and instead fire a failure action. Whatever happens, we’ve ended up kicking the ball back to our reducer with plain JS objects. This is what allows us to maintain purity in our Redux reducer. Our reducer doesn't get involved with side effects. It continues to care only about simple JS objects describing state changes.
  • Line 27: Another generator function, which includes the takeLatest method. This method will listen for our LOAD_BILLS action and call our loadBills() function. If the LOAD_BILLS action fires again before the first operation completed, the first one will be canceled and replaced with the new one. If you don’t require this canceling behavior, redux-saga/effects offer the takeEvery method.

One way to look at this is that saga functions are a sort-of intercepting reducer for certain actions. We fire-off the LOAD_BILLS action, Redux-Saga intercepts that action (which would normally go straight to our reducer), our API call is made and either succeeds or fails, and finally, we dispatch an action to our reducer that handles the app’s state update. Oh, but how is Redux-Saga able to intercept Redux action calls? Let’s take a look at index.js to find out.

1 import React from 'react'; 2 import ReactDOM from 'react-dom'; 3 import App from './App'; 4 import registerServiceWorker from './registerServiceWorker'; 5 import { Provider } from 'react-redux'; 6 import { createStore, applyMiddleware } from 'redux'; 7 import billsReducer from './reducers'; 8 9 import createSagaMiddleware from 'redux-saga'; 10 import { loadBillsSaga } from './loadBillsSaga'; 11 12 const sagaMiddleware = createSagaMiddleware(); 13 const store = createStore( 14 billsReducer, 15 applyMiddleware(sagaMiddleware) 16 ); 17 18 sagaMiddleware.run(loadBillsSaga); 19 20 ReactDOM.render( 21 <Provider store={store}> 22 <App /> 23 </Provider>, 24 document.getElementById('root') 25 ); 26 registerServiceWorker();

The majority of this code is standard React/Redux stuff. Let’s go over what’s unique to Redux-Saga.

  • Line 6: Import applyMiddleware from redux. This will allow us to declare that actions should be intercepted by our sagas before being sent to our reducers.
  • Line 9: createSagaMiddleware from Redux-Saga will allow us to run our sagas.
  • Line 12: Create the middleware.
  • Line 15: Make use of Redux’s applyMiddleware to hook our saga middleware into the Redux store.
  • Line 18: Initialize the saga we imported. Remember that sagas are generator functions, which need to be called once before values can be yielded from them.

At this point, our sagas are running, meaning they’re waiting to respond to dispatched actions just like our reducers are. Which brings us to the last piece of the puzzle: we have to actually fire off the LOAD_BILLS action! Here’s the BillsList component:

1 import React, { Component } from 'react'; 2 import Bill from './Bill'; 3 import { connect } from 'react-redux'; 4 5 class BillsList extends Component { 6 componentDidMount() { 7 this.props.dispatch({ type: 'LOAD_BILLS' }); 8 } 9 10 render() { 11 return ( 12 <div className="BillsList"> 13 {this.props.bills.length && this.props.bills.map((bill, i) => 14 <Bill key={`bill-${i}`} bill={bill} /> 15 )} 16 </div> 17 ); 18 } 19 } 20 21 const mapStateToProps = state => ({ 22 bills: state.bills, 23 error: state.error 24 }); 25 26 export default connect(mapStateToProps)(BillsList);

I want to attempt to load the bills from the server once the BillsList component has mounted. Inside componentDidMount we fire off LOAD_BILLS using the dispatch method from Redux. We don’t need to import that method since it’s automatically available on all connected components. And this completes our example! Let’s break down the steps:

  1. BillsList component mounts, dispatching the LOAD_BILLS action
  2. loadBillsSaga responds to this action, calls loadBills
  3. loadBills calls the API to fetch the bills
  4. If successful, loadBills dispatches the LOAD_BILLS_SUCCESS action
  5. billsReducer responds to this action, updates the store
  6. Once the store is updated, BillsList re-renders with the list of bills
Testing

A nice benefit of using Redux-Saga and generator functions is that our async code becomes less-complicated to test. We don’t need to worry about mocking API services since all we care about are the action objects that our sagas output. Let’s take a look at some tests for our loadBills saga:

1 import { put, call } from 'redux-saga/effects'; 2 import { callAPI, loadBills } from './loadBillsSaga'; 3 4 describe('loadBills saga tests', () => { 5 const gen = loadBills(); 6 7 it('should call the API', () => { 8 expect(gen.next().value).toEqual(call(callAPI)); 9 }); 10 11 it('should dispatch a LOAD_BILLS_SUCCESS action if successful', () => { 12 const bills = [ 13 { 14 id: 0, 15 amountDue: 1000, 16 autoPay: false, 17 dateDue: 1, 18 description: "Bill 0", 19 payee: "Payee 0", 20 paid: true 21 }, 22 { 23 id: 1, 24 amountDue: 1001, 25 autoPay: true, 26 dateDue: 2, 27 description: "Bill 1", 28 payee: "Payee 1", 29 paid: false 30 }, 31 { 32 id: 2, 33 amountDue: 1002, 34 autoPay: false, 35 dateDue: 3, 36 description: "Bill 2", 37 payee: "Payee 2", 38 paid: true 39 } 40 ]; 41 expect(gen.next(bills).value).toEqual(put({ type: 'LOAD_BILLS_SUCCESS', payload: bills })); 42 }); 43 44 it('should dispatch a LOAD_BILLS_FAILURE action if unsuccessful', () => { 45 expect(gen.throw({ error: 'Something went wrong!' }).value).toEqual(put({ type: 'LOAD_BILLS_FAILURE', payload: { error: 'Something went wrong!' } })); 46 }); 47 48 it('should be done', () => { 49 expect(gen.next().done).toEqual(true); 50 }); 51 });

Here we’re making use of Jest, which create-react-app provides and configures for us. This makes things like describe, it, and expect available without any importing required. Taking a look at what this saga is doing, I’ve identified 4 things I’d like to test:

  • The saga fires off the request to the server
  • If the request succeeds, a success action with a payload of an array of bills is returned
  • If the request fails, a failure action with a payload of an error is returned
  • The saga returns a done status when complete

By leveraging the put and call methods from Redux-Saga, I don’t need to worry about mocking the API. The call method does not actually execute the function, rather it describes what we want to happen. This should seem familiar since it’s exactly what Redux does. Redux actions don’t actually do anything themselves. They’re just JavaScript objects describing the change. Redux-Saga operates on this same idea, which makes testing more straightforward. We just want to assert that the API was called and that we got the appropriate Redux action back, along with any expected payload.

  • Line 5: first we need to initialize the saga (aka run the generator function). Once it’s running we can start to yield values out of it. The first test, then, is simple.
  • Line 8: call the next method of the generator and access its value. Since we used the call method from Redux-Saga instead of calling the API directly, this will look something like this:
{ '@@redux-saga/IO': true, CALL: { context: null, fn: [Function: callAPI], args: [] } }

This is telling us that we’re planning to fire-off the callAPI function as we described in our saga. We then compare this to passing callAPI directly into the call method and we should get the same descriptor object each time.

  • Line 11: Next we want to test that, given a successful response from the API, we return a new action with a payload of the bills we retrieved. Remember that this action will then be sent to our Redux reducer to handle updating the app state.
  • Line 12-40: Start by creating some dummy bills we can pass into our generator.
  • Line 41: Perform the assertion. Again we call the next method of our generator, but this time we pass-in the bills array we created. This means that when our generator reaches the next yield keyword, this argument will be available to it. We then compare the value after calling next to a call using the put method from Redux-Saga with the action.
  • Line 44-46: When testing the failure case, instead of plainly calling the next method on our generator, we instead use the throw method, passing in an error message. This will cause the saga to enter its catch block, where we expect to find an action with the error message as its payload. Thus, we make that assertion.
  • Line 48-50: Finally, we want to test that we’ve covered all the yield statements by asserting that the generator has no values left to return. When a generator has done its job, it will return an object with a done property set to true. If that’s the case, our tests for this saga are complete!
Conclusion

We’ve achieved several objectively useful things by incorporating Redux-Saga into our project:

  • Our async code has a more synchronous look to it thanks to the use of generators
  • Our Redux reducers remain pure (no side effects)
  • Our async code is simpler to test

I hope this article has given you enough information to understand how Redux-Saga works and what problems it solves, and made a case for why you should consider using it.

Further Reading

Header photo by Becky Matsubara

Categories: Drupal

Steamforged Previews Minerva, Takes Pre-Orders For Morticians Resin Team, Has Spring Sale

Tabletop Gaming News - 4 May 2018 - 8:00am
Man, Steamforged Games is, pardon the pun, full steam ahead as we head into the weekend. They’ve got a preview up of a new Falconer’s Guild player (even though she uses an owl). They’ve announced that the Main guilds are going to be moving over to colored resin. They’ve got the first pre-order up for […]
Categories: Game Theory & Design

Core Context

New Drupal Modules - 4 May 2018 - 7:49am

This module exists to create an ability to store contexts for entities, which will be usable by layout builder, etc.

Categories: Drupal

Tim Millwood: Drupal core Workspace module

Planet Drupal - 4 May 2018 - 7:46am
Drupal core Workspace module

The Workspace entity was first seen in the contrib module Multiversion on 1st June 2014. Back then the entity type was called "Content repository", it was renamed to "Workspace" in September 2014.

On 22nd Febuary 2016 the Workspace module was created, which built upon the Multiversion module.

The Workflow Initiative was announced in Dries' keynote DrupalCon New Orleans.

Today the Workspace module landed in Drupal core as a new experimental module. This module is very different from the contrib Workspace module. It has no dependencies and now actually has a lot in common with the Drupal 7 module CPS.

Please give the module a try, join us in the issue queue, and help us get Workspace module beta ready for 8.6.0-alpha1 in just over 2 months time.

timmillwood Fri, 04/05/2018 - 15:46 Tags drupal planet drupal-planet drupal drupal8 drupal 8 drupal core Add new comment
Categories: Drupal

Z-Man Games Announces Race to the New Found Land Game

Tabletop Gaming News - 4 May 2018 - 7:00am
The Age of Discovery is on. European nations are setting sail all over the world, looking for new places to claim and colonize. In Race to the New Found Land (as opposed to Race to Newfoundland, which seems less exciting), players take on the role of explorers from one of the European nations, heading across […]
Categories: Game Theory & Design

Gnome Stew Notables – Tanya DePass

Gnome Stew - 4 May 2018 - 6:26am

 

Welcome to the first installment of our Gnome Spotlight: Notables series. The notables series is a look at game developers in the gaming industry doing good work. The series will focus on female game creators and game creators of color primarily, and each entry will be a short bio and interview. We’ve currently got a group of authors and guest authors interviewing game creators and hope to bring you many more entries in the series as it continues on. If you’ve got a suggestion for someone we should be doing a notables article on, send us a note at headgnome@gnomestew.com. – Head Gnome John

Meet Tanya

Tanya DePass is the founder and Director of I Need Diverse Games, a non-profit organization based in Chicago, which is dedicated to better diversification of all aspects of gaming. I Need Diverse Games serves the community by supporting marginalized developers attend the Game Developer Conference by participating in the GDC Scholarship program, helps assist attendance at other industry events, and is seeking partnership with organizations and initiatives.

Tanya is a lifelong Chicagoan who loves everything about gaming, #INeedDiverseGames spawn point, and wants to make it better and more inclusive for everyone. She founded and was the EIC of Fresh Out of Tokens podcast where games culture was discussed and viewed through a lense of feminism, intersectionality and diversity. Now she’s a co-host on Spawn on Me Podcast. Along with all of that, she’s the Programming Coordinator for OrcaCon, the Diversity Liaison for GaymerX and often speaks on issues of diversity, feminism, race, intersectionality & other topics at multiple conventions throughout the year. Her writing about games and games critique appears in Uncanny Magazine, Polygon, Wiscon Chronicles, Vice Gaming, Paste Games, Mic, and other publications.

Talking With Tanya 1.)    Tell me a little about yourself, your work, and about I Need Diverse Games. What mediums do you work in? What’s one project or credit that you’re particularly proud of?

I’m a born and raised Chicagoan, grew up on the South Side of the city, lifelong White Sox fan, and now I live on the North Side, near the Swedish part of town. As for I Need Diverse Games, it started out of frustration with the “it’s too-hard-to-animate women” that had been making the rounds in mid-2014. I tweeted out the hashtag on a few tweets before work in early October ‘14 and by the time I got to work it was trending a bit. After it stayed in the public sphere, I was getting tapped to talk about it on podcasts and for some articles. I was interviewed by Arthur Chu for Salon in December and from there things just kept growing.

I work in both videogames and tabletop, with a lot of work in tabletop in the later part of 2017 joining the staff of OrcaCon as their programming coordinator; after being a Guest of Honor in January 2017. I was also a Industry Insider at GenCon in the last year, and I’m already looking into panels for 2018.  Most people do refer to me for video games but tabletop needs way more help in terms of diversity.

As for what I’m most proud of, I’d say joining the Game Developers Conference Scholarship program. We get a chance to send 25 folks to GDC that may not otherwise have access to a week of professional development. It’s part of our mission and work to get more people into the industry, as well as help them stay.

2.)    What genres and themes do you lean toward? Have your tastes in writing and development changed over the years, or are there things you are consistently drawn back to?

I am a big RPG nerd, and have always been more into games like Dragon Age, The Witcher, and Dungeons & Dragons. I lean HARD into those because I have always been drawn to a narrative-driven game versus strictly action.

My tastes have shifted to be more open to games like FPS, and games that are narrative-driven but have more action in them. I’ve fallen in love with Tom Clancy’s The Division, especially after the latest update. My first love will always be RPGs though, both western and Japanese titles. I’ll always go to bat for Final Fantasy VII and Dragon Age II. Those are comfort games for me, that I can pop in and enjoy no matter what.

3.)    How did you get into games? Who did you look up to? Who do you look up to now?

I got into games as someone who snuck and played D&D because my mother thought it was Satanic, and by spending a lot of time in arcades when I had the quarters to spare. Thankfully not a lot of people have made me disappointed and not look up to them, but as for current folks who inspire me, the list is long; too long to fully go into here but here are some folks. Ann Lemay, Ceri Young, Andrien Gbinigie, Manveer Heir, Rebecca Cohen-Palacios, Donna Prior, Charles Babb, Karen Lewis, Gordon Bellamy, Richard LeMarchand to name a few.

4.)    You started INDG to create dialogue and action addressing the default of whiteness in games heroes and themes. What has that experience been like? Where are you hoping to go in the next few years with the project?

It’s all been a happy accident that worked out well! The experience has been both great and terrible, with a lot of awesome opportunities including writing for games, doing an anthology that will be out this year. I was able to do a podcast, Fresh Out of Tokens for two years and join Spawn on Me earlier in 2017 due to the work I’ve been doing and the perspectives I’ve shared and learned doing this work.  In the coming years, I’d love to have a physical location for I Need Diverse Games, and be bringing in enough to fund others’ work, or trips to conferences. I’d love to have others step up and do some of the things I’ve been doing like going to conventions, conferences, running and being on panels about these topics.

5.)    You’re a pretty powerful voice in the industry. Do you have any advice for women of color, particularly young women of color, on how to deal with an industry awash with racism and sexism without losing their creativity and self-worth?

Find your circle, find other Women of Color in gaming. Join groups like the Blacks in Gaming SIG from the IGDA (International Game Developers Association). Network with others on twitter, and in game dev groups. Sign up on blackgamedevs.com and find others.

Remember you are not alone in the industry. Know that the micro-aggressions you experience  are real, they aren’t over-exaggerated. Also self care is utmost. Know when to take a break, disengage and when to dig in. You don’t have to fight every battle, and don’t let people drag you into everything they want to make into a fight that you need to engage in. Remember you engage on your terms, for your health and well-being. Its ok to be angry, it’s fuel at times. Don’t let others burn your wick down, especially when they won’t even thank you for it in the end.

6.)    Indie games are often on the frontlines of developing new, exciting things. What are some of the indie games that have come out recently that you feel are important not only as fun, but as contributions to a diverse genre?

There’s Moon Hunters by Kit Fox studios, Read Only Memories from Midboss, the upcoming Speed Dating for Ghosts by Copy Chaser. A lot of Alexandra Van Chestiens’ work is awesome, though it’s mostly zine’s and small games. Robert Yang’s games are excellent and great commentary on sex, consent and queer culture.

7.)    You do diversity consultation, as well as other freelance work. What are some of the services you offer, and where can people go to find information on how to hire you?

I can review your script, character description, world building etc. I gave talks at Ubisoft Montreal and Arena Net on diversity in general as well as their games. If anyone is interested in my services, I have a handy contact form on my site! ( )

8.)    Anything else you want to add? Open forum!

I’ve got an anthology coming out this year, Game Devs and Others: Tales from the Margins published by CRC Press. It’s a follow up to Women in Game Development: Breaking the Glass Level Cap, which was edited by Jennifer Brandes Hepler. Its personal essays from marginalized folks in the industry and also adjacent to it. I’m also getting in some writing for a couple unannounced projects which I am excited to share soon!

Thanks for joining us for this entry in the notables series.  You can find more in the series here:
and please feel free to drop us any suggestions for people we should interview at headgnome@gnomestew.com.
Categories: Game Theory & Design

Agaric Collective: Creating a New Social Simple Button

Planet Drupal - 4 May 2018 - 6:11am

Sharing an article via a social network is a super common task requested on a project.

Fortunately for Drupal 8 there is a module for that called Social Simple. This module allows you to display the most popular networks in a node so the user can just click any of the buttons and share the article.

By default this module provides the following buttons:

  • Twitter
  • Facebook
  • Linkedin
  • Google plus

This will cover 90% of use cases, but what if we need to add a button for a new network?

Creating a Custom Social Simple Button

The Social Simple module is already supports custom buttons, we just need to let the module know that we want to add one.

Basically what we need to do is:

  • Create a class that implements SocialNetworkInterface.
  • Register this class in our services file.
  • Add the tag social_simple_network to our service.

For our example we are going to create a basic Mail button. We start by creating a custom module. Inside our module let's create a Mail php file inside of the src/SocialNetwork folder:

mkdir -p src/SocialNetwork cd src/SocialNetwork touch Mail.php

The next step is to create a class and implement the SocialNetworkInterface which interface has the following methods:

  • getShareLink: This is the most important method. It must return a rendered array which later Drupal will use to create the button.
  • getLabel: Here we will need to provide the name of our button. In our case Mail.
  • getId: The ID of the button. We can choose any ID here, we just need to make sure that it is unique. Let's use mail for our example.
  • getLinkAttributes: These attributes are going to be passed to the link. We can add custom parameters to the link in this part.

Our class looks like this:

namespace Drupal\social_simple\SocialNetwork; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Url; /** * The Mail button. */ class Mail implements SocialNetworkInterface { use StringTranslationTrait; /** * The social network base share link. */ const MAIL = 'mailto:'; /** * {@inheritdoc} */ public function getId() { return 'mail'; } /** * {@inheritdoc} */ public function getLabel() { return $this->t('Mail'); } /** * {@inheritdoc} */ public function getShareLink($share_url, $title = '', EntityInterface $entity = NULL, array $additional_options = []) { $options = [ 'query' => [ 'body' => $share_url, 'subject' => $title, ], 'absolute' => TRUE, 'external' => TRUE, ]; if ($additional_options) { foreach ($additional_options as $id => $value) { $options['query'][$id] = $value; } } $url = Url::fromUri(self::MAIL, $options); $link = [ 'url' => $url, 'title' => ['#markup' => '' . $this->getLabel() . ''], 'attributes' => $this->getLinkAttributes($this->getLabel()), ]; return $link; } /** * {@inheritdoc} */ public function getLinkAttributes($network_name) { $attributes = [ 'title' => $network_name, ]; return $attributes; } }

The next step is to let the social network know about our new button and we do this by adding this class as a service in our module.services.yml. If you are not familiar with this file, you can read the structure of a service file documentation..

Basically we need to add something like this:

services: social_simple.mail: class: Drupal\custom_module\SocialNetwork\Mail tags: - { name: social_simple_network, priority: 0 }

Next, we just need to rebuild the cache. Now when we visit the social simple configuration we will see our new button there, ready to be used.

The only thing that we need to pay extra attention to is that the Social Simple module will just search the services with the tag social_simple_network otherwise our class will not be found

If you want to see how the whole thing is working, you can check this patch that I made as a part of a project: https://www.drupal.org/project/social_simple/issues/2899517. As a bonus, I made an initial integration with the Forward module.

Categories: Drupal

New Blood Red Skies Releases From Warlord Games

Tabletop Gaming News - 4 May 2018 - 6:00am
Over the battlefields of WWII, pilots dueled it out in their planes, swooping, diving, and putting on acts of daring-do. Warlord Games is bringing that excitement and action to your tabletops in Blood Red Skies. And they’ve got new sets that you can order from their website now. Plus, matching dice. Because there’s #NoSuchThingAsTooManyDice. Packed […]
Categories: Game Theory & Design

Working with Pixel Art Sprites in Unity: The Camera - by Alex Belzer

Gamasutra.com Blogs - 4 May 2018 - 5:42am
Part of an ongoing series in best practices for handling pixel art games in Unity. This time I share some hard-won wisdom (and code) for working with the camera component.
Categories: Game Theory & Design

How we made music and sound in Wrack: Exoverse - by Alex Mars

Gamasutra.com Blogs - 4 May 2018 - 5:38am
In this video we will show you the concept of music and sound design in Wrack: Exoverse.
Categories: Game Theory & Design

Pseudo-Localization – A Must in Video Gaming - by IGDA Localization SIG

Gamasutra.com Blogs - 4 May 2018 - 5:36am
Pseudo-localization is the process by which the video game source text is translated into other languages using fake (or pseudo-) translations.
Categories: Game Theory & Design

Commerce GlobalOnePay

New Drupal Modules - 4 May 2018 - 5:33am

Provides an integration with GlobalOnePay payment gateway. Right now the module supports only on-site payments.

Categories: Drupal

Amazee Labs: Slack integration as a debugging tool

Planet Drupal - 4 May 2018 - 5:19am
Slack integration as a debugging tool

We use Slack to communicate internally as well as with our clients, but we also make use of it in different ways that help us deliver a better service to both groups of stakeholders.

Fran Garcia-Linares Fri, 05/04/2018 - 14:19

Slack vs Email

Whilst we still use emails when the situation requires, we always try to move the communication related to our projects to slack. Most of our clients are in slack in their own dedicated channel, which happens to be the same one that all designers, developers, project managers, etc. use for communications related to the project. 

This way, everybody involved in the project is aware of what’s going on. Information gets passed easily across the team and we avoid multiple “broken telephone” situations. Also, if the person who is usually responsible for something happens to be sick or on holiday, the rest of the team can assist instead of getting an unhelpful “Out of Office” reply.

Different Integrations

Slack and its bots are part of our Global Maintenance team too (I guess they can be considered remote workers). They help us with our day to day tasks in a myriad of ways. 

  • Activity Channel: we use slack integrations that will pull any message or activity related to the tickets that the team is taking care of in the current sprint. This can get a bit noisy sometimes but it’s a wonderful way to stay informed of what’s going on on our team board. No more email and Jira issue watching.


     
  • Think about Blaize: it’s not just a reminder to think about Blaize (which we also do) who lives in New Zealand, it’s also a reminder for the UTC timezone team to starting wrapping up the day, commit everything not yet committed, update tickets not yet updated and leave things ready for Blaize, who will tell us “Good morning” at our 8~9pm (his 7~8am).


     
  • Information about important events: we have multiple integrations for regular but important events on certain projects, for peace of mind, and to make people aware that something has happened. The following examples are to inform everyone that an automatic Mailchimp list was created (this is crucial for the client) and to inform developers that a deployment has happened (and whether it went well or not - red vs green).




     
  • Instant bug reporting: this is probably the most important one and the one that is making the biggest difference to our Global Maintenance team. We use it whenever there are bug reports that we can’t replicate because the data changed, or when we don’t have enough information to take an action. If we can’t fully resolve a ticket request, we’re very likely to create an integration that will “spot” a problem and give us useful realtime information so that we can debug knowing further information about the issue. Over the past few months we’ve done this in multiple projects and it not only gives us instant feedback, it also informs everyone on the channel that something is happening, so we can be alert and take an action if needed. Below are two examples of those situations, again on critical parts of our clients’ systems, that allowed us to take quick action. 



These are just a few samples of the multiple integrations we have. If you want to know a bit more about the technical part, just keep reading.

How to do the integration?

  • Create the slack webhook: here.

  • Use the Drupal slack module (recommended) or code your own function, which could be as simple as:

  • Call the desired function:

    • Using slack module:


      Using custom module:

That’s it really, as you can see it’s not too complex but it adds huge value to our day to day work.

Categories: Drupal

GPU Ray Tracing in Unity – Part 1 - by David Kuri

Gamasutra.com Blogs - 4 May 2018 - 5:05am
Learn how to create a basic GPU ray tracer from scratch in this step-by-step tutorial. Using Compute Shaders in Unity, you will be able to render spheres with perfect reflections, hard shadows and super-sampling for anti-aliasing.
Categories: Game Theory & Design

Will 2018 be the year of change for loot boxes in the gaming industry - by Robert Allen

Gamasutra.com Blogs - 4 May 2018 - 5:05am
It seems that 2018 will be a turning point for loot boxes in the gaming industry.
Categories: Game Theory & Design

Is offering something free putting people off? - by Dean Noakes

Gamasutra.com Blogs - 4 May 2018 - 5:05am
Exploring why developers and professionals seem to be getting put off with things being "too good to be true"
Categories: Game Theory & Design

Pages

Subscribe to As If Productions aggregator