2018年4月17日:开源日报第40期

每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,欢迎关注开源日报。交流QQ群:202790710;电报群 https://t.me/OpeningSourceOrg


今日推荐开源项目:《 HTML控制框架Stimulus

推荐理由:Stimulus 是一款炫酷有趣的针对 HTML 的 JavaScript 框架。它可以让你的 HTML 更加闪耀。

如何使用Stimulus

  1. 安装 Stimulus,可以通过 webpack 将 stimulus 加入 bundle 中或直接在<script>标签中加载stimulus.umd.js:
  2. 若要尝试使用 stimulus,可以运行作者提供的 stimulus-starter。使用方法:
    1. 通过 git 加载 stimulus-starter:
      $ git clone https://github.com/stimulusjs/stimulus-starter.git
      
      $ cd stimulus-starter
      
      $ yarn install
      
      $ yarn start

      完成后就可以在本地编辑,在 http://localhost:9000/ 查看效果 。

    2. Glitch 上在线编辑,免去安装的过程。
  3. 使用范例:

在 html 文件中加入:

<div data-controller="hello">  
    <input data-target="hello.name" type="text">
    <button  data-action="click->hello#greet" >Greet</button>
</div>

编写控制器:

// src/controllers/hello_controller.js
import { Controller } from "stimulus"

export default class extends Controller {
  greet() {
    console.log(`Hello, ${this.name}!`)
  }

  get name() {
    return this.inputElement.value
  }
  
  get inputElement() {
    return this.targets.find("name")
  }
}

通过 data-controller 连接控制器 hello_controller。

通过 data-target="hello.name" 使得控制器可以通过 name 访问 <input> 的输入。

通过 data-action="click->hello#greet" 执行控制器中 greet 函数。

通过 this.targets.find() 可以获取匹配到的元素。

 

运行效果:

为何要用Stimulus

  1. 它通过增加一些效果,使网页看起来更加炫酷。它并不想接管整个前端,相反,它的设计是为了让 HTML 有足够多的行为。这其实是一个普遍的 JavaScript 的思想。
  2. 重要的是,此框架可以与作者的另一个“单页”应用JS客户端框架 Turbolinks 配合的很好。这实现了让web应用可以在移动端达到原生应用的体验。Stimulus是在SPA即单页面应用程序激增的现在应运而生的一个JS框架。
  3. Stimulus 计划将最佳模式汇集到一个适度的小型框架中,围绕三个主要概念:控制,目标,和动作属性。
  4. Stimulus 可以不断刷新页面,只要属性出现或者消失,就会进入页面它适用于DOM的任何更新,无论是整页加载,Turbolinks 页面更改还是Ajax请求。
  5. 上手真的很快,开发者只需要根据 Stimulus 手册花费五分钟就可以写一个控制器。

SPA(单页应用程序)

顾名思义,单页 web 应用就是只有一张 web 界面的应用,是加载单个 HTML 页面并在用户与应用程序交互时动态更新该页面的web应用程序。

优点:主要体现在速度上,它可以给用户更好的使用体验,让用户在 web APP 感受原生 APP 的速度和流畅。

它快的秘诀在于它同时减少了下载资源的大小(除去第一次加载模板后,后续全部使用 JSON API ),以及极大提高了解析资源的速度(通过 JSON 数据就能更新页面)。

使用Stimulus不得不知Turbolinks

Turbolinks 可以在不增加客户端JS框架的复杂性的情况下,获得单页应用程序的性能优势,使用HTML在服务器端呈现您的视图。当 Turbolinks 自动获取网页,不会招致全页面加载的成本。

关于作者

Javan Makhmail:供职于 Basecamp,专研于前端开发,网页制作。不仅是 Stimulus,他还有许多的开源项目制作。

个人主页: GitHub Twitter


今日推荐英文原文:《Linux is under your hood》作者:Steven J. Vaughan-Nichols

原文链接:https://www.zdnet.com/article/linux-is-under-your-hood/

推荐理由:事实上,BMW、雪佛来、本田、特思拉、梅赛德斯,你知道这些品牌的汽车有什么共同特点吗?即使你是一个资深开源爱好者你也不一定知道:它们的汽车都运行着 Linux 操作系统。

Linux is under your hood

Way back in 2004, Jonathan Schwartz, then Sun's chief operating officer, suggested that cars could become software platforms the same way feature phones were. He was right. But, it's Linux, not Java, which is making the most of "smart cars".

That's because Linux and open-source software are flexible enough to bring a complete software stack to any hardware, be it supercomputer, smartphone, or a car. There are other contenders, such as Blackberry's QNX and Microsoft IoT Connected Vehicles, but both have lost ground to Linux. Audi is moving to Linux-based Android and Microsoft lost is biggest car customer, Ford, years ago.

Today, as Dustin Kirkland, then Canonical product VP and now Google Cloud product manager, told me recently, "Ubuntu is in the Tesla and we support support auto manufacturers, but Tesla has gone on its own way. Tesla was so far ahead of the curve it doesn't surprise me that they did their own thing. But, Canonical expects most car manufacturers will work with Linux distributors to build operating systems that scale out for cars for the masses."

Much of that work is done via the Automotive Grade Linux (AGL). This Linux Foundation-based organization is a who's who of Linux-friendly car manufacturers. Its membership includes Ford, Honda, Mazda, Nissan, Mercedes, Suzuki, and the world's largest automobile company: Toyota.

"Automakers are becoming software companies, and just like in the tech industry, they are realizing that open source is the way forward," said Dan Cauchy, AGL's executive director, in a statement. Car companies know that while horsepower still sells, customers also want smart infotainment systems, automated safe drive features, and, eventually, self-driving cars.

I have two young grandsons. I seriously wonder if they'll learn to drive. Just like many people who no longer know how to drive a stick-shift, I can see people in the next 20 years never bothering with driving classes.

The AGL is helping this next generation of smart cars arrive with its infotainment source code and software development kit (SDK) AGL Unified Code Base (UCB) 4.0.

UCB, in turn, is based on Yocto 2.2, a set of tools for creating images for embedded Linux systems. AGL is expanding beyond infotainment to develop software profiles using the UCB for telematics, instrument cluster, and heads-up-display (HUD).

To support these new projects, AGL has formed a new Virtualization Expert Group (EG-VIRT) to identify a hypervisor and develop an AGL virtualization architecture that will speed up Linux car time-to-market, reduce costs, and increase security.

The ASL is also now working on car Speech Recognition and Vehicle-to-Cloud connectivity. Led by Amazon Alexa, Nuance and Voicebox, the Speech Expert Group will provide guidance for voice technologies including natural language, grammar development tools, on-board vs cloud based speech, and signal processing for noise reduction and echo cancellation.

Tesla, however, continues to go its own way. That said, under the hood, Tesla is moving forward. With the 8.1 update (17.24.30), Tesla upgraded its Linux kernel from the archaic 2.6.36 to 4.4.35.

The AGL isn't the only group working to integrate Linux and cars. The SmartDeviceLink (SDL) Consortium, which includes Ford, Toyota, Mazda, and Suzuki, is working on Linux-based open-source software for getting smartphones and cars to work together smoothly.

At the same time, Google has its own Linux for cars: Android Auto. Google is supporting this with the Open Automotive Alliance. Google is hoping to recapture the Open Handset Alliance magic, which led Android to smartphone dominance, in smart cars. This new alliance supporters include Acura, Audi, Cadillac, Ford, GMC, Honda, Hyundai, and many other car manufacturers.

And it's not just cars running on Linux. Lyft, the ride-sharing service, has been "running Ubuntu since day one across the board from server to desktop to cloud," said Kirkland. The company is also using Ubuntu in its autonomous vehicle team.

Kirkland added, "Top car equipment manufacturers, like Bosch and Continental Auto Parts, increasingly use Ubuntu IoT in their components." In addition, the GPS device company "TomTom uses Ubuntu on its back end."

Looking ahead, Kirkland can see a world where bitheads instead of gearheads will be modifying their car's software. But, "How much can you legally modify it? Gearheads have been molding for cars for years, but it still has to be street legal. I don't think we have the infrastructure for a shade-tree software engineer to pass inspection." Not yet anyway.

So, whether you're driving a car, riding in one, or working on its software, Linux is in your automotive future.


每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,欢迎关注开源日报。交流QQ群:202790710;电报群 https://t.me/OpeningSourceOrg

()
对 Windows 二进制兼容的开源操作系统 ReactOS 发布 0.4.8 版
第0届学生开源年会 SOSCON 将于6月在重庆大学举办
暂无评论
做你所想,开源工场

开源工场是一个校园风格的古典开源文化社区,通过开源协作形式来创造生产力和寓技术于乐趣的频分多址非盈利开源社区。主张享受开源审美和动手做开源。目前有全球流行开源项目榜中榜开源周报、开源日报、媛宝、猿帅、开源尚青、开源工寮等原创栏目及主办学生开源年会(sosconf)。了解我们加入我们

联系我们

重庆市沙坪坝区沙正街 174 号
重庆大学 A 校区主教学楼底楼

编程浪子
编程浪子
人不堪其忧,我不改其乐 base64 -d "d2VuQGJvb3RpbmdtYW4ub3Jn"
153
文章
35
评论
95
喜欢