Create a React Class in 60 Seconds

React is a JavaScript library built and maintained by Facebook that aims to make it easy to build user interfaces using, you guess it, JavaScript.

In this video, we’re going to take a quick look at how easy to is to get started using React. We’ll be learning a little bit more about React, as a library, and we’ll see how we can begin implementing it in our projects.

As mentioned in the video:

React is a JavaScript framework for building user interfaces. Unlike other front-end JavaScript frameworks, it doesn’t provide everything you will need to build a web application. Instead, it focuses only on the view layer. You use React by creating “chunks” of the overall view; these “chunks” are properly called components.

This is arguably one of the most important takeaways. The library doesn’t aim to be full stack. Instead, it focuses on the front-end, unlike many of the tools that we see today.

Don’t hesitate to leave your comments and feedback in the comments as we’d love to feature more content like this based on what you, as the audience and our readers, are seeking to learn!

In the meantime, don’t hesitate to take a look at the React documentation.

Want More React?

If you’re interested in seeing an application of React in the wild, then perhaps check out Quotes on CodeCanyon. It’s an iOS application built using React. Its goal is to provide an example application for how you can get started with using React to build iOS-specific applications. 

You may also be interested in the following courses:


Source: Nettuts Web Development

Create a React Class

React is a JavaScript library built and maintained by Facebook that aims to make it easy to build user interfaces using, you guess it, JavaScript.

In this video, we’re going to take a quick look at how easy to is to get started using React. We’ll be learning a little bit more about React, as a library, and we’ll see how we can begin implementing it in our projects.

As mentioned in the video:

React is a JavaScript framework for building user interfaces. Unlike other front-end JavaScript frameworks, it doesn’t provide everything you will need to build a web application. Instead, it focuses only on the view layer. You use React by creating “chunks” of the overall view; these “chunks” are properly called components.

This is arguably one of the most important takeaways. The library doesn’t aim to be full stack. Instead, it focuses on the front-end, unlike many of the tools that we see today.

Don’t hesitate to leave your comments and feedback in the comments as we’d love to feature more content like this based on what you, as the audience and our readers, are seeking to learn!

In the meantime, don’t hesitate to take a look at the React documentation.

Want More React?

If you’re interested in seeing an application of React in the wild, then perhaps check out Quotes on CodeCanyon. It’s an iOS application built using React. Its goal is to provide an example application for how you can get started with using React to build iOS-specific applications. 

You may also be interested in the following courses:


Source: Nettuts Web Development

Stevie Wonder and the Rise of the Machine Readers

I love looking at early technology and seeing how people problem-solve

A Kurzweil Reading Machine

A Kurzweil Reading Machine

Back in the early 80’s, I remember our sixth-grade teacher taking us to see a ‘new wonder device’ – a Kurzweil reading machine.

It wasn’t exactly a sexy design. It looked like a photocopier but was closer to the size of a family washing machine. You placed an open book on the top and it read aloud, even turning pages when required. The voice synthesizer was a little harsh on the ear but, hey, it was 1981 and this thing spoke better english than R2-D2, so it was hard to be super-critical.

We all thought it was very cool – but also wet-your-pants hilarious when the machine attempted to ‘read’ illustrations as text. “Period,… tee, …. owe, owe, period…. hyphen, … hyphen, owe.., jay, owe“.

It was funny. Trust me.

These machines were a really big deal at the time. Walter Cronkite once used one to sign off from his national TV news show and Stevie Wonder adored his. It’s easy to forget that reading privacy is an everyday luxury that visually-challenged users lose. This invention gave that back.

So, Was This the First Reading Machine?

Not quite.

A blind user with the Optophone.

A blind user with the Optophone.

This is the Optophone, a reading machine that was invented just before the First World War – in 1913.

How is that even possible, right?

This is before television, transistors, vacuum tubes – planes still look like jumped-up kites. It’s hard to even contemplate tackling this challenge at a time when electricity in the home was still a novelty.

But someone did. His name was Edmund Edward Fournier d’Albe and he was an Irish physicist, inventor, and all-round renaissance guy.

How did the Optophone work?

The Optophone

The Optophone

Like Kurzweil’s machine, readers placed the book on the glass top and the reading head below rocked from side-to-side, playing audio to the user through a headset.

Fournier d’Albe’s invention relied on using selenium cells to turn reflected light from the page into different musical tones.

Users would learn to associate particular sounds with letters, and construct words and sentences that way.

It certainly wasn’t a perfect system. Even the most skilled blind users only achieved reading speeds of around 60 words per minute. Most sighted readers hum along at closer to 300. Still, it sure beats zero.

But perhaps the biggest hurdle for users was the so-called ‘music’ it produced. Unfortunately, the tones it made were teeth-jarringly awful.

Don’t believe me? We can still listen to them today on this SoundCloud recording.

Continue reading %Stevie Wonder and the Rise of the Machine Readers%


Source: Sitepoint

Organize 2x The Keys With KeySmart 2.0

Sure, a bulky, noisy key ring is one of life’s smaller problems. But that doesn’t mean we can’t solve it—especially when the solution is as sleek as this one. And 30% off, to boot. Get the KeySmart 2.0 for $15.99. https://youtu.be/t13JYSS380o Keep up to 10 keys neatly tucked away in this compact organizer. The KeySmart […]

Continue reading %Organize 2x The Keys With KeySmart 2.0%


Source: Sitepoint

Frameworkless JavaScript

JavaScript frameworks offer many functionality and it’s not surprising at all that they’re getting more and more popular. They’re powerful and not so hard to master. Generally, we use them for large and complex applications, but in some cases also for smaller ones. After having learned how to use a framework, you’re tempted to use it for every app you want to develop, but you forget that sometimes using just old good JavaScript might be sufficient.

In this article I’ll discuss about the pros and cons of using a framework and what you should consider before starting your project.

Frameworks Are Powerful

Frameworks have their advantages. First of all, you don’t have to bother about namespaces, cross-browser compatibility, writing several utilities functions, and so on. You work on well organized code, made by some of the best developers in the industry. If you know the framework well, your development speed can be incredibly fast. Moreover, if you have problems with any of the features, it’s easy to find the documentation of the framework, tons of free tutorials, and big community happy to help. What if you need more manpower? There’s no hassle with hiring. If you know how a given framework works, no matter what the project is about, you’ll feel like at home. And the code of the framework itself evolves every day, to be even better, stronger, and more secure. So, you can just focus on what matters: your work.

Continue reading %Frameworkless JavaScript%


Source: Sitepoint

Using the doingitwrong Theme to Learn WordPress Theme Review

Did you know that all themes hosted on the WordPress.org repository undergo a thorough review process by dedicated volunteer members of the Theme Review Team (TRT)?

Not all professionals working with WordPress are aware of the review process and what this involves. If you’re among them, should you decide to submit your theme to the repository for the first time, you could be in for a surprise.

Realizing that there is a substantial number of guidelines and best practices to follow can strike you as being a bit overwhelming at first. If a reviewer keeps coming back asking for changes to your theme, you can even be tempted to give in to mounting frustration and throw in the towel.

But wait, don’t give up just yet.

In this article, you’ll meet an unusual learning tool of the TRT’s own devising, i.e., the doingitwrong theme.

I’m going to show you what it is and how you can use it to your advantage.

What Is the doingitwrong Theme?

The TRT has set up a fair number of resources to get both new reviewers and theme developers up to speed with the repository guidelines.

The core resource is the Theme Review Handbook. Here you can find chapters about the review process, theme requirements (stringent rules a theme must abide by), and recommended theme features (optional guidelines you’re free to ignore, although it would be nice if you didn’t).

Continue reading %Using the doingitwrong Theme to Learn WordPress Theme Review%


Source: Sitepoint

Giveaway: Win A $999 Alienware Gaming Laptop

Don’t let your laptop slow you down when you’re gaming. We’re giving away the best gaming-centric laptop out there—and it couldn’t be easier to enter to win. The Alienware gaming laptop has an all-day battery life for non-stop gaming, and a thin, light design so you can take it anywhere. Meanwhile, the quad HD+ display […]

Continue reading %Giveaway: Win A $999 Alienware Gaming Laptop%


Source: Sitepoint

Liking, Watchlisting and Uploading through Vimeo’s API

In a previous post, we used the Vimeo API to build a rudimentary video application with Silex and Twig. We added login and user feed functionality and wrapped it all up with a video searching feature. In this one, we’ll add in liking a video, adding a video to a watchlist for later, and uploading videos via the Vimeo API.

Vimeo Logo

Prerequisites

To get up to speed, please skim through the code presented in the previous part and get it to run in your development environment (preferably Homestead Improved). Alternatively, just download the final code of the previous post here. Once you’re ready, continue with the content below.

Interacting with Videos

In this section, you’re going to add the capability to like and add videos to be watched later. But before that, you first need to update the scopes for the Vimeo login (in the previous post, we only asked for public and private scope permissions). Add interact as one of the items, and once that’s done, access the login page in the browser and try logging in again.

$scopes = array('public', 'private', 'interact');
$state = substr(str_shuffle(md5(time())), 0, 10);
$_SESSION['state'] = $state;

$url = $vimeo->buildAuthorizationEndpoint(REDIRECT_URI, $scopes, $state);

$page_data = array(
    'url' => $url
);

It should now show an additional item under permissions. Check that to allow video interactions.

Continue reading %Liking, Watchlisting and Uploading through Vimeo’s API%


Source: Sitepoint

How to Develop a Membership Site With WordPress: Part 2

Final product image
What You’ll Be Creating

In the first part of this series, we covered customizing the registration and login forms. Today we’ll be covering how to add custom fields to the registration form. We’ll be adding a text input for a Twitter handle and a checkbox where users will need to agree to terms before registering. The work required can be divided into three parts:

  • Adding the fields themselves
  • Validation on the fields
  • Processing the data

We will also very briefly discuss the best ways to style your outgoing emails. This means users will receive nice branded emails when they register.  

Quickly before we start, make sure Anyone can register is ticked in your WordPress settings (Settings > General).  

General Settings

There’s Lots to Do; Let’s Get Started

One of the greatest things about WordPress is the way it supplies you with actions and filters. These allow us to hook onto events or filter content, which gives us the opportunity to extend WordPress gracefully.   

So using the register_form action, let’s hook into the registration form and add our fields. Copy the following function to our admin.php that we created in part one of this series.

Basically we are injecting some new fields into our registration form. The markup used is mimicking that of the native fields. We also want to retain the values if the page is reloaded, so we will check if they exist in the $_POST super global. You might be wondering why our Twitter label is wrapped in a function: <?php _e( 'Twitter name', 'tutsplus' ) ?>.

The _e function allows translation to occur—you can read more about it in the WordPress Codex.

This is great, but how about some validation? As it stands, users can put whatever they want in there or just leave it blank. Let’s make our fields required and make sure the text field only takes in regular characters to prevent malicious attacks. This time we will be using a WordPress filter: registration_errors

The above filter is passed three parameters: 

  1. The errors that have been processed
  2. The user’s email
  3. The user’s sanitized user name

The function is triggered after the form is submitted but before the data hits the database. In our case we are checking if the fields are empty and if there are any bizarre characters in our Twitter name input. If any of these are true we pass an error message to the $error object that is returned.   

Note: if you are getting an empty error box, don’t worry. The security plugin we installed in part one has a default setting that hides the messages. Under the WordPress Tweaks section, uncheck the option Disable login error messages.  

Login page showing four error messages

Now the final piece of our puzzle: processing the data so it’s saved in our database against that user. Again we will be using a WordPress defined action (user_register) to hook into this process. It takes one parameter, the user_id—that way it knows who to save the data against. Assuming the $_POST superglobal contains our data, we can save it using update_user_meta.

Custom Fields in the Admin

Right now we have collected the users’ data – including our custom fields – but we can not edit those values in the WordPress admin. Let’s hook that up. In our admin.php add the following function:

Using some WordPress actions we are easily able to add custom fields. 

Now to process the custom user meta. 

Redirect on Login

Finally we want to redirect our users to a specific page when they are logged in. The default sends them to the WordPress back end. Forget that. Let’s send them to a “my account” page. So firstly you’ll need to create this page in the back end. Don’t worry about content for now, because we’ll get into that in the next part of the series. 

Now that we have our page, paste the code below into ____.php and give it a test drive. Assuming your “my account” page has the slug my-account it should work. Yet again we have used a WordPress filter to achieve this sorcery. 

In a nutshell, the code checks for a user, and if they are an admin user they are directed to the default place, else they are redirect to the my-account page. All this is triggered when the user logs in using the filter login_redirect

A Quick Note on Outgoing Emails

When users register on your site they will be receiving confirmation emails. Also if a user forgets their password they have the ability to retrieve it over email. So it’s important we give these emails some love and attention if we want our membership site to be all that. 

Now there are a few ways to do this. For all the purists out there you can use WordPress filters to change the email content type and style your emails—see the WordPress Codex. Alternatively there’s a host of plugins out there designed for this purpose. 

Personally I like to use MailChimp’s Mandrill to send emails out of my WordPress sites. It’s not too tricky to set up and it’s full of features, one of which is being able to apply templates/styles to your outgoing emails. 

What’s Next?

In the next and final part of the series we will be making a basic account section whereby the logged-in users will be able to edit their details. We also want administrators to be able to edit these details from the WP admin area, so we will be adding some custom fields in there too.

If you have any suggestions or questions please leave a comment. I’ll do my best to reply in a timely fashion. 

Things to Note

Please note: if you are downloading the code from the GitHub repository it includes all the files to get your theme up and running. The idea is that you can grab the repo and just run the necessary Gulp and Bower commands and you’ll be away!  If you just want the files that contain code specific to this series the files are listed below. 


Source: Nettuts Web Development

Developing a Membership Site With WordPress: Part 2

Final product image
What You’ll Be Creating

In the first part of this series, we covered customizing the registration and login forms. Today we’ll be covering how to add custom fields to the registration form. We’ll be adding a text input for a Twitter handle and a checkbox where users will need to agree to terms before registering. The work required can be divided into three parts:

  • Adding the fields themselves
  • Validation on the fields
  • Processing the data

We will also very briefly discuss the best ways to style your outgoing emails. This means users will receive nice branded emails when they register.  

Quickly before we start, make sure Anyone can register is ticked in your WordPress settings (Settings > General).  

General Settings

There’s Lots to Do; Let’s Get Started

One of the greatest things about WordPress is the way it supplies you with actions and filters. These allow us to hook onto events or filter content, which gives us the opportunity to extend WordPress gracefully.   

So using the register_form action, let’s hook into the registration form and add our fields. Copy the following function to our admin.php that we created in part one of this series.

Basically we are injecting some new fields into our registration form. The markup used is mimicking that of the native fields. We also want to retain the values if the page is reloaded, so we will check if they exist in the $_POST super global. You might be wondering why our Twitter label is wrapped in a function: <?php _e( 'Twitter name', 'tutsplus' ) ?>.

The _e function allows translation to occur—you can read more about it in the WordPress Codex.

This is great, but how about some validation? As it stands, users can put whatever they want in there or just leave it blank. Let’s make our fields required and make sure the text field only takes in regular characters to prevent malicious attacks. This time we will be using a WordPress filter: registration_errors

The above filter is passed three parameters: 

  1. The errors that have been processed
  2. The user’s email
  3. The user’s sanitized user name

The function is triggered after the form is submitted but before the data hits the database. In our case we are checking if the fields are empty and if there are any bizarre characters in our Twitter name input. If any of these are true we pass an error message to the $error object that is returned.   

Note: if you are getting an empty error box, don’t worry. The security plugin we installed in part one has a default setting that hides the messages. Under the WordPress Tweaks section, uncheck the option Disable login error messages.  

Login page showing four error messages

Now the final piece of our puzzle: processing the data so it’s saved in our database against that user. Again we will be using a WordPress defined action (user_register) to hook into this process. It takes one parameter, the user_id—that way it knows who to save the data against. Assuming the $_POST superglobal contains our data, we can save it using update_user_meta.

Custom Fields in the Admin

Right now we have collected the users’ data – including our custom fields – but we can not edit those values in the WordPress admin. Let’s hook that up. In our admin.php add the following function:

Using some WordPress actions we are easily able to add custom fields. 

Now to process the custom user meta. 

Redirect on Login

Finally we want to redirect our users to a specific page when they are logged in. The default sends them to the WordPress back end. Forget that. Let’s send them to a “my account” page. So firstly you’ll need to create this page in the back end. Don’t worry about content for now, because we’ll get into that in the next part of the series. 

Now that we have our page, paste the code below into ____.php and give it a test drive. Assuming your “my account” page has the slug my-account it should work. Yet again we have used a WordPress filter to achieve this sorcery. 

In a nutshell, the code checks for a user, and if they are an admin user they are directed to the default place, else they are redirect to the my-account page. All this is triggered when the user logs in using the filter login_redirect

A Quick Note on Outgoing Emails

When users register on your site they will be receiving confirmation emails. Also if a user forgets their password they have the ability to retrieve it over email. So it’s important we give these emails some love and attention if we want our membership site to be all that. 

Now there are a few ways to do this. For all the purists out there you can use WordPress filters to change the email content type and style your emails—see the WordPress Codex. Alternatively there’s a host of plugins out there designed for this purpose. 

Personally I like to use MailChimp’s Mandrill to send emails out of my WordPress sites. It’s not too tricky to set up and it’s full of features, one of which is being able to apply templates/styles to your outgoing emails. 

What’s Next?

In the next and final part of the series we will be making a basic account section whereby the logged-in users will be able to edit their details. We also want administrators to be able to edit these details from the WP admin area, so we will be adding some custom fields in there too.

If you have any suggestions or questions please leave a comment. I’ll do my best to reply in a timely fashion. 

Things to Note

Please note: if you are downloading the code from the GitHub repository it includes all the files to get your theme up and running. The idea is that you can grab the repo and just run the necessary Gulp and Bower commands and you’ll be away!  If you just want the files that contain code specific to this series the files are listed below. 


Source: Nettuts Web Development