Skip to content

Commit 948e88e

Browse files
committed
prepare to gulp screencast, added dev qa stub
1 parent 0a26a7b commit 948e88e

16 files changed

Lines changed: 205 additions & 6 deletions

File tree

handlers/qa/client/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require('./styles');
2+
3+
var Spinner = require('client/spinner');
4+
var xhr = require('client/xhr');
5+
6+
var prism = require('client/prism');
7+
var notification = require('client/notification');
8+
9+
function init() {
10+
alert("Welcome to Q&A");
11+
prism.init();
12+
}
13+
14+
15+
init();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
@require "~styles/blocks/variables/variables"
3+
4+
.qa
5+
color red

handlers/qa/controllers/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
exports.get = function*() {
3+
4+
this.body = this.render('index');
5+
};

handlers/qa/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
var mountHandlerMiddleware = require('lib/mountHandlerMiddleware');
3+
4+
exports.init = function(app) {
5+
app.use( mountHandlerMiddleware('/qa', __dirname) );
6+
};

handlers/qa/models/qaQuestion.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const mongoose = require('mongoose');
2+
const Schema = mongoose.Schema;
3+
const config = require('config');
4+
const path = require('path');
5+
const assert = require('assert');
6+
const _ = require('lodash');
7+
const mongooseTimestamp = require('lib/mongooseTimestamp');
8+
9+
const schema = new Schema({
10+
title: {
11+
type: String,
12+
required: true,
13+
trim: true
14+
},
15+
content: {
16+
type: String,
17+
required: true,
18+
trim: true
19+
},
20+
// how to count views?
21+
// we need no google/yandex/etc bots
22+
viewsCount: {
23+
type: Number,
24+
required: true
25+
},
26+
slug: {
27+
type: String,
28+
required: true,
29+
index: true
30+
},
31+
user: {
32+
type: Schema.ObjectId,
33+
ref: 'User'
34+
},
35+
created: {
36+
type: Date,
37+
required: true,
38+
default: Date.now
39+
},
40+
tags: [{
41+
type: Schema.ObjectId,
42+
ref: 'QaTag'
43+
}]
44+
});
45+
46+
schema.plugin(mongooseTimestamp);
47+
48+
49+
module.exports = mongoose.model('QaQuestion', schema);

handlers/qa/models/qaTag.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const mongoose = require('mongoose');
2+
const Schema = mongoose.Schema;
3+
const config = require('config');
4+
const path = require('path');
5+
const assert = require('assert');
6+
const _ = require('lodash');
7+
const mongooseTimestamp = require('lib/mongooseTimestamp');
8+
9+
const schema = new Schema({
10+
title: {
11+
type: String,
12+
required: true,
13+
trim: true
14+
},
15+
created: {
16+
type: Date,
17+
required: true,
18+
default: Date.now
19+
}
20+
});
21+
22+
schema.plugin(mongooseTimestamp);
23+
24+
25+
module.exports = mongoose.model('QaTag', schema);

handlers/qa/router.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var Router = require('koa-router');
2+
3+
var index = require('./controllers/index');
4+
5+
var router = module.exports = new Router();
6+
7+
router.get("/", index.get);
8+

handlers/qa/templates/index.jade

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
extends /layouts/main
2+
3+
block append head
4+
!=css("qa")
5+
!=js("qa", {defer: true})
6+
7+
block append variables
8+
- var sitetoolbar = true
9+
- var layout_main_class = "main_width-limit"
10+
- var layout_header_class = "main__header_center"
11+
12+
block content
13+
p Вопрос-ответ
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
extends /layouts/main
2+
3+
block append variables
4+
- var headTitle = 'Скринкаст по Gulp [в процессе]';
5+
- var sitetoolbar = true
6+
- var header = true
7+
- var layout_page_class = "page_contains_header"
8+
- var mainclass = "main-headered"
9+
10+
block append head
11+
script window.SCREENCAST_SLUG='#{slug}';
12+
!=js("screencast", {defer: true})
13+
14+
block content
15+
+b.screencast-header._style_nodejs
16+
17+
+e("h1").title Скринкаст
18+
//- two spaces! one is consumed, one remains
19+
+e("strong").title-accent Gulp
20+
21+
+e("p").description
22+
| Детальный скринкаст про gulp и рецепты его использования.
23+
24+
+b.share-icons
25+
+e('span').title= t('site.share')
26+
include /blocks/social-icons
27+
28+
+e("p").foot Ниже вы можете ознакомиться более детально с содержанием скринкаста
29+
30+
.main(class='main_width-limit-wide').screencast-content
31+
32+
include:markit gulp.md
33+
34+
include /blocks/subscriptionsForm
35+
36+
include /blocks/comments
37+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Gulp -- замечательная система сборки и задач, но при всём обилии информации в интернете о ней -- не хватает подробного и детального рассказа об основах.
3+
4+
Как ни странно, именно основы работы Gulp и есть его самая интересная и сложная часть.
5+
Именно из-за проблем с основами многие программисты тратят кучу времени на форумах и блогах в поисках "рецептов".
6+
7+
Этим скринкастом мне хотелось бы ответить на большинство возникающих вопросов по Gulp.
8+
9+
Да, и кстати, если вы хотите рецепты -- конечно, они тоже будут. Нужны же примеры. Мы также рассмотрим порядка 20 плагинов.
10+
Но в этом скринкасте они играют вспомогательную роль, наша цель -- не копипаст решений, а понимание происходящего.
11+
12+
Копипаст обречён. Всё время появляются новые плагины и меняются старые. Информация быстро устаревает. А понимание позволит вам с умом собрать решение самому или адаптировать представленное в скринкасте.
13+
14+
План:
15+
16+
1. Что такое Gulp? Сравнение с Grunt/Webpack.
17+
2. Задачи в Gulp.
18+
3. Работа с потоками Vinyl-fs.
19+
4. Пример сборки со Stylus.
20+
5. Инкрементальная сборка, watch.
21+
6. Плагины для инкрементальной сборки.
22+
7. Пример сборки с postcss и webpack.
23+
8. Организация gulp-файла.
24+
25+
Это, конечно, общие слова, но вы можете задать конкретные вопросы и высказать пожелания в комментариях ниже, я их учту.
26+
27+
Вы также получите уведомления о выпусках, если подписаны на последнюю рассылку из списка ниже.
28+

0 commit comments

Comments
 (0)