Planet Drupal

Subscribe to flux Planet Drupal
Drupal.org - aggregated feeds in category Planet Drupal
Mis à jour : il y a 30 min 54 sec

Mediacurrent: DrupalCon NOLA: The People Behind the Usernames

mer, 17/08/2016 - 20:33

As we work every day on our own projects, with our own deadlines and priorities, it is often too easy to forget about the entire community of others using Drupal in much the same way. When we're working with Drupal in our various capacities, there is no shortage of methods to interact with the community and contribute back, but those aren't the focus of this post.

Catégories: Elsewhere

myDropWizard.com: Drupal 6 security updates for Panels!

mer, 17/08/2016 - 20:16

As you may know, Drupal 6 has reached End-of-Life (EOL) which means the Drupal Security Team is no longer doing Security Advisories or working on security patches for Drupal 6 core or contrib modules - but the Drupal 6 LTS vendors are and we're one of them!

Today, there is a Critical security releases for the Panels modules for multiple Access Bypass vulnerabilities.

The first vulnerability allows anonymous users to use AJAX callbacks to pull content and configuration from Panels, which allow them to access private data. And the second, allows authenticated users with permission to use the Panels IPE to modify the Panels display for pages that they don't have permission to otherwise edit.

See the security advisory for Drupal 7 for more information.

Here you can download the patch for 6.x-3.x!

If you have a Drupal 6 site using the Panels module, we recommend you update immediately! We have already deployed the patch for all of our Drupal 6 Long-Term Support clients. :-)

If you'd like all your Drupal 6 modules to receive security updates and have the fixes deployed the same day they're released, please check out our D6LTS plans.

Note: if you use the myDropWizard module (totally free!), you'll be alerted to these and any future security updates, and will be able to use drush to install them (even though they won't necessarily have a release on Drupal.org).

Catégories: Elsewhere

Rakesh's DSoC 16 blog: Last week - GSoC16 - Detected and Solved Merge Conflicts in Drupal8.

mer, 17/08/2016 - 20:04
Last week - GSoC16 - Detected and Solved Merge Conflicts in Drupal8. rakesh Wed, 08/17/2016 - 23:34
Catégories: Elsewhere

Miloš Bovan: The final week of Google Summer of Code 2016

mer, 17/08/2016 - 19:56
The final week of Google Summer of Code 2016

It’s been more than 13 warm weeks since I’ve started to work on my Google Summer of Code 2016 - Mailhandler project. During the past few weeks, I finished the coding and worked on latest improvements related to documentation.

In the past week, the project documentation has been updated which was the last step before merging Github repository and Sandbox project into Mailhandler. Drupal 8 release section was updated and it summarizes the features of D8 version. If you are wondering where you can use the code I developed this summer, feel free to read about real Mailhanlder use-cases.

This week, I am doing the latest cleanups and preparing the project for the final evaluation. It is the second evaluation after I submitted the midterm evaluation. In case you missed the previous posts from Google Summer of Code series, I am providing the project retrospect below.
 

Project Retrospect

In early February, in an ordinary conversation, a friend of mine told me about this year’s Google Summer of Code program. I got interested in it since I took apart in GHOP (The Google Highly Open Participation Contest; This program was replaced with Google Code-In) during high-school.

In March, I’ve found out that Drupal will be one of the participating organizations and since I did a Drupal internship last year, this seemed to be a perfect opportunity to continue open-source contribution.

Among many interesting project ideas, I decided for “Port Mailhandler to Drupal 8”. Miro Dietiker proposed the project and during the proposal discussions, Primoz Hmeljak joined the mentoring team too.

The great news came in April. I was one of the 11 students chosen to contribute Drupal this summer! First Yay moment!

The project progress could have been followed on this blog, so I’m will not go deeper into it.

3 months of work passed quickly and at this point, I can confirm that I learned a ton of new things. I improved not only my coding skills but communication and project management skills too.

In my opinion, we reached all the goals we put on the paper in April. All the features defined in the proposal were developed, tested and documented.

Google Summer of Code is a great program and I would sincerely recommend all the students to consider participating in it.

Future plans

The future plans about the module are related to its maintenance. Inmail is still under development and it seems it will be ready for an alpha release very soon. In the following days, I am going to create an issue about nice-to-have features of Mailhandler. This issue could serve as a place for Drupal community to discuss the possible ways of the future Mailhandler development.


Thank you note

Last but not least, I would like to give huge thanks to my mentors (Miro Dietiker and Primoz Hmeljak) for being so supportive, helpful and flexible during this summer. Their mentoring helped me in many ways - from the proposal re-definition in April/May, endless code iterations, discussions of different ideas to blog post reviews, including this one :).

I would like to thank my company too for allowing me to contribute Drupal via this program and Google for giving me an opportunity to participate in this great program.

 

 

Milos Wed, 08/17/2016 - 19:56 Tags Drupal Google Summer of Code Open source Drupal Planet Add new comment
Catégories: Elsewhere

lakshminp.com: Tagged services in Drupal 8

mer, 17/08/2016 - 16:07

We saw how to write a simple service container in Drupal earlier. We shall build a tagged service now. To illustrate a proper use case for tagged services, let's contrive a scenario where you add a pipeline custom filters to user text before rendering it on the page.

First, clone the code which will be used in this post.

$ git clone git@github.com:drupal8book/process_text.git

Checkout the first version of the code where we take custom text from user, process and display it in a page without using services.

$ cd process_text $ git checkout -f just-filtering

We get custom text from a user using a config form.

class CustomTextSettingForm extends ConfigFormBase { /** * {@inheritdoc} */ protected function getEditableConfigNames() { return [ 'process_text.settings', ]; } /** * {@inheritdoc} */ public function getFormId() { return 'custom_text_setting_form'; } /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('process_text.settings'); $form['custom_text'] = [ '#type' => 'textarea', '#title' => $this->t('Custom Text'), '#default_value' => $config->get('custom_text'), ]; return parent::buildForm($form, $form_state); } /** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $this->config('process_text.settings') ->set('custom_text', $form_state->getValue('custom_text')) ->save(); $form_state->setRedirect('process_text.show'); } }

We save it as a piece of configuration called process_text.settings.custom_text.

Before rendering this text, let's say you would want to:

  • Remove any <div> tags.
  • Substitute a token [greeting] with <span class"greeting">hello world</span> throughout the text.

We get the text and do all the above processing inside a custom controller.

class ProcessTextController extends ControllerBase { /** * Processtext. * * @return string * Return processed custom text. */ public function processText() { $custom_text = \Drupal::config('process_text.settings')->get('custom_text'); // do processing // remove divs $custom_text = str_replace(["<div>", "</div>"], "", $custom_text); // replace greeting tokens $custom_text = str_replace("[greeting]", '<span class="greeting">hello world</span>', $custom_text); return [ '#type' => 'markup', '#markup' => $custom_text ]; } }

This is good, but we could do better. What if we change the filter applying mechanism? We have to change this code. Instead, let's convert it into a service.

$ cd process_text $ git checkout -f services-first-cut

Our text filter service takes a set of filters and applies them to a given text when we call applyFilters.

class TextFilterService { private $filters = []; /** * @param Filter $filter */ public function addFilter(Filter $filter) { $this->filters[] = $filter; } /** * applies all filters to given text and returns * filtered text. * * @param string $txt * * @return string */ public function applyFilters($txt) { foreach ($this->filters as $filter) { $txt = $filter->apply_filter($txt); } return $txt; } }

We need to crate a services.yml file for the above service.

services: process_text.text_filter: class: Drupal\process_text\TextFilterService

Here's how the processText function text looks now.

public function processText() { $custom_text = \Drupal::config('process_text.settings')->get('custom_text'); // do processing using a service $filter_service = \Drupal::service('process_text.text_filter'); // remove divs $filter_service->addFilter(new RemoveDivs()); // substitute greeting token $filter_service->addFilter(new Greeting()); // apply all the above filters $custom_text = $filter_service->applyFilters($custom_text); return [ '#type' => 'markup', '#markup' => $custom_text ]; }

Now the filter applying mechanism is swappable. We can add write a different functionality and inject that implementation using service containers.

Now, what if we want to add a new filter to this code, like, enclosing the whole text within a <p> tag.

Sure. We could do that.

Let's checkout the specific tag where we add a new filter.

$ cd process_text $ git checkout -f add-new-filter

We build that filter.

class EnclosePTags implements Filter { public function apply_filter($txt) { return '<p>'. $txt . '</p>'; } }

…and add it to the set of filters being applied.

public function processText() { $custom_text = \Drupal::config('process_text.settings')->get('custom_text'); // do processing using a service $filter_service = \Drupal::service('process_text.text_filter'); // remove divs $filter_service->addFilter(new RemoveDivs()); // substitute greeting token $filter_service->addFilter(new Greeting()); // Enclose p tags $filter_service->addFilter(new EnclosePTags()); // apply all the above filters $custom_text = $filter_service->applyFilters($custom_text); return [ '#type' => 'markup', '#markup' => $custom_text ]; }

How about injecting the filter adding mechanism itself? Wouldn't it be cool if we are able to add new filters without changing this part of the code? Not to mention the fact that the code will be more testable than before if we follow this approach. This is exactly what tagged services help us accomplish.

Let's write each filter as a tagged service.

$ cd process_text $ git checkout -f tagged-services

Here's how our process_text.services.yml looks now.

services: process_text.text_filter: class: Drupal\process_text\TextFilterService tags: - { name: service_collector, tag: text_filter, call: addFilter } remove_divs_filter: class: Drupal\process_text\TextFilter\RemoveDivs tags: - { name: text_filter } greeting_filter: class: Drupal\process_text\TextFilter\Greeting tags: - { name: text_filter } enclose_p_filter: class: Drupal\process_text\TextFilter\EnclosePTags tags: - { name: text_filter }

There are many changes here. Firstly, all the filters have been converted to services themselves. The have a common tag called text_filter. The main service also has a few changes. It has a tag called service_collector and a tag parameter call. This ritual of creating a service container and adding a set of tagged services is such a common pattern that Drupal 8 has a special tag to do this, called the service_collector. This tag takes an additional parameter called call which indicates what function has to be called in the service to add all the tagged services.

What happens is, Drupal's TaggedHandlersPass picks up all services with "service_collector" tag, finds services which have the same tag as that of this service(text_filter in our case) and calls the method in call to consume the tagged service definition. If you're coming from Symfony world, this might seem familiar for you. In order to execute some custom code, like applying a set of filters, we implement CompilerPassInterface, which is run whenever the service cotainer(ApplyFilter in our case) is being built. You can find more about CompilerPassInterface here.

Your controller code looks a lot simpler now.

public function processText() { $custom_text = \Drupal::config('process_text.settings')->get('custom_text'); // do processing using a service $filter_service = \Drupal::service('process_text.text_filter'); $custom_text = $filter_service->applyFilters($custom_text); return [ '#type' => 'markup', '#markup' => $custom_text ]; }

Now, all you need to add new filters is to update the service yaml file with the new filter service and tag it with "text_filter" tag.

Tagged services in the wild

Drupal allows developers to add a new authentication mechanism using tagged services. The authentication_collector is defined in core.services.yml.

authentication_collector: class: Drupal\Core\Authentication\AuthenticationCollector tags: - { name: service_collector, tag: authentication_provider, call: addProvider }

To add a new authentication provider, one has to implement the AuthenticationProviderInterface and flesh out the applies and authenticate functions. This will be the subject of another post.

Here's how the addProvider function looks like:

public function addProvider(AuthenticationProviderInterface $provider, $provider_id, $priority = 0, $global = FALSE) { $this->providers[$provider_id] = $provider; $this->providerOrders[$priority][$provider_id] = $provider; // Force the providers to be re-sorted. $this->sortedProviders = NULL; if ($global) { $this->globalProviders[$provider_id] = TRUE; } }

And here's how we would register our hypothetical authentication provider service.

services: authentication.custom_auth: class: Drupal\custom_auth\Authentication\Provider\CustomAuth tags: - { name: authentication_provider }

Another example is the breadcrumb manager service.

breadcrumb: class: Drupal\Core\Breadcrumb\BreadcrumbManager arguments: ['@module_handler'] tags: - { name: service_collector, tag: breadcrumb_builder, call: addBuilder }

To add breadcrumbs from your module, you would need to implement BreadcrumbBuilderInterface and add the following entry to your services.yml,

services: foo.breadcrumb: class: Drupal\foo\MyBreadcrumbBuilder tags: - { name: breadcrumb_builder, priority: 100 }

The BreadcrumbManager::addBuilder collects all breadcrumb bilders and builds it using the BreadcrumbManager::build function.

public function addBuilder(BreadcrumbBuilderInterface $builder, $priority) { $this->builders[$priority][] = $builder; // Force the builders to be re-sorted. $this->sortedBuilders = NULL; } Drupal, Drupal 8, Drupal Planet
Catégories: Elsewhere

Lullabot: Making Web Accessibility Great Again: Auditing the US Presidential Candidates Websites for Accessibility

mer, 17/08/2016 - 15:00

Imagine that you arrive at a website, but you cannot see the screen. How do you know what’s there? How do you navigate? This is normal for many people, and the accessibility of your site will make or break their experience. Accessibility is about including everyone. People with physical and cognitive disabilities have specific challenges online—and making your site accessible removes those barriers and opens the door to more users.

Severely disabled Americans constitute a population of 38.3 million people, and make up a huge swath of voters (see the #CripTheVote movement on Twitter). Some notable U.S. presidential elections have been decided by much less, and because of this, we’re auditing the US presidential election candidates’ websites.

During this audit, we’ll see what the candidates’ websites are doing right and wrong, and where the low-hanging fruit lies. This article won’t be a full top-to-bottom audit, but we will show some of the important things to look for and explain why they’re important.

Our Methods Automated Testing

The first step in our a11y audit is to do a quick automated check. If you’re new to accessibility, the WAVE tool by WebAIM is a great place to start. It’ll check for standard accessibility features and errors in alt attributes, contrast, document outline, and form labels. For the features or errors it finds, it provides an info icon that you can click to learn what the issue is, why it’s important, and how to do it right. WAVE is free, and highlights both negative (errors, alerts, features, structural elements, ARIA attributes, contrast), and positive (features, structural elements, ARIA attributes).

Keyboard Testing

As great as WAVE is, an automated tool is never as good as a live person. This is because some accessibility requirements need human logic to apply them properly. For the next part, we’re going to navigate around each website using only the keyboard.

This is done by using the tab button to move to the next element, and shift-tab to move backwards. The spacebar (or return) is used to click or submit a form element. If everything is done right, a person will be able to navigate through your website without falling into tab rabbit-holes (tabbit-holes?). We should be able to tab through the whole page in a logical order without getting stuck or finding things that we can’t access or interact with.

Beyond that, we need to be able to see where the focus lies as we tab across the page. Just as interactive elements give a visual cue on hover, we should get an indication when we land on an interactive element while tabbing, too. That state is referred to as ‘having focus’. You can extend your hover state to focus, or you can make a whole new interaction for focus. It’s up to you!

.link--cta-button:hover, .link--cta-button:focus { /* The :focus pseudo-class for a11y */ background: #2284c0; } Screen Reader Audit

Screen readers are used by visually impaired and blind people to navigate websites. For this purpose we’ll use VoiceOver, which is the default pre-installed screen reader for OS X. We’re looking for things that read oddly (like an acronym), things that don’t get read that should get read (and vice-versa), and making sure all of the information is available.

Let’s start with Donald Trump’s website

The first thing that we did while looking at Donald Trump’s website was audit it using the WAVE tool. Here’s what we found:

  • 8 Errors
  • 14 Alerts
  • 15 Features
  • 35 Structural Elements
  • 5 HTML5 and ARIA
  • 5 Contrast Errors (2 were false flags)
The Good Bold Colors for a Bold Candidate

The color scheme is very accessible. On the front page, there were only two places where the contrast wasn’t sufficient. Outside of that, his color scheme provides text that stands out well from the background and is easy to read for low-vision users.

The Bad Lacking Focus

Remember how we talked about focus states? This site has almost none. Tabbing through the page is confusing because there are no visual indications of where you are.

This is especially egregious because the browser automatically applies focus states to focusable elements for you. In order for there not to be focus elements at all, the developer has to actively go out of their way to break them by applying outline: 0; to the element’s focus state. This is okay if you’re doing it to replace the focus state with something more decorative, but taking it off and not replacing it is a big accessibility no-no.

Skipped Skip Link

When tabbing through The Donald’s website, the first thing we notice is the absence of a skip link. Without a skip link, a keyboard user is forced to tab through each link in the navigation when arriving at each page before they can access the rest of the content. This repetitive task can become aggravating quickly, especially on sites with a lot of navigation links.

Unclear Link Text

Links should always have text that clearly explains where the user is going. The link’s text is what a person using a screen reader will hear, so text like ‘Read More’ or text and icons that require visual context to understand their destination aren’t ideal.

In this area, the link text that goes out to the linked Twitter posts read ‘12h’ and ‘13h’. Without the visual context of a Twitter icon (that’s a background image, so there’s no alternative text to provide that), the user probably has no idea what ‘12h’ is referring to or where that link will lead.

The Ugly Navigation Nightmares

The most important part of any website, in terms of access, is the navigation. An inaccessible navigation menu can block access to large portions of the website. Unfortunately, the navigation system of Trump’s website does just that, and prevents users with disabilities from directly accessing the sub-navigation items under the issues and media sections.

A more accessible way to do this is to use a click dropdown instead of a :hover. If that doesn’t work for the design, make sure that the :hover state of the menu applies to :focus as well, so that the menu will open the nested links when the parent menu item is tabbed to.

Disorganized Structure

Structural elements (h1, h2, h3, etc tags) are very helpful when used properly. In this case, they’re definitely not. Heading levels aren’t sequential, and nested information isn’t always relevant to its parent.

Audit of Hillary Clinton’s website The Good

Overall, Clinton’s website is better than most when it comes to accessibility. It’s that clear that her development team made it a purposeful consideration during the development process. While it’s not perfect, there was a lot of good done here. Let’s explore some examples of things done right.

Keyboard Accessibility

The keyboard accessibility on this site is very good. We found that we could access the elements and navigate to other pages easily without a mouse. It was easy to open and shut the drop-down ‘More’ area in the navigation, and access its nested links, which is a good example of how to implement what we were talking about when we covered the shortfalls of the navigation system on Trump’s website.

Skip Link

Hillary Clinton’s website includes a proper skip link, which allows users to skip the navigation and go directly to the content.

Great Focus States

The other thing we found when checking the keyboard accessibility was that everything has a focus state that makes it visually obvious where you are on the page. The light dotted border focus state is a bit subtle for low-vision users, but the fact that the focus state of the elements was styled independently from the hover state shows that the developer was aware of the need for focus indicators and made a conscious effort to implement them.

Translation

We usually think of accessibility in terms of people with disabilities because they often benefit from it the most, but accessibility is really just about including as many people as possible. A nice touch we found on Clinton’s site was a button at the top to translate the site into Spanish. With 41 million native Spanish speakers in the US, providing the option to experience the content in the user’s first language is a great accessibility move.

Video Captioning

Deaf people rely on captions to get the dialogue from videos, since it’s very difficult to lip-read in film. The videos on Hillary’s site are furnished with open captions, which means that they’re always on. Open captions are great for people with disabilities, but they’re also a smart move to capture your non-disabled audience as well. Often autoplay videos won’t play any sound unless they’re interacted with, but providing open captions on the video gives you another chance to capture the audience’s interest by displaying the words on the screen.

The Bad No Transcripts for Video

While it was great that the videos were captioned, we couldn’t find a transcript provided. Many people erroneously believe that you only need one or the other, but captions and transcripts actually serve different purposes, so it’s ideal to provide both. Captions are great for the Deaf, who want to read the words in real-time with the video. Transcripts are more useful for the blind and the Deaf-blind, who benefit from a written summary of what’s visually happening onscreen in each scene before the written dialogue begins. A braille terminal, used by the Deaf-blind, can’t convert open captions inlaid into the video’s frames into braille for its users, so these users won’t benefit from that.

Low Contrast

Contrast is important for low-vision users. We know that subtlety is all the rage, but design choices like putting blue text on a blue background makes it really difficult for some people to read. There are some great free tools like Das Plankton that will let you see if your contrast level is high enough to meet accessibility standards.

Schemes like this fail contrast testing on every level, so it’s best to avoid them. A better choice probably would have been white over a slightly darker blue.

The Ugly The Horrible Modal

Despite the obvious hard work that went into making Hillary’s website accessible, much of the effort is lost due to a modal that appears when visiting the website for the first time (or in incognito mode). The problem is that the modal doesn’t receive focus when it pops up, and its close button has no focus indicator. While it technically can be closed via keyboard by navigating backwards (or tabbing through every single link on the page) once it pops up, it’s not obvious visually when that close button has focus, and navigating backwards isn’t exactly intuitive.

Conclusion

With one glaring exception, it’s obvious that lots of thought and work had been put into making Hillary Clinton’s website accessible to voters with disabilities. There is definitely room for improvement with small things like somewhat irrelevant alternative attributes on photos, but on the whole the site is better on accessibility than the vast majority of the sites that we see.

Unfortunately, it is also obvious that accessibility is deeply neglected within Donald Trump’s website, which leaves a large swath of potential voters unable to browse to his stance on issues and other content. Hopefully, this will be attended to shortly.

Hopefully these auditing case studies lead you to think about your own website from the point of view of a person with a disability. There are plenty of challenges online for the disability community, but lots of those can be fixed with a few easy tweaks like the ones we covered here. We hope you'll use what you've learned to make your website accessible, too.

Catégories: Elsewhere

Anexus: How to use ES6 in Drupal 8

mer, 17/08/2016 - 12:58
How to use ES6 in Drupal 8

I bet many of you doesn't understand what is ES6, being honest I didn't know this term until a few days ago. 

ES6 stands for ECMAScript v6 or ES2015, but in simple words, is just Javascript; Correct Javascript as simple as that.

So, ES6 one of the latest version of Javascript specification, but is not supported by all browsers, because was released in June 2015, even worst in June 2016 we got ES7 and as you can imagine not supported yet.

Right now all browsers support ES5, then, if it's not compatible with all browsers, why ES6+ is a big thing? Because, now Javascript is more OOP, using classes, constants, and modules, enabling to create more complex and organized projects.

So, how we could use ES6 in our web projects like Drupal, to avoid to have a particular version of our site based on our client's browser? The solution is Babel

Babel transforms your code to ES5 to be used in your web applications. 

Babel works using plugins that allow the transformation and enable to use a particular plugin based on the source of your code like React that requires an especial plugin to do the conversion.

Let me show an example that creates a simple ReactJS.

1. Install Node.js

The first thing we need to do is install Node.js in your system, the easy way to do that is downloading the proper installer for our platform from https://nodejs.org/en/download

We need to install Node.js because we are going to use the NPM which is a package manager for javascript libraries 

2.  Modify gitignore file

Drupal 8 projects include their own .gitignore file, but because we are about to include npm in our development process, we need to add some extra rules listed below:

# Node.js # Logs logs *.log npm-debug.log* # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # node-waf configuration .lock-wscript # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules jspm_packages # Optional npm cache directory .npm # Optional REPL history .node_repl_history
3. Create a package.json file

To be able to distribute later your javascript library you need to create a package.json file, you create that file in interactive mode using the command:

$ npm init

In the end, you will get a file similar to the following file.

{   "name": "drupalreactform",   "version": "1.0.0",   "description": "ReactJS form to be embed in Drupal 8 Controller",   "main": "index.js",   "scripts": {     "test": "echo \"Error: no test specified\" && exit 1"   }   "author": "enzo - Eduardo Garcia",   "license": "ISC" } 4. Install Webpack

To expose our library in Drupal we need to create a distribution package, for that purpose, we will use [Webpack](webpack.github.io) that is a module bundler which takes modules with dependencies to generates static assets by bundling them together.

$ npm install webpack --save

The command about will install webpack with all required libraries and modify our package.json, in the same way that we use in Composer the composer.json file.

5. Configuring Webpack & creating bundle

It's necessary to inform to Webpack using file webpack.config.js, how we can to create our bundle to be used Drupal, the following configuration assumes we have a custom module located in web/modules/custom/mysearch.

var webpack = require('webpack'); var path = require('path'); var MODULE_BUILD_DIR = path.resolve(__dirname, 'web/modules/custom/mysearch/js'); var MODULE_APP_DIR = path.resolve(__dirname, 'web/modules/custom/mysearch/js/es6'); var config = {   entry: MODULE_APP_DIR + '/mysearch.form.jsx',   output: {     path: MODULE_BUILD_DIR,     filename: 'mysearch.form.js'   } }; module.exports = config;

With the configuration above, we are saying we will load the file mysearch.form.jsx and all included files in mysearch.form.js file

If you write something simple like

console.log('Hello ES6!');

You don't need any special transformation and you can create the bundle, for that propose you need to execute the following command:

$ ./node_modules/.bin/webpack -d

You will get an output similar to this image:

The generation will work correctly because the source in ES5 and the output too; So, no transformation was required.

6. Testing transformation

I know I said we would embed the file generated in Drupal, but in a development process is faster if we could test first outside Drupal, for that, we could create a file named test/es62es5/index.htm inside module directory  with the following content.

          Testing transformation ES6 -> ES5              

Opening that file in our browser would enable any possible error and reduce the change to blame Drupal 8 for a malfunction in our code.

7. Use Babel to transform ES6

Now we need to install Babel and Babel loaders to be able to transform our ReactJS form into ES5; the next command installs the required packages.

$ npm install babel-loader babel-preset-es2015 babel-preset-react --save

Also, we need to create a .babelrc file, to inform to Babel what presents will be used in transformation, check and example of that file below:

{   "presets" : ["es2015", "react"] }

Finally, we need to modify out webpack configuration to report what loader we are going to use in our transformation, the new aspect of webpack.config.js will be like this:

var webpack = require('webpack'); var path = require('path'); var MODULE_BUILD_DIR = path.resolve(__dirname, 'web/modules/custom/mysearch/js'); var MODULE_APP_DIR = path.resolve(__dirname, 'web/modules/custom/mysearch/js/es6'); var config = {     entry: MODULE_APP_DIR + '/mysearch.form.jsx',     output: {         path: MODULE_BUILD_DIR,         filename: 'mysearch.form.js'     },     module : {         loaders : [             {                 test : /\.jsx?/,                 include : MODULE_APP_DIR,                 loader : 'babel'             }         ]     } }; 8. Create React form

Before to create the form we need to install some libraries to build our form.

$ npm install react react-dom antd --save

If we plan to embed CSS or LESS files in our app, need to install loaders for that using the following instructions, and register the loader in webpack

$ npm install css-loader less less-loader style-loader  --save-dev

The code of our form will be an example form React created in a previous blog post:

import React, { PropTypes } from 'react'; var Search = React.createClass({     render: function(){         return (             React.createElement('form', {onSubmit: this.onSubmit, className: 'SearchForm', noValidate: true},                 React.createElement('input', {                     type: 'text',                     placeholder: 'Search'                 }),                 React.createElement("select", { placeholder: 'Category', value: '', onChange: this.changeHandler },                     React.createElement("option", { value: 1 }, "Software"),                     React.createElement("option", { value: 2 }, "Movie")                 ),                 React.createElement('button', {type: 'submit'}, "Go")             )         );     }, }); ReactDOM.render(React.createElement(Search),  document.getElementById("app"));

Of course, you can create a more advanced form, importing other libraries.

9. Include form in a Drupal controller

After "compile" our form in one file, the remaining step is to include it in a Drupal Controller, to do that you just need to follow the blog entry www.anexusit.com/blog/how-to-load-js-and-css-libraries-a-drupal-8-controller.

I hope did you find this blog entry useful.
 

enzo Wed, 08/17/2016 - 04:58
Catégories: Elsewhere

Liip: Drupalaton 2016

mer, 17/08/2016 - 11:13

Last week Drupalaton 2016 took place. With about 150 registrations this was the largest Drupalaton so far. The organizers did an amazing job in coping with this mass. There were two session threads and a sprint room. Of the many interesting presentations I would like to mention Fabian Bircher’s “Configuration Management: theory and practice” (a must for everyone who gets lost while trying to work in a team on a Drupal8 project) , Pieter Frenssen’s “Working with REST APIs”  (it was good to see how simple it is in Drupal8) and “Drupal 8 Media” from Pónya Péter, Szanyi Tamás and Rubén Teijeiro (seems we have a huge step forward in media handling since Drupal7!). I held a session on caching in Drupal 8 which was the shortened version the one I did on Drupal Developer Days in Milan.

Liip was a silver sponsor of the event.

Finally, some pictures on the Friday ship cruise. Thanks to Brainsum for sponsoring it!

Catégories: Elsewhere

DrupalCon News: Build your DrupalCon agenda: the session and BOF schedule is live

mer, 17/08/2016 - 05:00

DrupalCon starts in just 40 days. But you can plan your schedule today. There'll be more than 140 sessions, three keynotes, and one unforgettable pre-note.

Catégories: Elsewhere

Anchal: GSoC'16 - Port Comment Alter Module - Week 12

mer, 17/08/2016 - 02:00

As part of GSoC’16 I’m working on Porting Comment Alter module to Drupal 8 under the mentorship of boobaa and czigor. This blog is an excerpt of the work which I did in the twelfth week of the coding period of GSoC’16. The blogpost for the work done in the eleventh week can be found here.

The GSoC coding period ends this week and I’m glad that I was able to complete the project as per my proposal. All these three months have been very productive for me during which I learned a ton of things not just related to Drupal but also things like writing blogs, managing the project, etc.

During the coding period being stuck on a problem for 3-4 days and after countless hours of debugging finding the solution to be a one-liner or getting good reviews from mentors were some of the most intriguing and satisfying moments for me. I would like to thank both of my mentors boobaa and czigor for always helping me with coding, blogs and project management. It would have never been possible without them. I would also like to thank the whole Drupal community and Google Summer of Code for providing this opportunity to me.

Now talking about the work which I did this week, since most of the coding part was completed last week this week I focused on adding documentation for the module, doing cleaning and proof reading of the whole repo. I’ve created a short demo video: Comment Alter module for Drupal 8 demonstrating a simple use case and working of the module.


This week I also fixed some minor issues like changing the #parent property for the comment form for all the fields to avoid any clashes. In order to allow same name fields on both comment as well as parent entity the #parent property was used in the comment_alter_form_comment_form_alter() function. Due to this the submitted field values appeared at a different location preventing instances of multiple field value in the same #parent space or $form element (see commit).

In the upcoming week I would first move the module to drupal.org and will update the description about the module on the project page. I planned to move the module to drupal.org last week only but because of some complications, my mentors were unable to do the final review of the module. My mentors will do with the review before this Friday so I’ll move the module to drupal.org by then.

By the end of the week I’ve created a demo video for the module and fixed some issues. My mentors have already reviewed the code for the work which I did during this week. If anyone is interested, my progress can be followed on my GitHub repo.

Catégories: Elsewhere

OSTraining: Would You Be Interested in an Online Drupal 8 Day?

mar, 16/08/2016 - 20:59

Drupal 8 has been out since November and is now maturing into a really powerful platform.

We'd like to hold an online event all about Drupal 8. 

The event will be called "Drupal 8 Day" and will be an online version of a Drupal Camp.

It will be one complete day of live presentations. To get a good feel for this type of event, check out Wordsesh.org in the WordPress space.

The goal is to present Drupal 8 in the best possible light, especially to people who normally can't attend a Drupal Camp. We talk with a lot of people who just don't live near any kind of DrupalCamp. Some typical examples are people outside the big Canadian cities, people living in Eastern Europe but outside capital cities, and people in sub-Saharan Africa.

Catégories: Elsewhere

frobiovox.com: Basic Hello World with composer and php

mar, 16/08/2016 - 19:40
Getting started with composer I want this to be an introduction to using Composer. If you are looking for more information about using Drupal with Composer then you should checkout the official composer facade doc page on drupal.org. I will not be talking about publishing to Packagist. My php is nearly always for Drupal, and as such, if I publish anything it will most likely be to a project on...
Catégories: Elsewhere

Galaxy: GSoC’ 16: Port Search Configuration module; coding week #12

mar, 16/08/2016 - 19:14

Google Summer of Code' 16 coding phase has almost come to an end. The link for the final submissions will be open from 16-23 August 2016. I am sure all the students and mentors had a memorable time learning new technologies, sharing their ideas and giving shape for the proposals submitted to the organisations in the initial phase. Now ,its time for the works to get evaluated.

As you know, I was engaged with porting search configuration module to Drupal 8.The past week I devoted for documentation of the ported module, writing few tests for the module and then fixing some of the issues reported/ I came across in the testing time. The collapsible elements were not active. It had to be ported to the HTML5 elements. This was an important fix that I could achieve in the past week. So, I will help you understand what this actually is.
In Drupal 7, to make the field-sets collapsible, we had to set the collapsible attribute as true.

$form[‘settings’] = array(
‘#type’ = ‘fieldset’,
‘#title’ = t(‘Search Configuration’),
‘#collapsible’ => TRUE,
‘#collapsed’ => TRUE,
);

In Drupal 8, we make use of the HTML5 details and the open elements to achieve this collapsible state for the field-sets. I.e,

$form[‘settings’] = array(
‘#type’ = ‘details’,
‘#title’ = t(‘Search Configuration’),
‘#open’ => TRUE,
);

This was one important task that was left behind. I should have done it before. So, now the collapsible issue is fixed for now. Now, I need to spend some time for the testing the module documentation.

Another issue that I had to fix was the removal of the !placeholders. The !placeholder has been removed from the t() and the format_string() of Drupal 8. This has been moved to :variable format.
<.a href = “:variable”>@variable

Documentation is always an important process when it comes to any software development. We need to document the functionalities available and the various functions added to the module so that it will be beneficial for users as a future reference. I found time to document the important functions involved. I am sure this is really an essential component for developers who would like to contribute to this module. I have documented mainly the helper functions which have been used in the module.

I was mentored by Karthik Kumar, Naveen Valecha and Neetu Morwani. They stood along with me for any sort of help and helped me a lot to improve my basic skills in Drupal. Thanks to all of you for the support and co- operations. I am also thankful to Alan for his tips and suggestions even in his very busy schedules. He was also very much helpful in reviewing some of the patches for some of the issues reported. I can never forget the contribution of our organisation admin- Slurpee in the progress of my project. The weekly analysis of the project and the blog posts on the status updates have really benefitted me. I would also like to extend my sincere thanks to all the other community members for supporting me and guiding me in this long process. I really enjoyed this project development process. I could learn a lot and I want to stay connected with the Drupal community contributing to various projects and help the members of the community. It is really a proud moment to see our commits being reviewed by experienced developers. Moreover, the support from the community members was really exciting. People were ready to share ideas and help whenever I was stuck in the implementation process. I would also thank Google for bringing up a platform for university students to work on some of the high quality projects of the open source organisations.

Tags: drupal-planet
Catégories: Elsewhere

Arpit Jalan: GSOC 2016- Making Label Detection results configurable and improving documentation- Week 12

mar, 16/08/2016 - 18:02
TL;DR Last week I had worked moving the helper functions for filling Alt Text of image file to a new service; and moving the reused/supporting functions of the tests to an abstract parent class, GoogleVisionTestBase. This week I have worked on improving the documentation of the module and making the label detection results configurable.
With all major issues and features committed to the module, this week I worked on few minor issues, including the documentation and cleanup in the project..
It is an immense pleasure for me that I am getting the feedbacks from the community on the Google Vision API module. An issue Improve documentation for helper functions was created to develop more on documentation and provide the minute details on the code. I have worked on it, and added more documentation to the helper functions so that they can be understood better.
In addition, a need was felt to let the number of results obtained from the Vision API for each of the feature as configurable, and allow the end user to take the control on that. The corresponding issue is Make max results for Label Detection configurable. In my humble opinion, most of the feature implementations and requests to the Google Cloud Vision API have nothing to do with allowing the end user to configure the number of results. For instance, the Safe Search Detection feature detects and avoids the explicit contents to be uploaded, and does not need the number of results to be configurable. However, the taxonomy tagging using Label Detection should be user dependent, and hence, I worked on the issue to make the value configurable only for Label Detection purpose. This value can be configured from the Google Vision settings page, where we set the API key. I have also developed simple web tests to verify that the value is configurable. Presently, the issue is under review.
I have also worked on standard coding fixes and pa-reviews and assisted my mentor, Naveen Valecha to develop interfaces for the services. I assisted him on access rights of the functions, and fixing the documentation issues which clashed with the present one.
Lastly, I worked on improving the README and the module page to include all the new information and instructions implemented during the Google Summer of Code phase.
With all these works done, and all the minor issues resolved, I believe that the module is ready for usage with all the features and end user cases implemented.
Next Week, I’ll work on creating a video demonstration on how to use Google Vision API to fill the Alt Text attribute of an image file, detect the emotion in the user profile pictures and to group the similar images which share the same dominant color.
Catégories: Elsewhere

Four Kitchens: Launch Announcement: American Craft Council

mar, 16/08/2016 - 18:00

The American Craft Council (ACC) gets a shiny new Drupal 8 site, encouraging visitors to appreciate the culture of craft. […]

Catégories: Elsewhere

Acquia Developer Center Blog: Making Drupal User File Uploads Safe(r)

mar, 16/08/2016 - 16:48

Do you let users upload files to your Drupal site? You know that "user" is a synonym for attacker, right?.

To keep your Drupal site secure you need to remember and account for the fact that any string or file upload that comes from a user can be an attack. Even if you don't let users register without administrator approval, a site user may have re-used their password or otherwise have their account compromised and then used to attack the site.

Tags: acquia drupal planet
Catégories: Elsewhere

Zivtech: 3 Developer Podcasts to Hear

mar, 16/08/2016 - 15:58
Podcasts are a great way to get intel on the go. Listen while you walk, drive, exercise, or unwind. According to recent research in The Infinite Dial 2016, podcast listening has experienced sharp gains, with an average of 5 podcasts consumed per week.


If you can think of a topic, there’s probably a podcast about it. Web development is no different. Here are three podcasts to listen to if you’re a developer. Code Newbies​ For new developers, it’s enlightening to listen to others talk about how they started coding and the struggles that they faced along the way. Saron always interviews interesting people (including many women in tech) and has a segment where she asks about the worst advice the interviewee has ever received. With over one hundred episodes, there’s a lot of content to leave you feeling inspired. Javascript Jabber This podcast has an incredible amount of content at over two hundred episodes and counting. Rather than a single interviewee, the episodes include panels of individuals, all with different but equally insightful perspectives. As a newer developer, you’ll get exposure to new concepts and resources, which is extremely valuable considering Javascript is all the rage these days. PhillyDev Podcast This podcast is fairly new and was created by a NYCDA grad. It’s fun and informative and provides a closer look at the Philly tech scene: it highlights the movers and shakers, how they got into the field, and the technologies they use. Steven always includes his “sweet nug” segment where he asks the interviewee to share a piece of wisdom or a recommendation for his listeners.

Do you have a favorite podcast about development? Let us know in the comments below!

Catégories: Elsewhere

InternetDevels: Lviv Euro DrupalCamp 2016: every drupaler’s destination for September 3-4

mar, 16/08/2016 - 14:47

Greetings, dear readers! We have recently welcomed you behind the curtains to show you how we organize our famous IT events. And now it’s time to announce one of them approaching! This is a very famous annual Drupal meetup, long awaited by so many people across Ukraine and beyond. Lviv Euro DrupalCamp 2016 in the magic city of Lviv is coming on September 3-4!

Read more
Catégories: Elsewhere

Jay L.ee: How To Make The Web Widgets Module Work With Drupal 7.50

mar, 16/08/2016 - 14:04

For users of the awesome Web Widgets module, you'll notice that it'll no longer work after installing Drupal 7.50. But after digging into this issue, I realized that the problem was much simpler than I had originally imagined (Drupal 7.50 supporting PHP 7). Sometimes all it takes is to just RTFM lol. Anyway, here's how to solve it:

1) Understand what the source of the issue is. The cause of the problem was "Protection against clickjacking enabled by default".

Tags: Drupal 7Drupal Planet
Catégories: Elsewhere

Pages