Friday, July 13, 2018

TypeScript 3 RC and a npm security issue to be aware of

#394 — July 13, 2018

Read on the Web

JavaScript Weekly

Toast UI Image Editor: A Full-Featured Photo Image Editor — From the creators of TUI Calendar and TUI Chart controls comes a powerful JavaScript image editor control. Live demo here.

NHN Entertainment

Compromised eslint-scope npm Package Published — Just over 24 hours ago, an npm account was compromised and a popular package (eslint-scope) was infected with malicious code. Post mortem from ESLint here. The long and short of it is you’re recommended to review your own use of this module and to move to using 2FA on your own npm accounts. Revoking npm tokens and clearing node_modules may also be a good idea.

The npm Blog

Webpack 4 Fundamentals 🛠️ by Webpack Core Maintainer, Sean Larkin — Webpack 4 is the most popular and flexible build tool – Vue CLI, create-react-app and the Angular CLI all use Webpack under the hood – as soon as you need something custom, you'll need to know Webpack.

Frontend Masters sponsor

TypeScript 3.0 Release Candidate — Project references allow TypeScript projects to depend on other TypeScript projects in a way that helps the build tools. Rest parameters can also be inferred as tuple types to make using them easier. There’s also a new unknown type to investigate.

Daniel Rosenwasser (Microsoft)

Proxymise: A Chainable Promise Proxy — An interesting proof of concept that takes you away from writing lots of then or await calls. Instead you could write something like value = await proxymise(foo).a().b().c;

Ilya Kozhevnikov

Phenomenon: A 2KB Low-Level WebGL Library — Provides the essentials to deliver high performance visuals easily. Several neat demos with code including throwing 10000 cubes around.

Colin van Eenige

💻 Jobs

Sr. Front-End Engineer, Creator Tools (New York City) — We empower video creators to tell exceptional stories and to connect with their audiences & communities. Build the future with us.

Vimeo

Find a Job Through Vettery — Vettery matches top tech talent with fast-growing companies. Create your profile to get started.

Vettery

📘 Tutorials and Opinions

React, Vue and Hyperapp Compared — Based around a simple counter example.

Angelos Chalaris

WTF Is 'this'? Understanding the 'this' Keyword, call, apply, and bind in JavaScript — There's also a video, if you prefer.

Tyler McGinnis

▶  Free Video Course: How to Upgrade Cordova Applications to NativeScript — Avoid poor app performance and unnatural UX. Free and open source cross-platform mobile framework.

NativeScript sponsor

The Extensive Guide to Creating Streams in RxJS

Oliver Flaggl

Managing Complex Waiting Experiences on Web UIs

Fatih Kadir Akın

Building an Audio Player App with Ionic, Angular, RxJS, and NgRx — Uses Auth0 for the authentication.

Prosper Otemuyiwa

What is JSX? — You may use it every day, but have you seen what happens after Babel transpiles JSX?

Kent C. Dodds

Angular SEO Done Right with Server-Side Rendering

Michael Poirier-Ginter

▶  An Introduction to TensorFlow.js in Your Browser — An official introduction to using TensorFlow.js for machine learning in the browser.

Laurence Moroney

🔧 Code and Tools

10 JavaScript Animation Libraries Worth Investigating in 2018 — With summaries and, importantly, live interactive JSFiddle demos for most.

Anton Shaleynikov

vue-wait: Loader and Progress Management for Vue and Nuxt Apps

Fatih Kadir Akın

Enjoy a Better Development Experience with Webstorm — Try smart code completion, refactorings, & integrated tools on your React, Angular & Vue projects.

JetBrains sponsor

simple-keyboard: A Customizable, Responsive On-Screen KeyboardLive demo here.

Francisco Hodge

Reclare: A Declarative State and Logic Management Library — Inspired by Redux and the Elm architecture.

Reclare

carbon-now-cli: Create Beautiful Images of Code From Your Terminal — It’s a terminal client for the awesome Carbon tool.

Miloš Sutanovac

Access DigitalOcean’s Quarterly Report on Developer Cloud Trends Now

DigitalOcean sponsor

9 CSS in JS Libraries You Should Know in 2018 — Including Styletron, Emotion and Styled Components.

Jonathan Saring

😄 Some Bonus “They're Not JS But You'll Like 'Em” Links

vim.wasm: The Vim Editor, Ported to WebAssembly — Great demo and very fast, too. Here's the code and an explanation of how it works.

Linda_pp

Kotlin on the Server at Khan Academy — Adding another language to a codebase is no small feat, but Khan Academy has found the performance gains of Kotlin, a JVM-based multiplatform language, are more than worth it. A popular item from this week's Web Operations Weekly.

Khan Academy Engineering

Web Architecture 101 — If terms like 'load balancer', 'caching', or CDN are gibberish to you, you might appreciate this simple explanation.

Jonathan Fulton

A 'div' That Looks Different In Each Major Browser — A neat demonstration of how specs don’t guarantee an identical result across browsers. Here’s the CodePen to try it for yourself.

Martijn Cuppens on Twitter


by via JavaScript Weekly

Lightbridge

Lovely subtle device parallax as you start scrolling this clean Landing Page for Lightbridge.

Full Review | Direct Link


by Rob Hope @robhope via One Page Love

Twitter's New Update Lets You Dock the Video As You Scroll Through The Timeline

As the life gets busier, multitasking seems like a norm and anything lesser makes you feel hampered and stuck. Finding an excellent solution, Twitter has introduced a new update that focuses on docking a video while you browse through your timeline. Watching a video does not mean that it’s the only...

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

by Mehwish Mehmood via Digital Information World

Set Up Routing in PHP Applications Using the Symfony Routing Component

Today, we'll go through the Symfony Routing component, which allows you to set up routing in your PHP applications.

What Is the Symfony Routing Component?

The Symfony Routing Component is a very popular routing component which is adapted by several frameworks and provides a lot of flexibility should you wish to set up routes in your PHP application.

If you've built a custom PHP application and are looking for a feature-rich routing library, the Symfony Routing Component is more than a worth a look. It also allows you to define routes for your application in the YAML format.

Starting with installation and configuration, we'll go through real-world examples to demonstrate a variety of options the component has for route configuration. In this article, you'll learn:

  • installation and configuration
  • how to set up basic routes
  • how to load routes from the YAML file
  • how to use the all-in-one router

Installation and Configuration

In this section, we're going to install the libraries that are required in order to set up routing in your PHP applications. I assume that you've installed Composer in your system as we'll need it to install the necessary libraries that are available on Packagist.

Once you've installed Composer, go ahead and install the core Routing component using the following command.

Although the Routing component itself is sufficient to provide comprehensive routing features in your application, we'll go ahead and install a few other components as well to make our life easier and enrich the existing core routing functionality.

To start with, we'll go ahead and install the HttpFoundation component, which provides an object-oriented wrapper for PHP global variables and response-related functions. It makes sure that you don't need to access global variables like $_GET, $_POST and the like directly.

Next, if you want to define your application routes in the YAML file instead of the PHP code, it's the YAML component that comes to the rescue as it helps you to convert YAML strings to PHP arrays and vice versa.

Finally, we'll install the Config component, which provides several utility classes to initialize and deal with configuration values defined in the different types of file like YAML, INI, XML, etc. In our case, we'll use it to load routes from the YAML file.

So that's the installation part, but how are you supposed to use it? In fact, it's just a matter of including the autoload.php file created by Composer in your application, as shown in the following snippet.

Set Up Basic Routes

In the previous section, we went through the installation of the necessary routing components. Now, you're ready to set up routing in your PHP application right away.

Let's go ahead and create the basic_routes.php file with the following contents.

Setting up routing using the Symfony Routing component usually goes through a series of steps as listed below.

  • Initialize the Route object for each of your application routes.
  • Add all Route objects to the RouteCollection object.
  • Initialize the RequestContext object which holds the current request context information.
  • Initialize the UrlMatcher object by passing the RouteCollection object and the RequestContext object.

Initialize the Route Object for Different Routes

Let's go ahead and define a pretty basic foo route.

The first argument of the Route constructor is the URI path, and the second argument is the array of custom attributes that you want to return when this particular route is matched. Typically, it would be a combination of the controller and method that you would like to call when this route is requested.

Next, let's have a look at the parameterized route.

The above route can match URIs like foo/1, foo/123 and similar. Please note that we've restricted the {id} parameter to numeric values only, and hence it won't match URIs like foo/bar since the {id} parameter is provided as a string.

Add All Route Objects to the RouteCollection Object

The next step is to add route objects that we've initialized in the previous section to the RouteCollection object.

As you can see, it's pretty straightforward as you just need to use the add method of the RouteCollection object to add route objects. The first argument of the add method is the name of the route, and the second argument is the route object itself.

Initialize the RequestContext Object

Next, we need to initialize the RequestContext object, which holds the current request context information. We'll need this object when we initialize the UrlMatcher object as we'll go through it in a moment.

Initialize the UrlMatcher Object

Finally, we need to initialize the UrlMatcher object along with routes and context information.

Now, we have everything we could match our routes against.

How to Match Routes

It's the match method of the UrlMatcher object which allows you to match any route against a set of predefined routes.

The match method takes the URI as its first argument and tries to match it against predefined routes. If the route is found, it returns custom attributes associated with that route. On the other hand, it throws the ResourceNotFoundException exception if there's no route associated with the current URI.

In our case, we've provided the current URI by fetching it from the $context object. So, if you're accessing the http://your-domain/basic_routes.php/foo URL, the $context->getPathInfo() returns foo, and we've already defined a route for the foo URI, so it should return us the following.

Now, let's go ahead and test the parameterized route by accessing the http://your-domain/basic_routes.php/foo/123 URL.

It worked if you can see that the id parameter is bound with the appropriate value 123.

Next, let's try to access a non-existent route like http://your-domain/basic_routes.php/unknown-route, and you should see the following message.

So that's how you can find routes using the match method.

Apart from this, you could also use the Routing component to generate links in your application. Provided RouteCollection and RequestContext objects, the UrlGenerator allows you to build links for specific routes.

The first argument of the generate method is the route name, and the second argument is the array that may contain parameters if it's the parameterized route. The above code should generate the /basic_routes.php/foo/123 URL.

Load Routes From the YAML File

In the previous section, we built our custom routes using the Route and RouteCollection objects. In fact, the Routing component offers different ways you could choose from to instantiate routes. You could choose from various loaders like YamlFileLoader, XmlFileLoader, and PhpFileLoader.

In this section, we'll go through the YamlFileLoader loader to see how to load routes from the YAML file.

The Routes YAML File

Go ahead and create the routes.yaml file with the following contents.

An Example File

Next, go ahead and make the load_routes_from_yaml.php file with the following contents.

The only thing that's different in this case is the way we initialize routes!

We've used the YamlFileLoader loader to load routes from the routes.yaml file instead of initializing it directly in the PHP itself. Apart from that, everything is the same and should produce the same results as that of the basic_routes.php file.

The All-in-One Router

Lastly in this section, we'll go through the Router class, which allows you to set up routing quickly with fewer lines of code.

Go ahead and make the all_in_one_router.php file with the following contents.

Everything is pretty much the same, except that we've instantiated the Router object along with the necessary dependencies.

With that in place, you can straight away use the match method of the Router object for route mapping.

Also, you will need to use the getRouteCollection method of the Router object to fetch routes.

Conclusion

Go ahead and explore the other options available in the Routing component—I would love to hear your thoughts!

Today, we explored the Symfony Routing component, which makes implementation of routing in PHP applications a breeze. Along the way, we created a handful of examples to demonstrate various aspects of the Routing component. 

I hope that you've enjoyed this article, and feel free to post your thoughts using the feed below!


by Sajal Soni via Envato Tuts+ Code

Dailychart.js : SVG Charting library

Dailychart.js is a tiny standalone SVG charting library to display daily graph of a stock market security.

The post Dailychart.js : SVG Charting library appeared first on Best jQuery.


by Admin via Best jQuery

Tobi : Simple Lightbox script without Dependencies

Tobi is a simple lightbox script without dependencies.

Features:

  • No dependencies
  • Simple and light-weight
  • Keyboard support: Prev/Next keys allows to navigate through items, close the lightbox with the escape key
  • Touch gestures: Drag/Swipe to navigate through items, close the lightbox with a vertical drag/swipe

The post Tobi : Simple Lightbox script without Dependencies appeared first on Best jQuery.


by Admin via Best jQuery

Gather emails before your big launch using a Squarespace “Launching Soon” template

Squarespace Logo

When we’re hard at work in the final stages of our new product or service launch, we overlook how effective a well-planned marketing campaign can be.

Word-of-mouth after launching is still worth it’s weight in gold and can be achieved with a beautiful pre-launch teaser followed by the reveal of a quality product or service.

In this tutorial I’m going to show you how to tease your upcoming product or service with a beautiful Squarespace Launching Soon page. This website will also gather email addresses for the final launch announcement sent using Squarespace Email Marketing Tools.

[pixel tag here]


One Page Love Exclusive Coupon

OPL10

Yay! Squarespace has been kind enough to give One Page Love readers the exclusive coupon OPL10 for 10% Off your first website or domain purchase. (There is a free 14-day trial with no credit card needed, so you can try risk free.)


FAQ: What are Squarespace Email Marketing Tools?

Squarespace has become an All-In-One platform for small businesses. Their newest feature allows anyone to gather email addresses within their website and then send marketing emails using the same Squarespace platform. Right now existing Squarespace customers can use Email Campaigns at no cost for a limited time during an invite-only early access period. General availability at a low monthly rate is coming soon but noteworthy highlights include:

  • A range of customizable templates to start designing emails
  • Import content from your website or blog straight into emails
  • Responsive layouts so emails look great on desktop or mobile
  • Compose and edit emails from your mobile if needed
  • Import email addresses using CSV files
  • Comprehensive click tracking and reporting

My favorite feature is definitely how the click tracking is part of a bigger analytics platform. We can track a click from an email button all the way to the purchase page, meaning we can see how much our Email Marketing Campaigns are converting into sales.

A preview of the Email Campaigns Interface

A preview of the Email Campaigns Interface


Tutorial: How to build a Launching Soon page with Squarespace

In this quick tutorial we are going to setup a Squarespace Cover Page to tease our product while encouraging a Newsletter Signup for the launch announcement:

Step One: Open up the Squarespace editor (if this is a new website setup, simply choose any template to begin).

Step Two: In the Main Navigation, click Pages, then click the + icon and select Cover Page:

Adding a Cover Page from the Squarespace Interface

Step Three: Choose a Cover Page layout you love, I’ve chose the minimal “Landing – Cover” layout to tease an ingredient for our demo Juice and Snack product:

A preview of the Squarespace Cover Pages Builder

Step Four: Add your branding, text and media.

Step Five: Open up Action area of the Cover Page:

Squarespace Cover Pages Action Area

Step Six: Select Submission Type as Newsletter Signup:

A preview of the Cover Pages - Actions Interface

Step Seven: Click the Edit Newsletter Signup button and connect the new list to your Google Drive or to your new Email Campaigns feature if your Squarespace account has access.

Step Eight: Style the page if needed.

Step Nine: To set the Cover Page as the first page visitors see at your domain, set it as your Home Page.

Now you should have a great looking teaser Launching Soon page to announce and start gathering emails leading up to the big launch day:

A preview of our beautiful Launching Soon website using a Squarespace Cover Page

FAQ: What are the benefits of using Squarespace?

Squarespace is a leading online website builder. What sets them apart from the rest is their superior level of design and customer support. They have a huge support team and are available 24/7. Other main benefits are:

  • No Website Hosting Needed - their platform is fast and secure
  • Online Content Management - all edits are done within your browser, no software needed
  • Easily Drag & Drop Images - unlimited galleries with unlimited bandwidth
  • Free Domain Name - when registering for your first website, if you pay annually (renews at standard rate)
  • Beautifully Responsive - all templates work for all devices, so you only have to design your website once. Test and preview how your website will appear on a range of screen sizes.
  • Blog Sections - can easily be added to start sharing your journey
  • eCommerce Solutions - are an upgrade away if you want to start selling products

That’s a wrap! Don’t forget your 10% Off coupon: OPL10

OPL10

I hope enjoyed this tutorial on how to create a stunning Launching Soon website integrated with the Email Marketing Campaigns functionality for your launch. Props to Squarespace for creating a platform where we can create beautiful announcement websites, easily. If you missed it I wrote a tutorial last month on the Top 5 Squarespace Photography Templates.


by Rob Hope @robhope via One Page Love