From ed842e485ecdfac6f954fac79d5ceced85207e86 Mon Sep 17 00:00:00 2001 From: loongmxbt Date: Fri, 26 Feb 2016 10:42:07 +0800 Subject: [PATCH] init --- .meteor/.finished-upgraders | 12 +++ .meteor/.gitignore | 1 + .meteor/.id | 7 ++ .meteor/packages | 48 +++++++++ .meteor/platforms | 2 + .meteor/release | 1 + .meteor/versions | 123 ++++++++++++++++++++++++ README.md | 15 +++ client/router.js | 13 +++ client/views/home/home.html | 13 +++ client/views/layout/main_layout.html | 7 ++ client/views/layout/sidenav_layout.html | 4 + client/views/pages/default_page.html | 9 ++ client/views/pages/not_found.html | 9 ++ client/views/pages/simple_page.html | 6 ++ client/views/partials/footer.html | 8 ++ client/views/partials/header.html | 27 ++++++ client/views/partials/header.js | 5 + client/views/posts/post_item.html | 26 +++++ client/views/posts/post_item.js | 15 +++ client/views/posts/posts_list.html | 6 ++ client/views/posts/posts_list.js | 25 +++++ lib/collections/posts.js | 76 +++++++++++++++ lib/config.js | 21 ++++ lib/dictionary/site.js | 11 +++ lib/page/page.js | 19 ++++ lib/roles/user.js | 28 ++++++ lib/startup.js | 15 +++ server/publications/posts.js | 7 ++ server/seeds.js | 26 +++++ 30 files changed, 585 insertions(+) create mode 100644 .meteor/.finished-upgraders create mode 100644 .meteor/.gitignore create mode 100644 .meteor/.id create mode 100644 .meteor/packages create mode 100644 .meteor/platforms create mode 100644 .meteor/release create mode 100644 .meteor/versions create mode 100644 README.md create mode 100644 client/router.js create mode 100644 client/views/home/home.html create mode 100644 client/views/layout/main_layout.html create mode 100644 client/views/layout/sidenav_layout.html create mode 100644 client/views/pages/default_page.html create mode 100644 client/views/pages/not_found.html create mode 100644 client/views/pages/simple_page.html create mode 100644 client/views/partials/footer.html create mode 100644 client/views/partials/header.html create mode 100644 client/views/partials/header.js create mode 100644 client/views/posts/post_item.html create mode 100644 client/views/posts/post_item.js create mode 100644 client/views/posts/posts_list.html create mode 100644 client/views/posts/posts_list.js create mode 100644 lib/collections/posts.js create mode 100644 lib/config.js create mode 100644 lib/dictionary/site.js create mode 100644 lib/page/page.js create mode 100644 lib/roles/user.js create mode 100644 lib/startup.js create mode 100644 server/publications/posts.js create mode 100644 server/seeds.js diff --git a/.meteor/.finished-upgraders b/.meteor/.finished-upgraders new file mode 100644 index 0000000..61ee313 --- /dev/null +++ b/.meteor/.finished-upgraders @@ -0,0 +1,12 @@ +# This file contains information which helps Meteor properly upgrade your +# app when you run 'meteor update'. You should check it into version control +# with your project. + +notices-for-0.9.0 +notices-for-0.9.1 +0.9.4-platform-file +notices-for-facebook-graph-api-2 +1.2.0-standard-minifiers-package +1.2.0-meteor-platform-split +1.2.0-cordova-changes +1.2.0-breaking-changes diff --git a/.meteor/.gitignore b/.meteor/.gitignore new file mode 100644 index 0000000..4083037 --- /dev/null +++ b/.meteor/.gitignore @@ -0,0 +1 @@ +local diff --git a/.meteor/.id b/.meteor/.id new file mode 100644 index 0000000..b4392ea --- /dev/null +++ b/.meteor/.id @@ -0,0 +1,7 @@ +# This file contains a token that is unique to your project. +# Check it into your repository along with the rest of this directory. +# It can be used for purposes such as: +# - ensuring you don't accidentally deploy one app on top of another +# - providing package authors with aggregated statistics + +1b92aag1u3iypp1fox5d diff --git a/.meteor/packages b/.meteor/packages new file mode 100644 index 0000000..824ae16 --- /dev/null +++ b/.meteor/packages @@ -0,0 +1,48 @@ +# Meteor packages used by this project, one per line. +# Check this file (and the other files in this directory) into your repository. +# +# 'meteor add' and 'meteor remove' will edit this file for you, +# but you can also edit it by hand. + +meteor-base # Packages every Meteor app needs to have +mobile-experience # Packages for a great mobile UX +mongo # The database Meteor supports right now +blaze-html-templates # Compile .html files into Meteor Blaze views +session # Client-side reactive dictionary for your app +jquery # Helpful client-side library +tracker # Meteor's client-side reactive programming library + +standard-minifiers # JS/CSS minifiers run for production mode +es5-shim # ECMAScript 5 compatibility for older browsers. +ecmascript # Enable ECMAScript2015+ syntax in app code + +## Orion +orionjs:core +orionjs:pages + +## Styles +twbs:bootstrap +fortawesome:fontawesome +orionjs:bootstrap + +## Router +kadira:flow-router +kadira:blaze-layout + +## Files +orionjs:filesystem +vsivsi:orion-file-collection +orionjs:file-attribute +orionjs:image-attribute + +## Editor +orionjs:summernote + +## i18n +loongmxbt:orion-lang-zh-cn + +## Test +msavin:mongol + +## Export +nicolaslopezj:orion-exporter diff --git a/.meteor/platforms b/.meteor/platforms new file mode 100644 index 0000000..efeba1b --- /dev/null +++ b/.meteor/platforms @@ -0,0 +1,2 @@ +server +browser diff --git a/.meteor/release b/.meteor/release new file mode 100644 index 0000000..3a05e0a --- /dev/null +++ b/.meteor/release @@ -0,0 +1 @@ +METEOR@1.2.1 diff --git a/.meteor/versions b/.meteor/versions new file mode 100644 index 0000000..5a01365 --- /dev/null +++ b/.meteor/versions @@ -0,0 +1,123 @@ +accounts-base@1.2.2 +accounts-password@1.1.4 +aldeed:autoform@5.7.1 +aldeed:collection2@2.5.0 +aldeed:simple-schema@1.4.0 +aldeed:tabular@1.4.2 +anti:i18n@0.4.3 +autoupdate@1.2.4 +babel-compiler@5.8.24_1 +babel-runtime@0.1.4 +base64@1.0.4 +binary-heap@1.0.4 +blaze@2.1.3 +blaze-html-templates@1.0.1 +blaze-tools@1.0.4 +boilerplate-generator@1.0.4 +caching-compiler@1.0.0 +caching-html-compiler@1.0.2 +callback-hook@1.0.4 +check@1.1.0 +coffeescript@1.0.11 +cosmos:browserify@0.9.2 +dburles:collection-helpers@1.0.4 +dburles:mongo-collection-instances@0.3.4 +ddp@1.2.2 +ddp-client@1.2.1 +ddp-common@1.2.2 +ddp-rate-limiter@1.0.0 +ddp-server@1.2.2 +deps@1.0.9 +diff-sequence@1.0.1 +ecmascript@0.1.6 +ecmascript-runtime@0.2.6 +ejson@1.0.7 +email@1.0.8 +es5-shim@4.1.14 +fastclick@1.0.7 +fortawesome:fontawesome@4.5.0 +geojson-utils@1.0.4 +hot-code-push@1.0.0 +html-tools@1.0.5 +htmljs@1.0.5 +http@1.1.1 +id-map@1.0.4 +jquery@1.11.4 +kadira:blaze-layout@2.3.0 +kadira:flow-router@2.10.0 +lai:collection-extensions@0.1.4 +launch-screen@1.0.4 +less@2.5.1 +livedata@1.0.15 +localstorage@1.0.5 +logging@1.0.8 +loongmxbt:orion-lang-zh-cn@1.3.0 +matb33:collection-hooks@0.8.1 +mdg:validation-error@0.1.0 +meteor@1.1.10 +meteor-base@1.0.1 +meteor-platform@1.2.3 +meteorhacks:inject-initial@1.0.3 +meteorhacks:picker@1.0.3 +meteortoys:toykit@2.2.1 +minifiers@1.1.7 +minimongo@1.0.10 +mobile-experience@1.0.1 +mobile-status-bar@1.0.6 +momentjs:moment@2.10.6 +mongo@1.1.3 +mongo-id@1.0.1 +msavin:mongol@1.6.2 +nicolaslopezj:options@1.0.1 +nicolaslopezj:orion-exporter@1.3.1 +nicolaslopezj:reactive-templates@1.2.1 +nicolaslopezj:roles@2.0.4 +nicolaslopezj:router-layer@0.0.11 +npm-bcrypt@0.7.8_2 +npm-mongo@1.4.39_1 +observe-sequence@1.0.7 +ordered-dict@1.0.4 +orionjs:accounts@1.7.0 +orionjs:attributes@1.7.0 +orionjs:base@1.7.0 +orionjs:bootstrap@1.7.0 +orionjs:collections@1.7.0 +orionjs:config@1.7.0 +orionjs:core@1.7.0 +orionjs:dictionary@1.7.0 +orionjs:file-attribute@1.7.0 +orionjs:filesystem@1.7.0 +orionjs:image-attribute@1.7.0 +orionjs:lang-en@1.7.0 +orionjs:pages@1.7.0 +orionjs:summernote@1.7.0 +promise@0.5.1 +random@1.0.5 +rate-limit@1.0.0 +reactive-dict@1.1.3 +reactive-var@1.0.6 +reload@1.1.4 +retry@1.0.4 +routepolicy@1.0.6 +service-configuration@1.0.5 +session@1.1.1 +sha@1.0.4 +softwarerero:accounts-t9n@1.1.6 +spacebars@1.0.7 +spacebars-compiler@1.0.7 +srp@1.0.4 +standard-minifiers@1.0.2 +summernote:standalone@0.6.16 +templating@1.1.5 +templating-tools@1.0.0 +tracker@1.0.9 +twbs:bootstrap@3.3.6 +ui@1.0.8 +underscore@1.0.4 +url@1.0.5 +useraccounts:bootstrap@1.12.4 +useraccounts:core@1.12.4 +vsivsi:file-collection@1.2.2 +vsivsi:orion-file-collection@0.2.2 +webapp@1.2.3 +webapp-hashing@1.0.5 diff --git a/README.md b/README.md new file mode 100644 index 0000000..45176af --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Orion Kickstarter + +## seeds.js +创建默认用户,其中管理员用户密码为 +admin@admin.com +admin123 + +## posts功能 +添加修改删除post,并赋予相应权限 + +## i18n中文 +orion自带翻译 + +## TODO +页面模板 \ No newline at end of file diff --git a/client/router.js b/client/router.js new file mode 100644 index 0000000..1174851 --- /dev/null +++ b/client/router.js @@ -0,0 +1,13 @@ +FlowRouter.route('/', { + name: "home", + action: function() { + BlazeLayout.render("mainLayout", {content: "home"}); + } +}); + +FlowRouter.route('/posts/:postId', { + name: "postItem", + action: function() { + BlazeLayout.render("mainLayout", {content: "postItem"}); + } +}); \ No newline at end of file diff --git a/client/views/home/home.html b/client/views/home/home.html new file mode 100644 index 0000000..bb6c989 --- /dev/null +++ b/client/views/home/home.html @@ -0,0 +1,13 @@ + diff --git a/client/views/layout/main_layout.html b/client/views/layout/main_layout.html new file mode 100644 index 0000000..aa2260f --- /dev/null +++ b/client/views/layout/main_layout.html @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/client/views/layout/sidenav_layout.html b/client/views/layout/sidenav_layout.html new file mode 100644 index 0000000..38a12c9 --- /dev/null +++ b/client/views/layout/sidenav_layout.html @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/client/views/pages/default_page.html b/client/views/pages/default_page.html new file mode 100644 index 0000000..c756e3c --- /dev/null +++ b/client/views/pages/default_page.html @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/client/views/pages/not_found.html b/client/views/pages/not_found.html new file mode 100644 index 0000000..27a2b5f --- /dev/null +++ b/client/views/pages/not_found.html @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/client/views/pages/simple_page.html b/client/views/pages/simple_page.html new file mode 100644 index 0000000..b1192c0 --- /dev/null +++ b/client/views/pages/simple_page.html @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/client/views/partials/footer.html b/client/views/partials/footer.html new file mode 100644 index 0000000..62e6c4e --- /dev/null +++ b/client/views/partials/footer.html @@ -0,0 +1,8 @@ + diff --git a/client/views/partials/header.html b/client/views/partials/header.html new file mode 100644 index 0000000..8203c7a --- /dev/null +++ b/client/views/partials/header.html @@ -0,0 +1,27 @@ + diff --git a/client/views/partials/header.js b/client/views/partials/header.js new file mode 100644 index 0000000..ec0898b --- /dev/null +++ b/client/views/partials/header.js @@ -0,0 +1,5 @@ +Template.header.helpers({ + app_name: function() { + return orion.config.get('APP_NAME'); + } +}) \ No newline at end of file diff --git a/client/views/posts/post_item.html b/client/views/posts/post_item.html new file mode 100644 index 0000000..cb6b6db --- /dev/null +++ b/client/views/posts/post_item.html @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/client/views/posts/post_item.js b/client/views/posts/post_item.js new file mode 100644 index 0000000..fa614d0 --- /dev/null +++ b/client/views/posts/post_item.js @@ -0,0 +1,15 @@ +Template.postItem.onCreated(function() { + var self = this; + var postId = FlowRouter.getParam('postId'); + self.autorun(function() { + self.subscribe('postById', postId); + }); +}); + +Template.postItem.helpers({ + post: function() { + var postId = FlowRouter.getParam('postId'); + var post = Posts.findOne({_id: postId}) || {}; + return post; + } +}); \ No newline at end of file diff --git a/client/views/posts/posts_list.html b/client/views/posts/posts_list.html new file mode 100644 index 0000000..0de8fc0 --- /dev/null +++ b/client/views/posts/posts_list.html @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/client/views/posts/posts_list.js b/client/views/posts/posts_list.js new file mode 100644 index 0000000..ebb6c20 --- /dev/null +++ b/client/views/posts/posts_list.js @@ -0,0 +1,25 @@ +Template.postsList.onCreated(function() { + var self = this; + self.autorun(function() { + self.subscribe('postsList'); + }); +}); + +Template.postsList.helpers({ + posts: function() { + return Posts.find({}, {sort: {created: -1}}); + }, + + pathForPost: function() { + var post = this; + var params = { + postId: post._id + }; + var queryParams = {}; + var routeName = "postItem"; + var path = FlowRouter.path(routeName, params, queryParams); + + return path; + } + +}); \ No newline at end of file diff --git a/lib/collections/posts.js b/lib/collections/posts.js new file mode 100644 index 0000000..91db787 --- /dev/null +++ b/lib/collections/posts.js @@ -0,0 +1,76 @@ +Posts = new orion.collection('posts', { + singularName: 'post', // The name of one of these items + pluralName: 'posts', // The name of more than one of these items + title: '管理文章', // The title in the index of the collection + link: { + /** + * The text that you want to show in the sidebar. + * The default value is the name of the collection, so + * in this case it is not necessary. + */ + title: '文章' + }, + /** + * Tabular settings for this collection + */ + tabular: { + columns: [ + { data: "title", title: "Title" }, + { data: "category", title: "Category"}, + /** + * If you want to show a custom orion attribute in + * the index table you must call this function + * orion.attributeColumn(attributeType, key, label) + */ + orion.attributeColumn('summernote', 'body', 'Content'), + orion.attributeColumn('createdBy', 'createdBy', 'Created By') + ] + } +}); + +Posts.attachSchema(new SimpleSchema({ + title: { + label: 'Title for a post', + type: String + }, + /** + * The file attribute is a custom orion attribute + * This is where orion does its magic. Just set + * the attribute type and it will automatically + * create the form for the file. + * WARNING: the url of the image will not be saved in + * .image, it will be saved in .image.url. + */ + image: orion.attribute('file', { + label: 'Image', + optional: true + }), + + category: { + label: 'Post Category', + type: String, + autoform: { + type: "select-radio-inline", + options: function () { + return [ + {label: "News", value: "News"}, + {label: "Blog", value: "Blog"}, + {label: "Draft", value: 'Draft'} + ]; + } + } + }, + + /** + * Here it's the same with an image attribute. + * summernote is an html editor. + */ + body: orion.attribute('summernote', { + label: 'Body' + }), + /** + * This attribute sets the user id to that of the user that created + * this post automatically. + */ + createdBy: orion.attribute('createdBy') +})); \ No newline at end of file diff --git a/lib/config.js b/lib/config.js new file mode 100644 index 0000000..bc7ef67 --- /dev/null +++ b/lib/config.js @@ -0,0 +1,21 @@ +// Orion options + +Options.set('forbidClientAccountCreation', false); + +Options.set('defaultRoles', ['user']); + +Options.set('showExportTab', true); + + + +// Orion Config +orion.config.add('AWS_API_KEY', 'aws'); +orion.config.add('AWS_API_SECRET', 'aws', { secret: true }); +orion.config.add('AWS_S3_BUCKET', 'aws'); + +orion.config.add('APP_NAME', 'app', {public: true}); +orion.config.add('APP_LANG', 'app'); + +// Templates +ReactiveTemplates.set('pages.notFound', 'notFound'); + diff --git a/lib/dictionary/site.js b/lib/dictionary/site.js new file mode 100644 index 0000000..b79f590 --- /dev/null +++ b/lib/dictionary/site.js @@ -0,0 +1,11 @@ +orion.dictionary.addDefinition('name', 'site', { + type: String, + label: 'Site Name', + defaultValue: 'Orion Blog' +}); + +orion.dictionary.addDefinition('desc', 'site', { + type: String, + label: 'Site Description', + defaultValue: 'Welcome to Orion CMS' +}); \ No newline at end of file diff --git a/lib/page/page.js b/lib/page/page.js new file mode 100644 index 0000000..9929a9b --- /dev/null +++ b/lib/page/page.js @@ -0,0 +1,19 @@ +orion.pages.addTemplate({ + template: 'pagesSimple', + name: 'Simple', + description: 'Simple template' +}, { + content: orion.attribute('summernote', { + label: 'Content' + }) +}) + +orion.pages.addTemplate({ + template: 'pagesDefault', + name: 'Default', + description: 'Default template' +}, { + content: orion.attribute('summernote', { + label: 'Content' + }) +}) \ No newline at end of file diff --git a/lib/roles/user.js b/lib/roles/user.js new file mode 100644 index 0000000..69fcc85 --- /dev/null +++ b/lib/roles/user.js @@ -0,0 +1,28 @@ +UserRole = new Roles.Role('user'); + +// index +UserRole.allow('collections.posts.index', true); +UserRole.helper('collections.posts.indexFilter', function() { + return { createdBy: this.userId }; +}); + + +// create +UserRole.allow('collections.posts.showCreate', true); +UserRole.allow('collections.posts.insert', true); + + +// edit +UserRole.allow('collections.posts.showUpdate', true); +UserRole.allow('collections.posts.update', function(userId, doc, fields, modifier) { + return doc.createdBy === userId; +}); + +// delete +UserRole.allow('collections.posts.showRemove', function(doc) { + return doc.createdBy == this.userId; +}); + +UserRole.allow('collections.posts.remove', function(userId, doc) { + return doc.createdBy === userId; +}); diff --git a/lib/startup.js b/lib/startup.js new file mode 100644 index 0000000..9b087ea --- /dev/null +++ b/lib/startup.js @@ -0,0 +1,15 @@ +if (Meteor.isClient) { + + // Set language zh-CN, zh_cn + setLanguage = function() { + var i18nLang = window.navigator.userLanguage || window.navigator.language; + i18n.setLanguage(i18nLang); + t9nLang = i18nLang.replace('-','_').toLowerCase(); + T9n.setLanguage(t9nLang); + } + + Meteor.startup(function() { + setLanguage(); + }) + +} \ No newline at end of file diff --git a/server/publications/posts.js b/server/publications/posts.js new file mode 100644 index 0000000..def821b --- /dev/null +++ b/server/publications/posts.js @@ -0,0 +1,7 @@ +Meteor.publish('postsList', function() { + return Posts.find({}, {field: {body: 0}}); +}) + +Meteor.publish('postById', function(postId) { + return Posts.find(postId); +}) \ No newline at end of file diff --git a/server/seeds.js b/server/seeds.js new file mode 100644 index 0000000..a6fbd36 --- /dev/null +++ b/server/seeds.js @@ -0,0 +1,26 @@ +if (Meteor.users.find().count() === 0) { + Accounts.createUser({ + username: "admin", + email: "admin@admin.com", + password: "admin123", + profile: { + name: "Admin" + } + }); + Accounts.createUser({ + username: "dragonszy", + email: "dragonszy@163.com", + password: "123456", + profile: { + name: "dragonszy" + } + }); + Accounts.createUser({ + username: "test", + email: "test@test.com", + password: "test123", + profile: { + name: "test" + } + }); +}; \ No newline at end of file