Friday, July 21, 2017

Thumbelina – Lightweight jQuery Content Slider

Thumbelina is a very lightweight jQuery content slider designed for galleries of thumbnail images. It integrates well with other plugins, and is a perfect solution where too many thumbnails would clutter the page.


by via jQuery-Plugins.net RSS Feed

Flow

Flow

Slick little One Pager for Flow - a free typeface for wireframing. The Single Page site features an interactive, central demo area with clear alongside settings to switch between the 3 weights (circular, rounded and block). The mobile adaption is also well thought of with all elements reduced and re-arranged. Awesome freebie and lovely One Pager, cheers Dan!

by Rob Hope via One Page Love

#344: JavaScript Factory Functions with ES6+

This week's JavaScript newsRead this e-mail on the Web
JavaScript Weekly
Issue 344 — July 21, 2017
“In JavaScript, any function can return an object. When it does so without the new keyword, it’s a factory function.”
Eric Elliot

A fun look at the mechanics behind a seemingly simple snippet of JavaScript that doesn’t do what you’d expect. Beware of hidden Unicode characters.
Stefan Judis

This popular survey returns for its second year to see which “buzzwords are here to stay and which ones will soon fall to JavaScript fatigue”.
Sacha Greif

GrapeCity Wijmo
This free e-book teaches you about the strengths and weaknesses of JavaScript’s top frameworks and offers a methodology for selecting which framework works best for your team and project. Get it now.
GrapeCity Wijmo   Sponsor

Nirmalya Ghosh shows you how to use Firebase’s real-time database features, coupled with create-react-app, to build a basic Reddit clone with live voting.
SitePoint

Compiles specially written JavaScript functions into shader language (GLSL) and runs them on the GPU via WebGL.
Sapuan, Saw and Cheah

“a good bit has changed in browser land since the last ‘You Might Not Need jQuery’ article you might have stumbled upon”
Ollie Williams

An explanation of a proposed new binary AST format and what benefits it could bring.
Shu-yu Guo

Jobs Supported by Hired.com

  • Front End Engineer at EDITED (London)Join us to impact how the world's biggest retailers operate by making a web app with great UX and DX using React, Redux and Glamor EDITED
  • Mobile and client library SDK developerWe’re a growing realtime platform solving truly complex distributed problems for the developer community. If you enjoy challenging your grey matter and building great web services, apply. ABLY.IO
  • Senior Software Engineer - JavaScriptWe are looking for a Software Engineer with strong interest and experience in UI engineering who can help take our newest product, New Relic Infrastructure, to the next level.  New Relic

Can't find the right job? Want companies to apply to you? Try Hired.com.

In Brief

Angular 4.3 Now Available news
A minor release that contains no breaking changes. Full changelog.
Stephen Fluin

New Book: How to Earn More as a Software Developer 
Learn new skills faster, find work you love, earn what you're worth. Get it today for $0.99 (limited time).
Simple Programmer  Sponsor

Implementing the MVC Design Pattern in Vanilla JavaScript tutorial
SitePoint

How to Use Polymer with Webpack tutorial
Rob Dodson

Extracting Logic from React Components tutorial
Jack Franklin

An ES Proposal Explained: RegExp Unicode Property Escapes tutorial
Dr. Axel Rauschmayer

Webpack’s import() Will Soon Fetch JS + CSS — Here’s How To Do It tutorial
James Gillmore

Preventing a Mobile Browser From Sleeping with NoSleep.js tutorial
NoSleep.js is a small Wake Lock API shim to prevent the browser and device from going to sleep.
David Walsh

Angular Testing In Depth: Components tutorial
Gábor Soós

4 Important Changes in Vue.js 2.4 tutorial
Anthony Gore

Catch Errors Before Your Users Do 🎣 
Instantly know whats broken and why. Monitoring, alerting & analytics for JavaScript errors. Try it!
ROLLBAR  Sponsor

RxJS By Example video
Ben Lesh

Vue.js 2.0 From Scratch in 60 Minutes video
Brad Traversy

Control Things in the Real World with Web Bluetooth and Puck.js video
Gordon Williams

emojify-webpack-plugin: Transforms Code Into Emoji tools
A humorous idea if normal minification isn’t your thing.
Mechazawa

“CircleCI 2.0 is fast. We reduced builds from minutes to 12 seconds.” tools
CircleCI  Sponsor

Express React Starter: Starter Project for create-react-app + Express.js code
Burke Holland

Wade: Fast, 1KB Trie-based Search for JavaScript code
And a related blog post.
Kabir Shah

Curated by Peter Cooper and published by Cooperpress.

Like this? You may also enjoy: FrontEnd Focus : Node Weekly : React Status

Stop getting JavaScript Weekly : Change email address : Read this issue on the Web

© Cooperpress Ltd. Fairfield Enterprise Centre, Lincoln Way, Louth, LN11 0LS, UK


by via JavaScript Weekly

Understand the Basics of Laravel Middleware

In this article, we'll dive deep into the Laravel framework to understand the concept of middleware. The first half of the article begins with an introduction to middleware and what it's actually used for.

As we move on, we'll cover how to create custom middleware in a Laravel application. After creation of your custom middleware, we'll explore the options available to register it with Laravel so that it could be actually invoked during the request processing flow.

I hope that you consider yourself familiar with basic Laravel concepts and the Artisan command-line tool to generate the scaffolding code. Of course, a working installation of the latest Laravel application allows you to run the examples provided in this article straight away.

What Is Middleware in Laravel?

We could think of middleware as a mechanism that allows you to hook into the typical request processing flow of a Laravel application. A typical Laravel route processing goes through certain stages of request processing, and the middleware is one of those layers an application has to pass through.

So what exactly is the point of hooking into the Laravel request processing flow? Think of something that requires an execution at the early stages of bootstrapping of an application. For example, it's necessary to authenticate users at the early stages to decide whether they're allowed to access the current route.

A few things I could think of that you could achieve through middleware are:

  • logging of requests
  • redirecting users
  • altering/sanitizing the incoming parameters
  • manipulating the response generated by the Laravel application
  • and many more

In fact, the default Laravel application already ships a couple of important pieces of middleware with it. For example, there's middleware that checks if the site is in maintenance mode. On the other hand, there's middleware to sanitize the input request parameters. As I mentioned earlier, the user authentication is also achieved by the middleware itself.

I hope that the explanation so far helps you to feel more confident about the term middleware. If you're still confused, don't worry about it as we're going to build a piece of custom middleware from the next section onwards that should help you understand exactly how middleware could be used in the real world.

How to Create Custom Middleware

In this section, we'll create our custom middleware. But what exactly is our custom middleware going to accomplish?

Recently, I came across a custom requirement from my client that if users access the site from any mobile device, they should be redirected to the corresponding sub-domain URL with all the querystring parameters intact. I believe this is the perfect use case to demonstrate how Laravel middleware could be used in this particular scenario.

The reason why we would like to use middleware in this case is the need to hook into the request flow of the application. In our custom middleware, we'll inspect the user agent, and users are redirected to the corresponding mobile URL if they are using a mobile device.

Having discussed all that theory, let's jump into the actual development, and that's the best way to understand a new concept, isn't it?

As a Laravel developer, it's the Artisan tool that you'll end up using most of the time to create basic template code should you wish to create any custom functionality. Let's use it to create a basic template code for our custom middleware.

Head over to the command line and go the document root of your project. Run the following command to create the custom middleware template MobileRedirect.

And that should create a file app/Http/Middleware/MobileRedirect.php with the following code.

More often than not, you'll notice the implementation of the handle method that acts as the backbone of the middleware, and the primary logic of the middleware you're looking to implement should go here.

Let me grab this opportunity to introduce the types of middleware that Laravel comes with. Mainly, the are two types—before middleware and after middleware.

As the name suggests, the before middleware is something that runs before the request is actually handled and the response is built. On the other hand, the after middleware runs after the request is handled by the application and the response is already built at this time.

In our case, we need to redirect the user before the request is handled, and hence it'll be developed as a before middleware.

Go ahead and modify the file app/Http/Middleware/MobileRedirect.php with the following contents.

For the sake of simplicity, we just check the existence of the mobile querystring parameter, and if it's set to TRUE, the user will be redirected to the corresponding mobile site URL. Of course, you would like to use the user agent detection library should you wish to detect it in real time.

Also, you would like to replace the mobile-site-url-goes-here route with the proper route or URL as it's just a placeholder for demonstration purposes.

Following our custom logic, there's a call to $next($request) that allows the request to be processed further in the application chain. The important thing to note in our case is that we've placed the mobile detection logic prior to the $next($request) call, effectively making it a before middleware.

And with that, our custom middleware is almost ready to be tested. At the moment, there's no way Laravel knows about our middleware. To make that happen, you need to register your middleware with the Laravel application, and that's exactly the topic of our next section.

Before heading into the next section, I would like to demonstrate how the after middleware looks, just in case someone out there is curious about it.

As you would already have noticed, the custom logic of the middleware gets executed after the request is processed by the Laravel application. At this time, you have access to the $response object as well, which allows you to manipulate certain aspects of it if you wish to.

So that was the story of after middleware.

Our Custom Middleware in Action

This section describes the process of registering the middleware with the Laravel application so that it could actually be invoked during the request processing flow.

Go ahead and open the file app/Http/Kernel.php and look for the following snippet.

As you can see, the $middleware holds the array of middleware that comes with the default installation of Laravel. The middleware listed here will be executed upon every Laravel request, and thus it's an ideal candidate to place our own custom middleware.

Go ahead and include our custom middleware as shown in the following snippet.

Now, try to access any of your Laravel routes with the querystring mobile=1, and that should trigger our middleware code!

So that's how you're supposed to register your middleware that needs to be run on every request. However, sometimes you wish to run your middleware for the specific routes only. Let's check how to achieve that by using the $routeMiddleware.

In the context of our current example, let's assume that the users will be redirected to a mobile site if they access any specific route on your site. In this scenario, you don't want to include your middleware in the $middleware list.

Instead, you would like to attach the middleware directly to the route definition, as shown below.

In fact, we could go one step further and create an alias for our middleware so that you don't have to use inline class names.

Open the file app/Http/Kernel.php and look for the $routeMiddleware that holds the mappings of aliases to middleware. Let's include our entry into that list, as shown in the following snippet.

And the revised route definition looks like this.

And that's the story of registering middleware with the Laravel application. That was pretty straightforward, wasn't it?

In fact, we've reached the end of this article, and I hope you've thoroughly enjoyed it.

Conclusion

Exploring the architectural concept in any framework is always exciting stuff, and that's what we did in this article as we explored middleware in the Laravel framework.

Starting with a basic introduction to middleware, we shifted our attention to the topic of creating custom middleware in a Laravel application. And it was the latter half of the article that discussed how to register your custom middleware with Laravel, and that was also the opportunity to explore the different ways you could attach your middleware.

Hopefully the journey was fruitful and the article has helped you enrich your knowledge. Also, if you want me to come up with specific topics in the upcoming articles, you could always drop me a line about that.

That's it for today, and don't hesitate to shoot your queries, if any, using the feed below!


by Sajal Soni via Envato Tuts+ Code

Change Gout

Equal parts interactive documentary and WebGL exploration, Change Gout explores the misconceptions behind gout disease. Doctors and pharmacists can deep dive into new research on gout.
by via Awwwards - Sites of the day

How Celebrity Endorsements Influence Young Consumers

More than 50 percent of internet users say they follow some sort of celebrity account on social media sites, with figures reaching as high as 68 percent among 16-24 years old according to research from GlobalWebIndex. While this kind of marketing provides brands with targeted exposure to their...

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Irfan Ahmad via Digital Information World

Messenger Chatbots: How to Get Started

Wondering if Messenger chatbots are right for your business? Want to know how to build your own chatbot? To explore why and how to create Facebook Messenger chatbots, I interview Ben Beck. More About This Show The Social Media Marketing podcast is an on-demand talk radio show from Social Media Examiner. It’s designed to help [...]

This post Messenger Chatbots: How to Get Started first appeared on .
- Your Guide to the Social Media Jungle


by Michael Stelzner via