This repository has been archived by the owner on Apr 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 98cf5c2
Showing
28 changed files
with
1,904 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# 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 | ||
1.3.0-split-minifiers-package | ||
1.4.0-remove-old-dev-bundle-link | ||
1.4.1-add-shell-server-package | ||
1.4.3-split-account-service-packages | ||
1.5-add-dynamic-import-package | ||
1.7-split-underscore-from-meteor-base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
y86kuay3dddt.flkjpma3sowg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 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. | ||
|
||
[email protected] # Packages every Meteor app needs to have | ||
[email protected] # Packages for a great mobile UX | ||
[email protected] # The database Meteor supports right now | ||
[email protected] # Compile .html files into Meteor Blaze views | ||
[email protected] # Reactive variable for tracker | ||
[email protected] # Meteor's client-side reactive programming library | ||
|
||
[email protected] # CSS minifier run for production mode | ||
[email protected] # JS minifier run for production mode | ||
[email protected] # ECMAScript 5 compatibility for older browsers | ||
[email protected] # Enable ECMAScript2015+ syntax in app code | ||
[email protected] # Server-side component of the `meteor shell` command | ||
|
||
[email protected] | ||
underscore | ||
session |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
server | ||
browser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* CSS declarations go here */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<head> | ||
<title>Short Link</title> | ||
</head> | ||
|
||
<body> | ||
<div id="app"></div> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import { routes } from '../imports/routes/routes'; | ||
import '../imports/startup/simple-schema-configuration'; | ||
|
||
Meteor.startup(() => { | ||
ReactDOM.render(routes, document.getElementById('app')); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { Mongo } from 'meteor/mongo'; | ||
import SimpleSchema from 'simpl-schema'; | ||
import shortid from 'shortid'; | ||
|
||
export const Links = new Mongo.Collection('links'); | ||
|
||
if (Meteor.isServer) | ||
{ | ||
Meteor.publish('links', function () { | ||
return Links.find({ userId: this.userId }); | ||
}); | ||
} | ||
|
||
Meteor.methods({ | ||
'links.insert'(url) { | ||
if (!this.userId) | ||
{ | ||
throw new Meteor.Error('not-authorised') | ||
} | ||
|
||
new SimpleSchema({ | ||
url: { | ||
type: String, | ||
label: 'Your link', | ||
regEx: SimpleSchema.RegEx.Url | ||
} | ||
}).validate( { url } ); | ||
|
||
Links.insert({ | ||
_id: shortid.generate(), | ||
url, | ||
userId: this.userId, | ||
visible: true, | ||
visitedCount: 0, | ||
lastVisitedAt: null | ||
}); | ||
}, | ||
'links.setVisibility'(_id, visible) { | ||
if (!this.userId) | ||
{ | ||
throw new Meteor.Error('not-authorised'); | ||
} | ||
|
||
new SimpleSchema({ | ||
_id: { | ||
type: String, | ||
min: 1 | ||
}, | ||
visible: { | ||
type: Boolean, | ||
} | ||
}).validate({ _id, visible }); | ||
|
||
Links.update( | ||
{ | ||
_id, | ||
userId: this.userId | ||
}, | ||
{ | ||
$set: {visible} | ||
} | ||
); | ||
}, | ||
'links.trackVisit'(_id) { | ||
new SimpleSchema({ | ||
_id: { | ||
type: String, | ||
min: 1 | ||
} | ||
}).validate({ _id }); | ||
|
||
Links.update({ _id }, | ||
{ | ||
$inc: {visitedCount: 1}, | ||
$set: {lastVisitedAt: new Date().getTime()} | ||
} | ||
); | ||
|
||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import SimpleSchema from 'simpl-schema'; | ||
import { Accounts } from 'meteor/accounts-base'; | ||
|
||
Accounts.validateNewUser((user) => { | ||
const email = user.emails[0].address; | ||
|
||
new SimpleSchema({ | ||
email: { | ||
type: String, | ||
regEx: SimpleSchema.RegEx.Email | ||
} | ||
}).validate( { email } ); | ||
|
||
return true; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import React from 'react'; | ||
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; | ||
|
||
import Authentication from '../ui/Authentication'; | ||
import Link from '../ui/Link'; | ||
import Login from '../ui/Login'; | ||
import NotFound from '../ui/NotFound'; | ||
import Signup from '../ui/Signup'; | ||
|
||
export const routes = ( | ||
<Router> | ||
<div> | ||
<Route path='*' component={Authentication}/> | ||
<Switch> | ||
<Route exact path='/' component={Login}/> | ||
<Route path='/signup' component={Signup}/> | ||
<Route path='/links' component={Link}/> | ||
<Route path='*' component={NotFound}/> | ||
</Switch> | ||
</div> | ||
</Router> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import SimpleSchema from 'simpl-schema'; | ||
|
||
SimpleSchema.defineValidationErrorTransform(e => { | ||
return new Meteor.Error(400, e.message); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import { Meteor } from 'meteor/meteor'; | ||
|
||
export default class AddLink extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
url: '' | ||
} | ||
} | ||
onSubmit(e) { | ||
e.preventDefault(); | ||
const url = this.refs.url.value.trim(); | ||
if (url) | ||
{ | ||
Meteor.call('links.insert', url); | ||
this.refs.url.value = ''; | ||
} | ||
} | ||
onChange(e) { | ||
this.setState({url: e.target.value }); | ||
} | ||
render() { | ||
return ( | ||
<div> | ||
<p>Add link</p> | ||
<form onSubmit={this.onSubmit.bind(this)}> | ||
<input | ||
type="text" | ||
ref="url" | ||
placeholder="URL" | ||
value={this.state.url} | ||
onChange={this.onChange.bind(this)} | ||
/> | ||
<button>Add link</button> | ||
</form> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Tracker } from 'meteor/tracker'; | ||
|
||
const unauthenticatedPages = ['/', '/signup']; | ||
const authenticatedPages = ['/links']; | ||
|
||
export default ({ location, history }) => { | ||
Tracker.autorun(() => { | ||
const isAuthenticated = !!Meteor.userId(); | ||
// console.log('isAuthenticated', isAuthenticated); | ||
|
||
const isUnauthenticatedPage = unauthenticatedPages.includes(location.pathname); | ||
const isAuthenticatedPage = authenticatedPages.includes(location.pathname); | ||
|
||
if (isUnauthenticatedPage && isAuthenticated) | ||
{ | ||
history.replace('/links'); | ||
} | ||
if (isAuthenticatedPage && !isAuthenticated) | ||
{ | ||
history.replace('/'); | ||
} | ||
}); | ||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
|
||
import LinksList from './LinksList' | ||
import PrivateHeader from './PrivateHeader'; | ||
import AddLink from './AddLink'; | ||
import LinksListFilters from './LinksListFilters'; | ||
|
||
export default () => { | ||
return ( | ||
<div> | ||
<PrivateHeader title='Links Page'/> | ||
<LinksListFilters/> | ||
<LinksList/> | ||
<AddLink/> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.