Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New gallery #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ var express = require('express'),
fs = require('fs'),
slides = require('../controllers/slides');

var session = require('express-session');

module.exports = function(app, config) {
var db = require('mongoskin').db(config.app.db);

app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}))

//static files served from /public
app.use(express.static(path.join(__dirname, '/../public')));
if (env === 'production') {
Expand All @@ -18,7 +22,6 @@ module.exports = function(app, config) {
// root
app.get('/', function(req, res) {
res.render('index');
//res.sendfile('index.html', {'root': __dirname + '/../public/'});
});

//create slide
Expand All @@ -27,4 +30,28 @@ module.exports = function(app, config) {
app.get('/slide', function (req, res) { res.redirect('/') });
app.get('/slide/', function (req, res) { res.redirect('/') });
app.get('/slide/:id', slides.get);
app.get('/slides', checkAuth, slides.gallery);

function checkAuth(req, res, next) {
if (!req.session.user_id) {
res.send('You are not authorized to view this page');
} else {
next();
}
}

app.get('/login', function(req, res) {
res.render('login');
});

app.post('/login', function (req, res) {
var post = req.body;
if (post.user === 'johnny' && post.password === 'meteor') {
req.session.user_id = '1';
res.redirect('/slides');
} else {
res.send('Bad user/pass');
}
});

};
7 changes: 6 additions & 1 deletion controllers/slides.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ exports.get = function(req, res) {
console.error('error loading slide ' + req.params.id, fs.readdirSync(slidesDir))
res.redirect('/');
}
};
};

exports.gallery = function(req, res) {
var folder = fs.readdirSync('public/slides');
res.render('slides', { folder: folder});
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"hbs": "^2.7.0",
"mongoskin": "^1.4.4",
"morgan": "^1.1.1",
"serve-favicon": "^2.0.1"
"serve-favicon": "^2.0.1",
"express-session": "1.5.1"
},
"devDependencies": {}
}
69 changes: 69 additions & 0 deletions views/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="/css/styles.css">
{{#if is_phone}}
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" media="all and (max-device-width: 720px)" href="/css/mobile.css" />
{{/if}}
<title>מה אני חושב על ערוץ1</title>
<meta property="og:title" content="מה אני חושב על ערוץ 1" />
<meta property="og:site_name" content="arutzehad.com" />
<meta property="og:url" content="http://arutzehad.com" />
<meta property="og:description" content="בוא ליצור שקופיות ולענות לערוץ 1" />
<meta property="og:type" content="website" />
<meta property="fb:app_id" content="306743582817028" />
<meta name="description" content="לחצו כדי לראות מה אני חושב על ערוץ 1">
</head>
<body>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-52086778-1', 'arutzehad.com');
ga('send', 'pageview');
</script>
<div class="container">
<header>
<input id="input" dir="rtl" type="text" placeholder="כתוב כאן את הטקסט"></input>
<a class="button go" onclick="drawSlide()">שדר</a>
<a class="button clear" onclick="clearSlide()">נקה</a>
<div class="error-message"></div>
<div class="clr"></div>
</header>
<div class="canvas-container">
<img class="tv" src="/images/tv.png"></img>
<canvas id="canvas" dir="rtl" width="672" height="412"></canvas>
</div>
<br />
<a class="button save-button" onclick="saveSlide()">שמור</a>
<span class="loader rotating"><img src="/images/loader.png"></span>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="/js/script.js"></script>
<script type="text/javascript" src="/js/bPopUp.js"></script>
</div>
<div class="popup">
<div class="pop-header">Login:</div>
<div class="pop-body">
<form action="/login" method="post" style="direction: ltr;">
<div>
<label for="user">user:</label>
<input type="text" name="user" id="user" />
</div>
<div>
<label for="password">password:</label>
<input type="password" name="password" id="password" />
</div>
<button class="button" type="submit">login</button>
</form>


</div>


</div>
</body>
</html>
50 changes: 50 additions & 0 deletions views/slides.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="/css/styles.css">
{{#if is_phone}}
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" media="all and (max-device-width: 720px)" href="/css/mobile.css" />
{{/if}}
<title>מה אני חושב על ערוץ1</title>
<meta property="og:title" content="מה אני חושב על ערוץ 1" />
<meta property="og:site_name" content="arutzehad.com" />
<meta property="og:description" content="לחץ כדי לראות את השקופית" />
<meta property="og:type" content="article" />
<meta property="fb:app_id" content="306743582817028" />
<meta name="description" content="לחצו כדי לראות מה אני חושב על ערוץ 1">

</head>
<body>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){

})
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-52086778-1', 'arutzehad.com');
ga('send', 'pageview');
</script>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&appId=306743582817028&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

{{#each slides}}
<div><img src="{{this}}"></div>
{{/each}}


</body>
</html>