Skip to content

Commit

Permalink
Implemented basic view
Browse files Browse the repository at this point in the history
  • Loading branch information
hackreactor-students committed May 20, 2014
1 parent 3753548 commit 3f9fa67
Show file tree
Hide file tree
Showing 22 changed files with 519 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "client/lib"
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
client/lib
_DS_Store
DS_Store
88 changes: 88 additions & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"user strict";
var gulp = require('gulp'),
bower = require('gulp-bower'),
jshint = require('gulp-jshint'),
refresh = require('gulp-livereload'),
notify = require('gulp-notify'),
plumber = require('gulp-plumber'),
client = require('tiny-lr')(),
list = require('gulp-task-listing'),
nodemon = require('gulp-nodemon'),
lr_port = 35729,
sass = require('gulp-sass');


var paths = {
scripts: ['!client/lib/**/*.js', 'client/**/*.js'],
views: ['!client/lib/*.html', 'client/**/*.html', 'client/index.html'],
styles: {
css: ['!client/lib/**/*.css', 'client/styles/css/*.css', 'client/**/*.css'],
sass: ['client/styles/sass/*.scss', 'client/**/*.scss'],
dest: 'client/styles/css'
}
};
var build = ['sass', 'css', 'lint'];


gulp.task('sass', function () {
return gulp.src(paths.styles.sass)
.pipe(plumber())
.pipe(sass())
.pipe(gulp.dest(paths.styles.dest))
.pipe(refresh(client))
.pipe(notify({message: 'Sass done'}));
});


gulp.task('bowerInstall', function () {
bower()
.pipe();
});

gulp.task('html', function () {
return gulp.src(paths.views)
.pipe(plumber())
.pipe(refresh(client))
.pipe(notify({message: 'Views refreshed'}));
});

gulp.task('css', function () {
return gulp.src(paths.styles.css)
.pipe(plumber())
.pipe(refresh(client))
.pipe(notify({message: 'CSS refreshed'}));
});

gulp.task('lint', function () {
return gulp.src(paths.scripts)
.pipe(plumber())
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(refresh(client))
.pipe(notify({message: 'Lint done'}));
});

gulp.task('serve', function () {
nodemon({script: 'server/server.js', ignore: ['node_modules/**/*.js']})
.on('restart', function () {
refresh(client);
});
});

gulp.task('live', function () {
client.listen(lr_port, function (err) {
if (err) {
return console.error(err);
}
});
});

gulp.task('watch', function () {
gulp.watch(paths.styles.sass, ['sass']);
gulp.watch(paths.views, ['html']);
gulp.watch(paths.scripts, ['lint']);
});

gulp.task('build', build);

gulp.task('default', ['build', 'live', 'serve', 'watch']);
12 changes: 12 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "hrhackathon",
"version": "",
"dependencies": {
"bootstrap-css-only": "*",
"angular": "*",
"angular-route": "*",
"angular-cookies": "*",
"ng-Fx": "*",
"angular-sanitize": "~1.2.16"
}
}
14 changes: 14 additions & 0 deletions client/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(function (angular) {
"use strict";

angular.module('HRhackathon', [
'fx.animations',
'ngAnimate',
'ngRoute',
'ngCookies',
'ngSanitize',
'HRhackathon.main']);
}(angular));



10 changes: 10 additions & 0 deletions client/common/directives.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function (angular) {
"use strict";

angular.module('HRhackathon')
.directive('search', function () {
return {

};
});
}(angular));
44 changes: 44 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html ng-app="HRhackathon">
<head>
<meta charset='utf8'>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width">
<title>Snftr</title>
<link rel="stylesheet" type="text/css" href="lib/bootstrap-css-only/css/bootstrap.css">
<link rel="stylesheet" href="styles/css/app.css"/>
</head>
<body>
<header>
<nav class='navbar navbar-default' role='navigation'>
<div class='container-fluid'>
<div class='navbar-header'>
<a class="navbar-brand" ui-sref='HRhackathon.main'>Snftr</a>
</div>
<ul class="nav navbar-nav">
<li>
<a href="#/">Home</a>
</li>
<li>
<a href="#/notes">Notes</a>
</li>
</ul>
</div>
</nav>
</header>
<div ng-view></div>

<script src="lib/angular/angular.js"></script>
<script src="lib/angular-route/angular-route.js"></script>
<script src="lib/angular-cookies/angular-cookies.js"></script>
<script src="lib/angular-sanitize/angular-sanitize.js"></script>


<script src="lib/angular-animate/angular-animate.js"></script><script src="lib/gsap/src/uncompressed/TweenMax.js"></script>
<script src="lib/ng-Fx/dist/ng-Fx.js"></script>
<script src="app.js"></script>
<script src="common/directives.js"></script>
<script src="main/main.js"></script>
<script src="note/note.js"></script>
</body>
</html>
95 changes: 95 additions & 0 deletions client/main/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
(function (angular) {
'use strict';
angular.module('HRhackathon.main', ['ngRoute', 'HRhackathon.main.note', 'ngSanitize'])
.config(function ($routeProvider) {

$routeProvider
.when('/', {
templateUrl: 'main/main.tpl.html',
controller: 'MainController'
})
.otherwise({
redirectTo: '/'
});

})
.controller('MainController', function ($scope, $http, $sce) {
$scope.things = [];
$scope.contentType = '/';
$scope.targetBlog = 'newyorker.tumblr.com';
$scope.postPhoto = function(post){
var photos = [];
for(var y = 0; y < post.photos.length; y++){
photos.push('<img src=' + post.photos[y].original_size.url + '></img>');
}
photos = photos.join('');
$scope.things.push({html: $sce.trustAsHtml(photos)});
};
$scope.postText = function(post){
$scope.things.push({html: $sce.trustAsHtml(post.body)});
};
$scope.postQuote = function(post){
$scope.things.push({html: $sce.trustAsHtml('<div>' + post.text + '</div>' + post.source)});
};
$scope.postLink = function(post){
$scope.things.push({html: $sce.trustAsHtml('<a href=' + post.url + '>' + post.title + '</a><div>' + post.description + '</div>')});
};
$scope.postChat = function(post){
post.title ? $scope.things.push({html: $sce.trustAsHtml('<div>' + post.title + '</div>' + post.body)}) : $scope.things.push({html: $sce.trustAsHtml(post.body)});
};
$scope.postAudio = function(post){
$scope.things.push({html: $sce.trustAsHtml(post.player + '<div>' + post.caption + '</div>')});
};
$scope.postVideo = function(post){
$scope.things.push({html: $sce.trustAsHtml(post.player.embed_code)});
};
$scope.postAnswer = function(post){
$scope.things.push({html: $sce.trustAsHtml('<div>' + post.question + '</div><a href=' + post.asking_url + '>' + post.asking_name + '</a><div>' + post.answer + '</div>')});
};
$scope.parsePost = function(post){
if(post.type === 'photo'){
$scope.postPhoto(post);
}else if(post.type === 'text'){
$scope.postText(post);
}else if(post.type === 'quote'){
$scope.postQuote(post);
}else if(post.type === 'link'){
$scope.postLink(post);
}else if(post.type === 'chat'){
$scope.postChat(post);
}else if(post.type === 'audio'){
$scope.postAudio(post);
}else if(post.type === 'video'){
$scope.postVideo(post);
}else if(post.type === 'answer'){
$scope.postAnswer(post);
}
};
$scope.searchFor = function(url, valid){
//console.log(valid);
$http({method: 'POST', url: '/load', data: {blog: url, contentType: $scope.contentType, source: $scope.contentSource}})
.success(function(data, status, headers, config) {
// $scope.things.push(data);

// console.log(data);
for(var i = 0; i < data.posts.length; i++){
var post = data.posts[i];
if($scope.contentSource){
console.log(post.source_url, post.source_title);
if(post.source_title === $scope.contentSource){
$scope.parsePost(post);
}
}else{
$scope.parsePost(post);
}
}
})
.error(function(data, status, headers, config) {
console.log(data);
console.log(status);
console.log(headers);
console.log(config);
});
};
});
}(angular));
27 changes: 27 additions & 0 deletions client/main/main.tpl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="container-fluid" ng-model='things'>
<h1></h1>
<form name='findForm'>
<input ng-model='targetBlog' name='url' placeholder='Enter Blog URL'>
<select ng-model='contentType'>
<option value='/'>All</option>
<option value='text'>Textposts</option>
<option value='photo'>Photos</option>
<option value='video'>Video</option>
<option value='audio'>Audio</option>
<option value='link'>Link</option>
<option value='answer'>Questions and Answers</option>
<option value='quote'>Quotes</option>
<option value='chat'>Chat posts</option>
</select>
<input ng-model='original' type='checkbox'> Return only original posts </input>
<input ng-model='contentSource' placeholder='(Optional) Source'>
<button type='submit' ng-model='search' ng-click='searchFor(targetBlog, findForm.url.$valid)'>Find</button>
</form>
<div ng-repeat='thing in things'>
<div ng-bind-html='thing.html'>{{thing}}</div>
</div>

<script type="text/ng-template" id="/text.html">
Working
</script>
</div>
12 changes: 12 additions & 0 deletions client/note/note.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
angular.module('HRhackathon.main.note', ['ngRoute'])

.config(function ($routeProvider) {
$routeProvider
.when('/notes', {
templateUrl: 'note/note.tpl.html',
controller: 'NoteController'
});
})
.controller('NoteController', function ($scope) {
$scope.notes = [];
});
5 changes: 5 additions & 0 deletions client/note/note.tpl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
<h1>
notes
</h1>
</div>
2 changes: 2 additions & 0 deletions client/styles/css/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#messages {
color: lightgrey; }
3 changes: 3 additions & 0 deletions client/styles/sass/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#messages {
color: lightgrey
}
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "package",
"version": "0.0.0",
"dependencies": {
"express": "*",
"mongoose": "*",
"q": "*",
"tumblr.js": "0.0.4"
},
"devDependencies": {
"gulp": "*",
"gulp-bower": "*",
"morgan": "*",
"body-parser": "*",
"tiny-lr": "*",
"gulp-jshint": "*",
"gulp-notify": "*",
"gulp-livereload": "*",
"gulp-nodemon": "*",
"gulp-plumber": "*",
"gulp-task-listing": "*",
"jshint-stylish": "*",
"gulp-concat": "*",
"gulp-uglify": "*",
"gulp-sass": "*"
}
}
25 changes: 25 additions & 0 deletions server/main/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use strict";

var express = require('express');
var app = express();
var routers = {};
var NoteRouter = express.Router();
routers.NoteRouter = NoteRouter;

require('./config.js')(app, express, routers);

require('../note/note_routes.js')(NoteRouter);

// var tumblr = require('tumblr.js');
// app.client = tumblr.createClient({
// consumer_key: 'daW4dgiFgb4oVOw8IB0vUjCyipIoRyYMlUVkBJUrp3AX8ENaVo',
// consumer_secret: 'FZ4dluZeGXTlMT109sG5lG3iqgYUN1PF7PXjOhXMSbwm8dVBLi',
// // token: '<oauth token>',
// // token_secret: '<oauth token secret>'
// });

module.exports = exports = app;


// OAuth Consumer Key: daW4dgiFgb4oVOw8IB0vUjCyipIoRyYMlUVkBJUrp3AX8ENaVo
// Secret Key: FZ4dluZeGXTlMT109sG5lG3iqgYUN1PF7PXjOhXMSbwm8dVBLi
Loading

0 comments on commit 3f9fa67

Please sign in to comment.