├── src ├── sample.styl ├── _wrapper │ ├── css.styl │ ├── umd-no-deps.ejs │ └── umd.ejs └── sample.js ├── releases ├── 0.1.0.md └── 0.1.1.md ├── .npmignore ├── wiki └── home.md ├── .npmrc ├── .gitignore ├── .editorconfig ├── redir.html ├── test ├── test.js └── test.html ├── doc └── api.zh.md ├── bower.json ├── package.json ├── LICENSE.txt ├── gulpfile.js ├── README.md └── README.full.md /src/sample.styl: -------------------------------------------------------------------------------- 1 | sample() 2 | color red 3 | -------------------------------------------------------------------------------- /src/_wrapper/css.styl: -------------------------------------------------------------------------------- 1 | @import '../sample.styl' 2 | 3 | .sample 4 | sample() 5 | -------------------------------------------------------------------------------- /releases/0.1.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | tag: 0.1.0 3 | title: 0.1.0 4 | --- 5 | 6 | * First public release. 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | * 2 | 3 | !package.json 4 | !README.md 5 | !src/*.js 6 | !src/*.styl 7 | !dist/*.js 8 | !dist/*.css 9 | -------------------------------------------------------------------------------- /wiki/home.md: -------------------------------------------------------------------------------- 1 | * [API Documentation](https://github.com/cssmagic/sample/issues/1) (Zh) 2 | * JavaScript API 3 | * `sample.sample1()` 4 | * `sample.sample2()` 5 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | sass_binary_site=https://npm.taobao.org/mirrors/node-sass/ 2 | phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/ 3 | electron_mirror=https://npm.taobao.org/mirrors/electron/ 4 | 5 | ;registry=https://registry.npm.taobao.org 6 | 7 | package-lock=false 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Thumbs.db 2 | ehthumbs.db 3 | [Dd]esktop.ini 4 | $RECYCLE.BIN/ 5 | .DS_Store 6 | .klive 7 | .dropbox.cache 8 | 9 | *.tmp 10 | *.bak 11 | *.swp 12 | *.lnk 13 | 14 | .svn 15 | .idea 16 | 17 | node_modules/ 18 | bower_components/ 19 | npm-debug.log 20 | 21 | *.zip 22 | *.gz 23 | 24 | *.sh 25 | *.bat 26 | 27 | # Sample ignores this dir, but your project may need to include this. 28 | dist/ 29 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs 2 | # editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_style = tab 9 | end_of_line = lf 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | 13 | [{package,bower}.json] 14 | indent_style = space 15 | indent_size = 2 16 | 17 | [*.{html}] 18 | quote_type = double 19 | 20 | [*.md] 21 | # use `
` to insert a line break explicitly. 22 | ; trim_trailing_whitespace = false 23 | -------------------------------------------------------------------------------- /redir.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {Sample} Redirecting... 6 | 9 | 14 | 15 | 16 | 17 |

{Sample}

18 |

Redirecting...

19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/_wrapper/umd-no-deps.ejs: -------------------------------------------------------------------------------- 1 | !function (root, factory) { 2 | if (typeof define === 'function' && define.amd) { 3 | // AMD 4 | define([], factory) 5 | } else if (typeof exports === 'object') { 6 | // CommonJS 7 | module.exports = factory() 8 | } else { 9 | // Browser globals 10 | root.{sample} = factory() 11 | } 12 | }(this, function () { 13 | 14 | //////////////////// START: source code //////////////////// 15 | <%= contents %> 16 | //////////////////// END: source code //////////////////// 17 | 18 | return {sample} 19 | }) 20 | -------------------------------------------------------------------------------- /src/_wrapper/umd.ejs: -------------------------------------------------------------------------------- 1 | !function (root, factory) { 2 | if (typeof define === 'function' && define.amd) { 3 | // AMD 4 | define(['jquery', 'underscore'], factory) 5 | } else if (typeof exports === 'object') { 6 | // CommonJS 7 | module.exports = factory(require('jquery'), require('underscore')) 8 | } else { 9 | // Browser globals 10 | root.{sample} = factory(root.jQuery || root.Zepto || root.$, root._) 11 | } 12 | }(this, function ($, _) { 13 | 14 | //////////////////// START: source code //////////////////// 15 | <%= contents %> 16 | //////////////////// END: source code //////////////////// 17 | 18 | return {sample} 19 | }) 20 | -------------------------------------------------------------------------------- /src/sample.js: -------------------------------------------------------------------------------- 1 | /** 2 | * {Sample} - {Description of Sample}. 3 | * Released under the MIT license. 4 | * https://github.com/cssmagic/sample 5 | */ 6 | var sample = function (window) { 7 | 'use strict' 8 | 9 | // util 10 | function _util() { 11 | //... 12 | } 13 | 14 | // fn 15 | function sample1() { 16 | //... 17 | } 18 | function sample2() { 19 | //... 20 | } 21 | 22 | // api 23 | var exports = {} 24 | exports.sample1 = sample1 25 | exports.sample2 = sample2 26 | 27 | /** DEBUG_INFO_START **/ 28 | // only for unit test 29 | exports.__util = _util 30 | /** DEBUG_INFO_END **/ 31 | 32 | return exports 33 | 34 | }(window) 35 | -------------------------------------------------------------------------------- /releases/0.1.1.md: -------------------------------------------------------------------------------- 1 | --- 2 | tag: 0.1.1 3 | title: 0.1.1 4 | --- 5 | 6 | * [Changed] Update some API. (#??) 7 | * [New] Add some feature. (#??) 8 | * [New] Add dist file in UMD format. (#??) 9 | * [New] Now available on npm. 10 | * [Fixed] Fix some issue. (#??) 11 | * [Improved] Improve some feature. (#??) 12 | * [Improved] Upgrade `{sub-sample}` module to [v?.?.?](https://github.com/cssmagic/sample/releases/tag/0.1.0). 13 | 14 | *** 15 | 16 | > Action names in Angular-style commit message: 17 | > 18 | > * feat (feature) 19 | > * fix (bug fix) 20 | > * docs (documentation) 21 | > * style (formatting, missing semi colons, …) 22 | > * refactor 23 | > * test (when adding missing tests) 24 | > * chore (maintain) 25 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | void function () { 2 | 'use strict' 3 | 4 | // check env 5 | if (typeof window === 'undefined') { 6 | console.error('[Sample] Open test.html in browsers to run tests!') 7 | return 8 | } 9 | 10 | describe('Util', function () { 11 | describe('sample.__util()', function () { 12 | it('does basic functionality', function () { 13 | expect(true).to.be.true 14 | }) 15 | }) 16 | }) 17 | 18 | describe('APIs', function () { 19 | describe('sample.sample1()', function () { 20 | it('does basic functionality', function () { 21 | expect(true).to.be.true 22 | }) 23 | }) 24 | describe('sample.sample2()', function () { 25 | it('does basic functionality', function () { 26 | expect(true).to.be.true 27 | }) 28 | }) 29 | }) 30 | 31 | }() 32 | -------------------------------------------------------------------------------- /doc/api.zh.md: -------------------------------------------------------------------------------- 1 | # API 文档 2 | 3 | ## 导言   4 | 5 | 一段介绍文字。 6 | 7 | ## JavaScript 变量   8 | 9 | ### `sample.var1`   10 | 11 | 类型。接口用途。 12 | 13 | 14 | ## JavaScript 接口   15 | 16 | ### `sample.sample1()`   17 | 18 | 接口用途。 19 | 20 | #### 参数 21 | 22 | (无) 23 | 24 | #### 返回值 25 | 26 | (无) 27 | 28 | #### 示例 29 | 30 | ```js 31 | sample.sample1() 32 | ``` 33 | 34 | #### 注意事项 35 | 36 | * 此接口的注意事项。 37 | * 此接口的注意事项。 38 | * 此接口的注意事项。 39 | 40 | *** 41 | 42 | ### `sample.sample2(arg)`   43 | 44 | 接口用途。 45 | 46 | #### 参数 47 | 48 | * `arg` -- 类型。参数含义。 49 | 50 | #### 返回值 51 | 52 | 类型。返回值含义。 53 | 54 | #### 示例 55 | 56 | ```js 57 | sample.sample2(1) // => true 58 | ``` 59 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{sample}", 3 | "homepage": "https://github.com/cssmagic/{sample}", 4 | "authors": [ 5 | "cssmagic " 6 | ], 7 | "description": "{Description of Sample}", 8 | "main": "dist/{sample}.umd.js", 9 | "moduleType": [ 10 | "amd", 11 | "node", 12 | "globals" 13 | ], 14 | "keywords": [ 15 | "{keywords of sample}" 16 | ], 17 | "license": "MIT", 18 | "ignore": [ 19 | "**/.*", 20 | "**.sh", 21 | "package.json", 22 | "node_modules", 23 | "bower_components", 24 | "gulpfile.js", 25 | "test", 26 | "doc", 27 | "demo", 28 | "src/_wrapper/" 29 | ], 30 | "dependencies": { 31 | "underscore": "1.*", 32 | "zepto.js": "1.*", 33 | "jquery": "*" 34 | }, 35 | "devDependencies": { 36 | "mocha.css": "0.1.0", 37 | "mocha": "1.*", 38 | "chai": "1.*" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample", 3 | "version": "0.0.0", 4 | "homepage": "https://github.com/cssmagic/{sample}", 5 | "repository": "github:cssmagic/{sample}", 6 | "author": "cssmagic ", 7 | "description": "{Description of Sample}", 8 | "main": "dist/{sample}.umd.js", 9 | "keywords": [ 10 | "{keywords of sample}" 11 | ], 12 | "license": "MIT", 13 | "scripts": { 14 | "dist": "gulp", 15 | "clean": "gulp clean", 16 | "js": "gulp js", 17 | "css": "gulp css", 18 | "prepublish": "npm run dist", 19 | "test": "echo \"See README.md to run tests in browsers.\" && exit 1" 20 | }, 21 | "dependencies": { 22 | "underscore": "1.*", 23 | "zepto.js": "1.*", 24 | "jquery": "*" 25 | }, 26 | "devDependencies": { 27 | "gulp": "3.*", 28 | "del": "1.*", 29 | "gulp-stylus": "2.*", 30 | "gulp-concat": "2.*", 31 | "gulp-rename": "1.*", 32 | "gulp-wrap": "^0.11.0", 33 | "gulp-replace": "^0.5.3", 34 | "gulp-uglify": "1.*" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 cssmagic and other contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UT - {Sample} 6 | 7 | 8 | 9 | 10 | 11 |
12 |

UT - {Sample}

13 |

View on GitHub

14 |
15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | var path = require('path') 4 | var gulp = require('gulp') 5 | var del = require('del') 6 | var stylus = require('gulp-stylus') 7 | var concat = require('gulp-concat') 8 | var rename = require('gulp-rename') 9 | var wrap = require('gulp-wrap') 10 | var replace = require('gulp-replace') 11 | var uglify = require('gulp-uglify') 12 | 13 | var myPath = { 14 | src: './src/', 15 | dest: './dist/', 16 | } 17 | 18 | gulp.task('default', ['clean'], function () { 19 | gulp.start('js') 20 | gulp.start('css') 21 | }) 22 | 23 | gulp.task('clean', function (callback) { 24 | del(path.join(myPath.dest, '*.*'), callback) 25 | }) 26 | 27 | gulp.task('js', function() { 28 | return gulp.src(path.join(myPath.src, 'sample.js')) 29 | .pipe(wrap({src: path.join(myPath.src, '_wrapper/umd.ejs')})) 30 | .pipe(replace(/\{sample}/g, 'sample')) 31 | .pipe(replace(/\/\*\* DEBUG_INFO_START \*\*\//g, '/*')) 32 | .pipe(replace(/\/\*\* DEBUG_INFO_END \*\*\//g, '*/')) 33 | .pipe(rename('sample.umd.js')) 34 | .pipe(gulp.dest(myPath.dest)) 35 | .pipe(uglify({ 36 | preserveComments: 'some' 37 | })) 38 | .pipe(rename('sample.umd.min.js')) 39 | .pipe(gulp.dest(myPath.dest)) 40 | }) 41 | 42 | gulp.task('css', function() { 43 | return gulp.src(path.join(myPath.src, '_wrapper/css.styl')) 44 | .pipe(stylus({ 45 | linenos: false, 46 | compress: false, 47 | errors: true 48 | })) 49 | .pipe(rename('sample.css')) 50 | .pipe(gulp.dest(myPath.dest)) 51 | }) 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sample 2 | 3 | > File templates for front-end projects. 4 | 5 | ## 简介 6 | 7 | 每次在 GitHub 新建一个前端小项目,都要做一遍繁琐的、重复的 “文案工作”?那不如把常用文件汇总为一个项目模板吧,以后新建项目时直接复制出来填填改改就可以了。 8 | 9 | 现在可用以下源码文件模板: 10 | 11 | * `README.md` (稍复杂的项目可以选用 `README.full.md`) 12 | * `.gitignore` 13 | * `package.json` 14 | * `bower.json` 15 | * `.editorconfig` 16 | * `src/*.*` 17 | * `test/*.*` 18 | * `gulpfile.js` 19 | * `redir.html` (适用于 GitHub Pages 的重定向页面) 20 | 21 | 以及文档模板: 22 | 23 | * `doc/*.md` 24 | * `wiki/*.md` 25 | * `releases/*.md` 26 | 27 | ## 兼容性 28 | 29 | 依赖以下类库: 30 | 31 | * Underscore 32 | * jQuery 33 | 34 | 支持以下浏览器: 35 | 36 | * Chrome / Firefox / Safari 等现代浏览器 37 | * IE 6+ 38 | 39 | ## 安装 40 | 41 | 0. 通过 Bower 安装: 42 | 43 | ```sh 44 | $ bower install {sample} 45 | ``` 46 | 47 | 0. 在页面中加载 {Sample} 的脚本文件及必要的依赖: 48 | 49 | ```html 50 | 51 | 52 | 53 | 54 | ``` 55 | 56 | ## API 文档 57 | 58 | 所有文档入口在 [Wiki 页面](https://github.com/cssmagic/sample/wiki),快去看吧! 59 | 60 | ## 单元测试 61 | 62 | 0. 把本项目的代码 fork 并 clone 到本地。 63 | 0. 在本项目的根目录运行 `bower install`,安装必要的依赖。 64 | 0. 在浏览器中打开 `test/test.html` 即可运行单元测试。 65 | 66 | ## 谁在用? 67 | 68 | 以下网站采用 {Sample} 作为基础组件: 69 | 70 | * [某某网站](https://github.com/cssmagic/sample) 71 | 72 | *** 73 | 74 | ## License 75 | 76 | [MIT License](http://www.opensource.org/licenses/mit-license.php) 77 | -------------------------------------------------------------------------------- /README.full.md: -------------------------------------------------------------------------------- 1 | # Sample 2 | 3 | > File templates for front-end projects. 4 | 5 | ## 简介 6 | 7 | 每次在 GitHub 新建一个前端小项目,都要做一遍繁琐的、重复的 “文案工作”?那不如把常用文件汇总为一个项目模板吧,以后新建项目时直接复制出来填填改改就可以了。 8 | 9 | 现在可用以下源码文件模板: 10 | 11 | * `README.md` (稍复杂的项目可以选用 `README.full.md`) 12 | * `.gitignore` 13 | * `package.json` 14 | * `bower.json` 15 | * `.editorconfig` 16 | * `src/*.*` 17 | * `test/*.*` 18 | * `gulpfile.js` 19 | * `redir.html` (适用于 GitHub Pages 的重定向页面) 20 | 21 | 以及文档模板: 22 | 23 | * `doc/*.md` 24 | * `wiki/*.md` 25 | * `releases/*.md` 26 | 27 | ## 兼容性 28 | 29 | #### 浏览器支持 30 | 31 | * 支持以下移动平台的主流浏览器: 32 | * iOS 5+ 33 | * Android 2.3+ 34 | 35 | * 同样支持以下桌面浏览器: 36 | * Firefox (edge) 37 | * Chrome (edge) 38 | * Safari (edge) 39 | 40 | #### 外部依赖 41 | 42 | * Underscore 1.6+ 43 | * Zepto 1.1+ 44 | 45 | ## 安装 46 | 47 | 0. 通过 Bower 安装: 48 | 49 | ```sh 50 | $ bower install {sample} 51 | ``` 52 | 53 | 0. 在页面中加载 {Sample} 的样式文件、脚本文件及必要的依赖: 54 | 55 | ```html 56 | 57 | 58 | 59 | ... 60 | 61 | 62 | 63 | ... 64 | 65 | 66 | 67 | 68 | 69 | 70 | ``` 71 | 72 | ## API 文档 73 | 74 | * {Sample} 提供了简洁易用的 API,[详见此文档](https://github.com/cssmagic/sample/issues/1)。 75 | * 此外,建议阅读 [Wiki](https://github.com/cssmagic/sample/wiki) 来获取更多信息。 76 | 77 | ## 谁在用? 78 | 79 | 以下开源项目采用 {Sample} 作为基础组件: 80 | 81 | * [CMUI](https://github.com/CMUI/CMUI) 82 | 83 | 因此,本项目运行在以下网站: 84 | 85 | * [某某网站](https://github.com/cssmagic/sample) 86 | 87 | *** 88 | 89 | ## 参与开发 90 | 91 | #### 构建 92 | 93 | 0. 把本项目的代码 fork 并 clone 到本地。 94 | 0. 在项目根目录执行 `npm install`,安装必要的依赖。 95 | 0. 在项目根目录执行 `npm run dist`,运行构建脚本。 96 | 0. 构建生成的发布文件将保存到 `/dist` 目录下。 97 | 98 | #### 单元测试 99 | 100 | 0. 把本项目的代码 fork 并 clone 到本地。 101 | 0. 在项目根目录执行 `bower install`,安装必要的依赖。 102 | 0. 在浏览器中打开以下文件即可运行单元测试: 103 | * `test/test-dev.html` - 测试源码 104 | * `test/test-dist.html` - 测试发布文件 105 | 106 | 如果想在移动设备上运行单元测试,可尝试以下任一方法: 107 | 108 | * 在本地建立 Web 服务,以便移动设备通过局域网访问上述单元测试页面。 109 | * 把本项目的所有文件(及必要的依赖)发布至公网,以便移动设备访问上述单元测试页面。 110 | 111 | *** 112 | 113 | ## License 114 | 115 | [MIT License](http://www.opensource.org/licenses/mit-license.php) 116 | --------------------------------------------------------------------------------