`
bluky999
  • 浏览: 715665 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论
阅读更多

 

Meteor 框架简介 

 

http://meteor.com/

 

构建应用的一种全新方式!

Meteor 是一个快速构建高质量WEB应用的新技术集,无论你是专业的开发人员还是初学者。

 


 

官方网站列出的9大特性:

 

Meteor 写道
001 Pure JavaScript. 传JS
002 Live page updates. 实时页面更新
003 Clean, powerful data synchronization. 干净、强大的数据同步
004 Latency compensation. 延迟补偿
005 Hot Code Pushes. 代码热推送
006 Sensitive code runs in a privileged environment. 敏感代码运行于受限环境中
007 Fully self-contained application bundles. 完全独立的应用包
008 Interoperability. 互操作
009 Smart Packages. 智能的包
 

 

 

官方提供的3个示例:

http://meteor.com/examples/leaderboard

http://meteor.com/examples/todos

http://meteor.com/examples/wordplay

 

GITHUB项目页:

http://github.com/meteor/meteor

 

Meteor@StackOverflow

http://stackoverflow.com/questions/tagged/meteor?sort=newest&pagesize=15

 

文档:

http://docs.meteor.com/

 

FAQ:

http://meteor.com/faq

 

目前版本:preview 0.3.3   作者团队何时计划发布1.0 呢? FAQ中说是“More than a month, less than a year”,这个与下文36kr文章的说法有点区别 :) 

 

 

 

首先,36kr上已经有 xinzhi 的一篇关于 meteor 介绍的文章了:

 

 

Web开发者看过来,Meteor开发框架为你带来下一代高品质实时Web App开发的新模式

xinzhi 发表于 2012-04-13 10:48

http://www.36kr.com/p/99503.html

 

测试: http://36kr.meteor.com

视频: http://v.youku.com/v_show/id_XMzgwMjc3Mzcy.html

 

 

然后,这里我主要记录下具体下载安装编码测试部署调试等实践性问题。

 

1 新手起步

在linux或mac os上 

 

安装Meteor:

$ curl install.meteor.com | /bin/sh

注:

- 如果你curl有问题,可以用浏览器打开 install.meteor.com 将页面的sh脚本另存到本地,然后 sh xxx.sh ;

- 如果你的linux内核和gcc、glibc等版本太低,可能会遇到安装错误,请升级或换一台较新的机器。

- meteor是在线安装,所以需要网络连接。 

 

创建项目:

$ meteor create myapp

 

本地运行:

$ cd myapp

$ meteor

Running on: http://localhost:3000/

 

部署到meteor提供的免费空间上,让所有人都可访问:

$ meteor deploy myapp.meteor.com

注:

- 默认不需要密码,如果你的myapp名字可用,则直接部署成功,否则返回失败,换一个名字。

- 使用 --password 为自己的项目设置密码 

 

 

2 尝试示例项目  

 

基于3个示例项目创建,比如;

$ meteor create --example todos myapp

 

然后本地运行测试效果,OK后,可以根据官方的文档说明,尝试自己修改;

简单项目结构是

 

.meteor

myapp.css

myapp.html

myapp.js

 

一般的项目结构是:

.meteor

client

 |__ myapp.css

  __ myapp.html

  __ myapp.js 

public

 |__ xxx.png

  __ ooo.jpg

  __ ...

 

server

 |__ bootstrap.js

  __ publish.js 

  __ ...

 

 

基本上很简洁直观,具体可参考example项目中的代码,看看每一部分都做了什么,todos示例非常经典。 

 

官方示例:

http://wordplay.meteor.com/ 
http://leaderboard.meteor.com/ 
http://todos.meteor.com/ 

 

3 meteor命令与其他

 

meteor help    帮助信息 

meteor run     运行当前项目 

meteor create  创建项目,使用 --example 从示例项目创建 

meteor deploy  部署当前项目,使用 --delete 选项删除已部署项目,使用 --debug 选项部署为调试模式 ,使用 --password 设置部署密码或修改已有密码 

meteor logs    查看参数指定的项目日志  

meteor update  更新Meteor 

meteor add     添加包到当前项目

meteor remove  移除当前项目中的包

meteor list    浏览所有包,使用 --using 查看已经添加到当前项目中的包

meteor mongo   打开本地mongodb的shell

meteor reset   重置本地Mongodb数据 

meteor bundle  打包应用以部署 

 

 

- 如果你部署时想用自己的域名,那么可以让自己的域名指向到 myapp.meteor.com ,只要修改你的域名A记录到 myapp.meteor.com 即可;

 

- 默认部署时你只是更新项目代码,而保留原有的mongodb数据。meteor reset只会对本地的monogdb数据清除,使用reset时要确保本地项目未运行。

 

 

4 包 

amplify

backbone

coffeescript

jquery

less

showdown

underscore

 

 

5 API 

 

Core

 

Meteor.is_client

Meteor.is_server

Meteor.startup

 

 

Publish and subscribe

 

Meteor.publish

    this.set

    this.unset

    this.complete

    this.flush

    this.onStop

    this.stop

Meteor.subscribe

Meteor.autosubscribe

 

 

Methods

 

Meteor.methods

    this.is_simulation

    this.unblock

Meteor.Error

Meteor.call

Meteor.apply

 

 

Server connections

 

Meteor.status

Meteor.reconnect

Meteor.connect

 

 

Collections

 

Meteor.Collection

    collection.find

    collection.findOne

    collection.insert

    collection.update

    collection.remove

 

Meteor.Collection.Cursor

    cursor.forEach

    cursor.map

    cursor.fetch

    cursor.count

    cursor.rewind

    cursor.observe

Selectors

Modifiers

Sort specifiers

 

 

Session

 

Session.set

Session.get

Session.equals

 

 

Meteor.ui

 

Meteor.ui.render

Meteor.ui.chunk

Meteor.ui.listChunk

Meteor.flush

Event maps

 

 

Timers

 

Meteor.setTimeout

Meteor.setInterval

Meteor.clearTimeout

Meteor.clearInterval

 

 

Meteor.deps

 

Meteor.deps.Context

context.run

context.on_invalidate

context.invalidate

Meteor.deps.Context.current

 

 

Meteor.http

 

Meteor.http.call

Meteor.http.get

Meteor.http.post

Meteor.http.put

Meteor.http.del

 

注:

- 模板部分跟其他模板差不多,只要给一个名字,然后绑定数据即可

- meteor API中有 pub/sub 功能,所以简单的聊天室可以借此实现。 

 

最后:

-  笔者也从 todos 开始创建了一个项目 http://gene.meteor.com 

-  中文社区: 目前有一个豆瓣小组  http://www.douban.com/group/meteorjs 

 

 

 

  • 大小: 396.3 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics