Ubuntu HTML5

Anatomy of an Ubuntu HTML5 app

An Ubuntu HTML5 app does not differ much in terms of its structure when compared to a traditional HTML site. This means developers will feel at home developing apps for Ubuntu using their familiar tools and workflows.

The main differences lie in the runtime and the presentation layer, both of which are handled in a way that is nearly transparent and does not get in the way for app authors.

The runtime and rendering

HTML5 apps in Ubuntu run in a native app wrapper instead of in a browser. This wrapper essentially contains a QML WebView component based on the Webkit engine that loads the main HTML file and takes care of the rendering.

To provide a simple example to illustrate how it works, here’s the code that loads the HTML file for a basic HTML5 application:

1
2
3
4
5
WebView {
     id: webView
     anchors.fill: parent
     url: "html/index.html"
}

The WebView is contained within the same Ubuntu SDK MainView component that native apps use, which can take care of features such as orientation.

The content, logic and presentation

At this point, we can follow the standard design philosophy for separation of content and logic, applied to the web technologies.

  • Content: you can use semantic HTML to provide your conttent, with minimal markup to add Ubuntu theming support
  • Logic: use standard JavaScript files loaded from the HTML files
  • Presentation: for basic Ubuntu applications just minimal CSS is required, as the HTML theme takes care of the presentation. If your application has more theming or customization demands, you can use more CSS imported in the same way from HTML as in the web.

The Ubuntu HTML theme

While cross-platform development is a significant advantage of HTML5 apps, users expect the software to look and behave in a way that is consistent with each platform’s UX guidelines. And here’s where the Ubuntu HTML theme brings differentiation with minimal effort.

The Ubuntu HTML theme reproduces the look and feel and behaviour of the native Ubuntu SDK widgets with web technologies. In practical terms, this means a CSS3 theme customized for Ubuntu and an Ubuntu UI JavaScript framework to implement the logic. With them, the familiar widgets from the SDK can be reused in HTML5 app, providing a native look and feel without any extra effort.

An important part of using the Ubuntu HTML theme are the data-role attributes in the HTML code. They are used to effectively define the Ubuntu SDK widgets that we want to use in our UI. They will act as selectors for the Ubuntu HTML theme to provide the right style and the behaviour to each widget.

Note that the names for data-role try to match the names of existing widgets in the SDK: page, pagestack, dialog, etc. While already usable for writing apps, the Ubuntu HTML theme is still under development, so some of these still need to be defined as classes but might change in the future.

Get started with the Ubuntu SDK

Follow these easy steps to install the Ubuntu SDK:

  1. Open a terminal by pressing the Ctrl+Alt+T key combination
  2. Enter the following command, pressing Enter at the end of the line and following the prompts

For Ubuntu 12.04 LTSUbuntu 12.10 and Ubuntu 13.04 users:

sudo add-apt-repository ppa:ubuntu-sdk-team/ppa && sudo apt-get update && sudo apt-get install ubuntu-sdk

Alternatively, for those using a development release:

sudo apt-get install ubuntu-sdk

Congrats! Now you’re all set to start writing a phone app.

Design something beautiful

To enable you to design and build beatiful and usable apps for Ubuntu on the phone, we’ve also prepared a set of clear guides with everything you need to know about UX and visual design best practices.

The App Design Guides are a resource that keeps growing with new guides to make your apps stand out, so stay tuned for new content!

Show me the App Design Guides ›

### Ubuntu系统中设置或使用HTML5播放器 对于希望在Ubuntu上浏览网页并观看依赖于HTML5技术的在线视频(如访问B站),确保浏览器支持HTML5是非常重要的。如果遇到Firefox无法正常使用HTML5的情况,可以通过安装`ubuntu-restricted-extras`来解决这个问题[^1]。 #### 安装必要的多媒体插件和支持库 为了使HTML5功能正常工作,在终端执行如下命令: ```bash sudo apt-get update && sudo apt-get install ubuntu-restricted-extras -y ``` 这一步骤会安装一系列额外的字体、Flash插件以及解码器等资源,从而增强系统的媒体处理能力,包括改善HTML5的支持效果。 #### 浏览器内部配置调整 除了上述操作外,有时还需要进入Firefox浏览器内的特殊配置页面(`about:config`),搜索有关`media.webm.enabled`和`media.ogg.enabled`这样的选项,并将其设为`true`以激活对特定格式的支持。不过通常情况下,默认设置已经足够满足日常需求。 #### 替代方案——第三方播放器辅助 当内置浏览器仍存在兼容性问题时,考虑采用专门设计用于Linux平台的强大播放软件也是一种不错的选择。例如SMPlayer不仅能够作为本地文件查看工具,还提供了良好的网络流媒体体验,甚至允许用户自定义加载外部网站的内容进行播放[^2]。 另外还有像Flow 'N Play这样具有独特UI设计的应用程序可供尝试,它同样适用于播放本地及在线视频素材[^3]。 通过以上措施应该可以在很大程度上优化Ubuntu环境下HTML5内容的显示质量。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值