Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PyCon2012ChinaBj-UliWeb
Search
Zoom.Quiet
October 20, 2012
Programming
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PyCon2012ChinaBj-UliWeb
http://cn.pycon.org/2012/schedulebj
Zoom.Quiet
October 20, 2012
More Decks by Zoom.Quiet
See All by Zoom.Quiet
PyCon2014China-Zhuhai-high performance
zoomquiet
0
190
PyCon2014China-Zhuhai-meta programming
zoomquiet
1
170
PyCon2014China-Zhuhai-bpm.py
zoomquiet
0
150
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
140
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
140
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
160
PyCon2014China-Zhuhai-jeff
zoomquiet
0
140
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
170
DevFest2014-Zhuhai-Polymer
zoomquiet
0
480
Other Decks in Programming
See All in Programming
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
6.6k
3Dシーンの圧縮
fadis
1
770
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
260
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
630
さぁV100、メモリをお食べ・・・
nilpe
0
140
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
330
Inside Stream API
skrb
1
710
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.2k
AI時代のUIはどこへ行く?その2!
yusukebe
21
7.2k
技術記事、 専門家としてのプログラマ、 言語化
mizchi
13
5.9k
ふつうのFeature Flag実践入門
irof
7
3.9k
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.4k
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
Leo the Paperboy
mayatellez
7
1.8k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
140
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
250
Raft: Consensus for Rubyists
vanstee
141
7.5k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
200
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
200
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
870
Navigating Weather and Climate Data
rabernat
0
220
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Transcript
又一年,Uliweb发展纪事 李迎辉(
[email protected]
) 2012/10/20
Uliweb 转到github,同时在 code.google.com Uliweb-doc为专门的Uliweb文档项目 Plugs集成越来越多的组件,包括JQuery, Bootstrap, AngularJS等 Ver 0.1.6 Ver
0.1.4 在多个场合介绍Uliweb,如:《我们的开源项目》 UliwebZone项目,由何家胜部署在 http://uliweb.clkg.org 2012 cn.pycon.org 官网开发
UliwebZone的实战
Uliweb Plugs SQLAlchemy par - MarkDown解释器,加入bootstrap的语法支持 JQuery + 插件 AngularJS
论坛
论坛
教程
教程
教程
课程
课程
消息
管理
AngularJS
Javascript MVC框架 基于DOM的模板引擎 双向数据绑定 Dirty data check 模块化 控制器 Directive
HTML标签扩展 。。。
{{use "angularjs"}} {{use "jquery"}} <div ng-app="AdminApp" id="ng-app" ng-controller="adminCtrl"> <form class="form-inline">
<input ng-model="topictype_name" placeholder="新课程分类名称"></input> <a class=“btn btn-primary” ng-click=“add_category()“>添加</a> </form> <table class="table table-bordered table-header"> <tbody> <tr ng-repeat="c in objects"> <td>{% c.name %}</td> <td> <a ng-click="edit_category(c.id)"> <i class="icon-edit" title="编辑"></i> </a> <a ng-click="remove_category(c.id)"> <i class="icon-remove" title="删除"></i> </a> </td> </tr> </tbody> </table> </div> 装入相关的资源 Template
{{use "angularjs"}} {{use "jquery"}} <div ng-app="AdminApp" id="ng-app" ng-controller="adminCtrl"> <form class="form-inline">
<input ng-model="topictype_name" placeholder="新课程分类名称"></input> <a class="btn btn-primary" ng-click="add_category()“>添加</a> </form> <table class="table table-bordered table-header"> <tbody> <tr ng-repeat="c in objects"> <td>{% c.name %}</td> <td> <a ng-click="edit_category(c.id)"> <i class="icon-edit" title="编辑"></i> </a> <a ng-click="remove_category(c.id)"> <i class="icon-remove" title="删除"></i> </a> </td> </tr> </tbody> </table> </div> 设置App和Controller Template
{{use "angularjs"}} {{use "jquery"}} <div ng-app="AdminApp" id="ng-app" ng-controller="adminCtrl"> <form class="form-inline">
<input ng-model="topictype_name" placeholder="新课程分类名称"></input> <a class="btn btn-primary" ng-click="add_category()">添加</a> </form> <table class="table table-bordered table-header"> <tbody> <tr ng-repeat="c in objects|orderBy:Ordering"> <td>{% c.name %}</td> <td> <a ng-click="edit_category(c.id)"> <i class="icon-edit" title="编辑"></i> </a> <a ng-click="remove_category(c.id)"> <i class="icon-remove" title="删除"></i> </a> </td> </tr> </tbody> </table> </div> 绑定变量 Template
{{use "angularjs"}} {{use "jquery"}} <div ng-app="AdminApp" id="ng-app" ng-controller="adminCtrl"> <form class="form-inline">
<input ng-model="topictype_name" placeholder="新课程分类名称"></input> <a class="btn btn-primary" ng-click="add_category()“>添加</a> </form> <table class="table table-bordered table-header"> <tbody> <tr ng-repeat="c in objects|orderBy:Ordering"> <td>{% c.name %}</td> <td> <a ng-click="edit_category(c.id)"> <i class="icon-edit" title="编辑"></i> </a> <a ng-click="remove_category(c.id)"> <i class="icon-remove" title="删除"></i> </a> </td> </tr> </tbody> </table> </div> 绑定click事件 Template
{{use "angularjs"}} {{use "jquery"}} <div ng-app="AdminApp" id="ng-app" ng-controller="adminCtrl"> <form class="form-inline">
<input ng-model="topictype_name" placeholder="新课程分类名称"></input> <a class="btn btn-primary" ng-click="add_category()“>添加</a> </form> <table class="table table-bordered table-header"> <tbody> <tr ng-repeat="c in objects|orderBy:Ordering"> <td>{% c.name %}</td> <td> <a ng-click="edit_category(c.id)"> <i class="icon-edit" title="编辑"></i> </a> <a ng-click="remove_category(c.id)"> <i class="icon-remove" title="删除"></i> </a> </td> </tr> </tbody> </table> </div> 对objects进行循环 在DOM显示变量值(表达式) 绑定click事件进行编辑 绑定click事件进行删除 Template
var app = angular.module('AdminApp', []).config(function ($interpolateProvider) { $interpolateProvider.startSymbol('{%'); $interpolateProvider.endSymbol('%}'); });
function adminCtrl($scope) { $.get('/class/admin/category/query') .success(function(data, status, headers, config){ $scope.objects = data.rows; $scope.$apply(); }); $scope.ordering = „name‟; $scope.add_category = function(){ var v = $('#field_category').val(); if (!v){ show_message('课程分类名称不能为空', 'error'); }else{ $.post('/class/admin/category/add', {'name':v}) .success(function(data){ if (data.success) $scope.objects.push(data.data); else show_message(data.message, 'error'); $scope.$apply(); }); } } } 初始化angularjs标签 Template
var app = angular.module('AdminApp', []).config(function ($interpolateProvider) { $interpolateProvider.startSymbol('{%'); $interpolateProvider.endSymbol('%}'); });
function adminCtrl($scope) { $.get('/class/admin/category/query') .success(function(data, status, headers, config){ $scope.objects = data.rows; $scope.$apply(); }); $scope.ordering = „name‟; $scope.add_category = function(){ var v = $('#field_category').val(); if (!v){ show_message('课程分类名称不能为空', 'error'); }else{ $.post('/class/admin/category/add', {'name':v}) .success(function(data){ if (data.success) $scope.objects.push(data.data); else show_message(data.message, 'error'); $scope.$apply(); }); } } } 从后台装入数据(只会执行一次) Template
var app = angular.module('AdminApp', []).config(function ($interpolateProvider) { $interpolateProvider.startSymbol('{%'); $interpolateProvider.endSymbol('%}'); });
function adminCtrl($scope) { $.get('/class/admin/category/query') .success(function(data, status, headers, config){ $scope.objects = data.rows; $scope.$apply(); }); $scope.ordering = „name‟; $scope.add_category = function(){ var v = $('#field_category').val(); if (!v){ show_message('课程分类名称不能为空', 'error'); }else{ $.post('/class/admin/category/add', {'name':v}) .success(function(data){ if (data.success) $scope.objects.push(data.data); else show_message(data.message, 'error'); $scope.$apply(); }); } } } 设置排序字段 Template
var app = angular.module('AdminApp', []).config(function ($interpolateProvider) { $interpolateProvider.startSymbol('{%'); $interpolateProvider.endSymbol('%}'); });
function adminCtrl($scope) { $.get('/class/admin/category/query') .success(function(data, status, headers, config){ $scope.objects = data.rows; $scope.$apply(); }); $scope.ordering = „name‟; $scope.add_category = function(){ var v = $('#field_category').val(); if (!v){ show_message('课程分类名称不能为空', 'error'); }else{ $.post('/class/admin/category/add', {'name':v}) .success(function(data){ if (data.success) $scope.objects.push(data.data); else show_message(data.message, 'error'); $scope.$apply(); }); } } } 添加数据处理,界面自动刷新 Template
#coding=utf8 from uliweb import expose, functions from uliweb.orm import get_model
@expose('/class/admin/category') class ClassCategoryAdminView(object): def __init__(self): self.model = get_model('class_category') def __begin__(self): functions.require_login() if not functions.has_role(request.user, 'superuser'): error("你没有权限访问此页面") def query(self): view = functions.ListView(self.model, pagination=False) return json(view.json()) def add(self): view = functions.AddView(self.model, success_data=True) return view.run(json_result=True) View 导入常用函数
#coding=utf8 from uliweb import expose, functions from uliweb.orm import get_model
@expose('/class/admin/category') class ClassCategoryAdminView(object): def __init__(self): self.model = get_model('class_category') def __begin__(self): functions.require_login() if not functions.has_role(request.user, 'superuser'): error("你没有权限访问此页面") def query(self): view = functions.ListView(self.model, pagination=False) return json(view.json()) def add(self): view = functions.AddView(self.model, success_data=True) return view.run(json_result=True) View 设置Class的URL
#coding=utf8 from uliweb import expose, functions from uliweb.orm import get_model
@expose('/class/admin/category') class ClassCategoryAdminView(object): def __init__(self): self.model = get_model('class_category') def __begin__(self): functions.require_login() if not functions.has_role(request.user, 'superuser'): error("你没有权限访问此页面") def query(self): view = functions.ListView(self.model, pagination=False) return json(view.json()) def add(self): view = functions.AddView(self.model, success_data=True) return view.run(json_result=True) View 初始化
#coding=utf8 from uliweb import expose, functions from uliweb.orm import get_model
@expose('/class/admin/category') class ClassCategoryAdminView(object): def __init__(self): self.model = get_model('class_category') def __begin__(self): functions.require_login() if not functions.has_role(request.user, 'superuser'): error("你没有权限访问此页面") def query(self): view = functions.ListView(self.model, pagination=False) return json(view.json()) def add(self): view = functions.AddView(self.model, success_data=True) return view.run(json_result=True) View 执行Class方法 前的处理
#coding=utf8 from uliweb import expose, functions from uliweb.orm import get_model
@expose('/class/admin/category') class ClassCategoryAdminView(object): def __init__(self): self.model = get_model('class_category') def __begin__(self): functions.require_login() if not functions.has_role(request.user, 'superuser'): error("你没有权限访问此页面") def query(self): view = functions.ListView(self.model, pagination=False) return json(view.json()) def add(self): view = functions.AddView(self.model, success_data=True) return view.run(json_result=True) View 返回数据处理
#coding=utf8 from uliweb import expose, functions from uliweb.orm import get_model
@expose('/class/admin/category') class ClassCategoryAdminView(object): def __init__(self): self.model = get_model('class_category') def __begin__(self): functions.require_login() if not functions.has_role(request.user, 'superuser'): error("你没有权限访问此页面") def query(self): view = functions.ListView(self.model, pagination=False) return json(view.json()) def add(self): view = functions.AddView(self.model, success_data=True) return view.run(json_result=True) View 新增的处理
代码框架自动生成 处理常见的:List, Add, Edit, Delete, View 目前支持angularjs,html等以后还要支持其它模式
谢谢!明年再见!