Merged UI and backend

This commit is contained in:
2018-05-08 23:33:13 +05:30
parent bbc9223c5a
commit c0042d1505
56 changed files with 1571 additions and 1 deletions

BIN
._.bowerrc Normal file

Binary file not shown.

BIN
._.gitignore Normal file

Binary file not shown.

BIN
._.jshintrc Normal file

Binary file not shown.

BIN
._.travis.yml Normal file

Binary file not shown.

BIN
._LICENSE Normal file

Binary file not shown.

BIN
._README.md Normal file

Binary file not shown.

BIN
._bower.json Normal file

Binary file not shown.

BIN
._karma.conf.js Normal file

Binary file not shown.

BIN
._package.json Normal file

Binary file not shown.

3
.bowerrc Normal file
View File

@@ -0,0 +1,3 @@
{
"directory": "app/bower_components"
}

113
.gitignore vendored
View File

@@ -1,2 +1,113 @@
venv
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
mini-amazon.iml
modules.xml
misc.xml
.idea
logs/*
!.gitkeep
node_modules/
bower_components/
tmp
.DS_Store

13
.jshintrc Normal file
View File

@@ -0,0 +1,13 @@
{
"globalstrict": true,
"globals": {
"angular": false,
"describe": false,
"it": false,
"expect": false,
"beforeEach": false,
"afterEach": false,
"module": false,
"inject": false
}
}

14
.travis.yml Normal file
View File

@@ -0,0 +1,14 @@
language: node_js
node_js:
- "0.10"
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm start > /dev/null &
- npm run update-webdriver
- sleep 1 # give server time to start
script:
- node_modules/.bin/karma start karma.conf.js --no-auto-watch --single-run --reporters=dots --browsers=Firefox
- node_modules/.bin/protractor e2e-tests/protractor.conf.js --browser=firefox

297
README.md Normal file
View File

@@ -0,0 +1,297 @@
# angular-seed — the seed for AngularJS apps
This project is an application skeleton for a typical [AngularJS](http://angularjs.org/) web app.
You can use it to quickly bootstrap your angular webapp projects and dev environment for these
projects.
The seed contains a sample AngularJS application and is preconfigured to install the Angular
framework and a bunch of development and testing tools for instant web development gratification.
The seed app doesn't do much, just shows how to wire two controllers and views together.
## Getting Started
To get you started you can simply clone the angular-seed repository and install the dependencies:
### Prerequisites
You need git to clone the angular-seed repository. You can get git from
[http://git-scm.com/](http://git-scm.com/).
We also use a number of node.js tools to initialize and test angular-seed. You must have node.js and
its package manager (npm) installed. You can get them from [http://nodejs.org/](http://nodejs.org/).
### Clone angular-seed
Clone the angular-seed repository using [git][git]:
```
git clone https://github.com/angular/angular-seed.git
cd angular-seed
```
If you just want to start a new project without the angular-seed commit history then you can do:
```bash
git clone --depth=1 https://github.com/angular/angular-seed.git <your-project-name>
```
The `depth=1` tells git to only pull down one commit worth of historical data.
### Install Dependencies
We have two kinds of dependencies in this project: tools and angular framework code. The tools help
us manage and test the application.
* We get the tools we depend upon via `npm`, the [node package manager][npm].
* We get the angular code via `bower`, a [client-side code package manager][bower].
We have preconfigured `npm` to automatically run `bower` so we can simply do:
```
npm install
```
Behind the scenes this will also call `bower install`. You should find that you have two new
folders in your project.
* `node_modules` - contains the npm packages for the tools we need
* `app/bower_components` - contains the angular framework files
*Note that the `bower_components` folder would normally be installed in the root folder but
angular-seed changes this location through the `.bowerrc` file. Putting it in the app folder makes
it easier to serve the files by a webserver.*
### Run the Application
We have preconfigured the project with a simple development web server. The simplest way to start
this server is:
```
npm start
```
Now browse to the app at `http://localhost:8000/app/index.html`.
## Directory Layout
```
app/ --> all of the source files for the application
app.css --> default stylesheet
components/ --> all app specific modules
version/ --> version related components
version.js --> version module declaration and basic "version" value service
version_test.js --> "version" value service tests
version-directive.js --> custom directive that returns the current app version
version-directive_test.js --> version directive tests
interpolate-filter.js --> custom interpolation filter
interpolate-filter_test.js --> interpolate filter tests
view1/ --> the view1 view template and logic
view1.html --> the partial template
view1.js --> the controller logic
view1_test.js --> tests of the controller
view2/ --> the view2 view template and logic
view2.html --> the partial template
view2.js --> the controller logic
view2_test.js --> tests of the controller
app.js --> main application module
index.html --> app layout file (the main html template file of the app)
index-async.html --> just like index.html, but loads js files asynchronously
karma.conf.js --> config file for running unit tests with Karma
e2e-tests/ --> end-to-end tests
protractor-conf.js --> Protractor config file
scenarios.js --> end-to-end scenarios to be run by Protractor
```
## Testing
There are two kinds of tests in the angular-seed application: Unit tests and End to End tests.
### Running Unit Tests
The angular-seed app comes preconfigured with unit tests. These are written in
[Jasmine][jasmine], which we run with the [Karma Test Runner][karma]. We provide a Karma
configuration file to run them.
* the configuration is found at `karma.conf.js`
* the unit tests are found next to the code they are testing and are named as `..._test.js`.
The easiest way to run the unit tests is to use the supplied npm script:
```
npm test
```
This script will start the Karma test runner to execute the unit tests. Moreover, Karma will sit and
watch the source and test files for changes and then re-run the tests whenever any of them change.
This is the recommended strategy; if your unit tests are being run every time you save a file then
you receive instant feedback on any changes that break the expected code functionality.
You can also ask Karma to do a single run of the tests and then exit. This is useful if you want to
check that a particular version of the code is operating as expected. The project contains a
predefined script to do this:
```
npm run test-single-run
```
### End to end testing
The angular-seed app comes with end-to-end tests, again written in [Jasmine][jasmine]. These tests
are run with the [Protractor][protractor] End-to-End test runner. It uses native events and has
special features for Angular applications.
* the configuration is found at `e2e-tests/protractor-conf.js`
* the end-to-end tests are found in `e2e-tests/scenarios.js`
Protractor simulates interaction with our web app and verifies that the application responds
correctly. Therefore, our web server needs to be serving up the application, so that Protractor
can interact with it.
```
npm start
```
In addition, since Protractor is built upon WebDriver we need to install this. The angular-seed
project comes with a predefined script to do this:
```
npm run update-webdriver
```
This will download and install the latest version of the stand-alone WebDriver tool.
Once you have ensured that the development web server hosting our application is up and running
and WebDriver is updated, you can run the end-to-end tests using the supplied npm script:
```
npm run protractor
```
This script will execute the end-to-end tests against the application being hosted on the
development server.
## Updating Angular
Previously we recommended that you merge in changes to angular-seed into your own fork of the project.
Now that the angular framework library code and tools are acquired through package managers (npm and
bower) you can use these tools instead to update the dependencies.
You can update the tool dependencies by running:
```
npm update
```
This will find the latest versions that match the version ranges specified in the `package.json` file.
You can update the Angular dependencies by running:
```
bower update
```
This will find the latest versions that match the version ranges specified in the `bower.json` file.
## Loading Angular Asynchronously
The angular-seed project supports loading the framework and application scripts asynchronously. The
special `index-async.html` is designed to support this style of loading. For it to work you must
inject a piece of Angular JavaScript into the HTML page. The project has a predefined script to help
do this.
```
npm run update-index-async
```
This will copy the contents of the `angular-loader.js` library file into the `index-async.html` page.
You can run this every time you update the version of Angular that you are using.
## Serving the Application Files
While angular is client-side-only technology and it's possible to create angular webapps that
don't require a backend server at all, we recommend serving the project files using a local
webserver during development to avoid issues with security restrictions (sandbox) in browsers. The
sandbox implementation varies between browsers, but quite often prevents things like cookies, xhr,
etc to function properly when an html page is opened via `file://` scheme instead of `http://`.
### Running the App during Development
The angular-seed project comes preconfigured with a local development webserver. It is a node.js
tool called [http-server][http-server]. You can start this webserver with `npm start` but you may choose to
install the tool globally:
```
sudo npm install -g http-server
```
Then you can start your own development web server to serve static files from a folder by
running:
```
http-server -a localhost -p 8000
```
Alternatively, you can choose to configure your own webserver, such as apache or nginx. Just
configure your server to serve the files under the `app/` directory.
### Running the App in Production
This really depends on how complex your app is and the overall infrastructure of your system, but
the general rule is that all you need in production are all the files under the `app/` directory.
Everything else should be omitted.
Angular apps are really just a bunch of static html, css and js files that just need to be hosted
somewhere they can be accessed by browsers.
If your Angular app is talking to the backend server via xhr or other means, you need to figure
out what is the best way to host the static files to comply with the same origin policy if
applicable. Usually this is done by hosting the files by the backend server or through
reverse-proxying the backend server(s) and webserver(s).
## Continuous Integration
### Travis CI
[Travis CI][travis] is a continuous integration service, which can monitor GitHub for new commits
to your repository and execute scripts such as building the app or running tests. The angular-seed
project contains a Travis configuration file, `.travis.yml`, which will cause Travis to run your
tests when you push to GitHub.
You will need to enable the integration between Travis and GitHub. See the Travis website for more
instruction on how to do this.
### CloudBees
CloudBees have provided a CI/deployment setup:
<a href="https://grandcentral.cloudbees.com/?CB_clickstart=https://raw.github.com/CloudBees-community/angular-js-clickstart/master/clickstart.json">
<img src="https://d3ko533tu1ozfq.cloudfront.net/clickstart/deployInstantly.png"/></a>
If you run this, you will get a cloned version of this repo to start working on in a private git repo,
along with a CI service (in Jenkins) hosted that will run unit and end to end tests in both Firefox and Chrome.
## Contact
For more information on AngularJS please check out http://angularjs.org/
[git]: http://git-scm.com/
[bower]: http://bower.io
[npm]: https://www.npmjs.org/
[node]: http://nodejs.org
[protractor]: https://github.com/angular/protractor
[jasmine]: http://jasmine.github.io
[karma]: http://karma-runner.github.io
[travis]: https://travis-ci.org/
[http-server]: https://github.com/nodeapps/http-server

BIN
app/._app.css Normal file

Binary file not shown.

BIN
app/._app.js Normal file

Binary file not shown.

BIN
app/._index-async.html Normal file

Binary file not shown.

BIN
app/._index.html Normal file

Binary file not shown.

8
app/__init__.py Normal file
View File

@@ -0,0 +1,8 @@
from flask import Flask
app = Flask('mini_amazon',
static_folder='./static',
static_url_path='',
template_folder='./templates')
from mini_amazon import views, api

131
app/api.py Normal file
View File

@@ -0,0 +1,131 @@
from flask import request, Response, render_template, send_from_directory
from mini_amazon import app
from mini_amazon.models.product import Product, MongoProduct
from mini_amazon.models.user import User, MongoUser
mongo_product = MongoProduct()
mongo_user = MongoUser()
product_list = []
@app.route('/health', methods=['GET'])
def health():
return 'healthy'
@app.route('/api/product', methods=['POST', 'GET'])
def products():
if request.method == 'GET':
matches = mongo_product.search_by_name(request.args['name'])
output_type = request.args.get('output_type', None)
if output_type == 'html':
return render_template('results.html', results=matches, query=request.args['name'], user_id=request.args.get('user_id'))
else:
return Response(str(matches), mimetype='application/json', status=200)
elif request.method == 'POST':
product = dict()
operation_type = request.form.get('operation_type', None)
if operation_type is not None:
if operation_type == 'add':
product['_id'] = request.form['_id']
product['name'] = request.form['name']
product['description'] = request.form['description']
product['price'] = request.form['price']
# p = Product(12, request.form['name'], request.form['description'], request.form['price'])
mongo_product.save(product)
return Response(str({'status': 'success'}), mimetype='application/json', status=200)
elif operation_type == 'delete':
_id = request.form.get('_id')
mongo_product.delete_by_id(_id)
return Response(str({'status': 'success'}), mimetype='application/json', status=200)
elif operation_type == 'update':
p = Product(request.form['name'], request.form['description'], request.form['price'])
mongo_product.update_by_id(request.form['_id'], p)
return Response(str({'status': 'success'}), mimetype='application/json', status=200)
db.products.update_one(update={'$set': product}, filter={'name': currentname})
return Response(str({'status': 'success'}), mimetype='application/json', status=200)
@app.route('/listProducts', methods=['GET'])
def list_all():
matching_prods = mongo_product.list_all_products()
matches = []
for prod in matching_prods:
matches.append(prod)
return Response(str(matches), mimetype='application/json', status=200)
@app.route('/addStuff', methods=['GET'])
def add_stuff():
mongo_product.add_stuff()
return Response(str({'status': 'success'}), mimetype='application/json', status=200)
@app.route('/api/user/<action>', methods=['GET', 'POST'])
def user_actions(action):
if action == 'login':
user = User(None, None, request.form.get('username'), request.form.get('password'))
is_valid = mongo_user.authenticate(user)
name = mongo_user.find_user_name_by_credentials(user)
if is_valid is not None and is_valid:
return render_template('profile.html', sign_up_msg="Welcome to Mini-Amazon", name = name if name is not None else "Anonymous", user_id=mongo_user.get_id_by_username(request.form.get('username')))
else:
return render_template("index.html", message="Invalid Username/Password")
elif action == 'signup':
user = dict()
user['name'] = request.form.get('name')
user['email'] = request.form.get('email')
user['username'] = request.form.get('username')
user['password'] = request.form.get('password')
does_user_exist = mongo_user.check_if_user_exists(request.form.get('username'))
if does_user_exist:
return render_template("index.html", user_exists_msg="Username exists, please enter a different user name!")
else:
mongo_user.save(user)
return Response(str({'status' : 'User Added!'}), mimetype='application/json', status=200)
else:
status = {
'status' : 'Invalid Action'
}
return Response(str(status), mimetype='application/json', status=400)
@app.route('/listUsers', methods=['GET'])
def list_all_users():
matching_users = mongo_user.list_all_users()
matches = []
if matching_users is not None:
for user in matching_users:
matches.append(user)
return render_template('users.html', results=matches)
@app.route('/addUsers', methods=['GET'])
def add_users():
mongo_user.add_stuff()
return Response(str({'status': 'success'}), mimetype='application/json', status=200)
@app.route('/api/cart', methods=['GET','POST'])
def cart():
if request.args.get('op_type') == 'getcart':
userId = request.args.get('user_id')
matched_ids = mongo_user.get_usercart_by_userid(userId)
matches = mongo_product.get_product_list_from_product_ids(matched_ids)
return render_template('cart.html', user_id=userId, results=matches)
elif request.args.get('op_type') == 'addToCart':
pass
else:
user_id = request.args.get('user_id',None)
product_id = request.args.get('product_id', None)
user= mongo_user.get_by_id(user_id)
success = mongo_user.add_to_cart(user_id,product_id)
user_data = mongo_user.get_by_id(user_id)
return render_template('profile.html',name=user_data['name'],user_id=user_id)
# @app.route('/admin.html')
# def admin_tasks():
# return render_template('../../static/admin.html')

70
app/app.css Normal file
View File

@@ -0,0 +1,70 @@
/* app css stylesheet */
.menu {
list-style: none;
border-bottom: 0.1em solid black;
margin-bottom: 2em;
padding: 0 0 0.5em;
}
.menu:before {
content: "[";
}
.menu:after {
content: "]";
}
.menu > li {
display: inline;
}
.menu > li:before {
content: "|";
padding-right: 0.3em;
}
.menu > li:nth-child(1):before {
content: "";
padding: 0;
}
.stbody
{
min-height:70px;
}
.stbody
{
min-height:70px;
margin-bottom:10px;
border-bottom:dashed 1px #cc0000;
}
.stimg
{
float:left;
height:50px;
width:50px;
border:solid 1px #dedede;
padding:5px;
}
.sttext
{
margin-left:70px;
min-height:50px;
word-wrap:break-word;
overflow:hidden;
padding:5px;
display:block;
font-family:'Georgia', Times New Roman, Times, serif
}
.sttime
{
font-size:11px;
color:#999;
font-family:Arial, Helvetica, sans-serif;
margin-top:5px;
}

12
app/app.js Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
// Declare app level module which depends on views, and components
angular.module('ngSocial', [
'ngRoute',
'ngSocial.view1',
'ngSocial.view2',
'ngSocial.facebook'
]).
config(['$routeProvider', function($routeProvider) {
$routeProvider.otherwise({redirectTo: '/facebook'});
}]);

Binary file not shown.

BIN
app/facebook/._facebook.js Normal file

Binary file not shown.

View File

@@ -0,0 +1,59 @@
<div class="row" ng-controller="FacebookCtrl">
<div class="col-md-4">
<h4>{{welcomeMsg}}</h4>
<div ng-if="isLoggedIn == true">
<a href="{{userInfo.link}}" target="_blank"><img ng-src="{{picture}}"></a>
</div>
<br>
<div ng-if="isLoggedIn == false">
<button type="button" class="btn btn-default" ng-click="login()">Login</button>
</div>
<div ng-if="isLoggedIn == true">
<button type="button" class="btn btn-default" ng-click="logout()">Logout</button>
</div>
<br><br>
<div ng-if="isLoggedIn == true" class="well">
<h4>User Info</h4>
<ul>
<li>ID: {{userInfo.id}}</li>
<li>First Name: {{userInfo.first_name}}</li>
<li>Last Name: {{userInfo.last_name}}</li>
<li>Email: {{userInfo.email}}</li>
<li>Gender: {{userInfo.gender}}</li>
<li>Locale: {{userInfo.locale}}</li>
</ul>
</div>
<br>
<div class="well" ng-if="isLoggedIn == true">
<h4>Permissions</h4>
<ul>
<li ng-repeat="permission in permissions">{{permission.permission}} - {{permission.status}}</li>
</ul>
</div>
</div>
<div class="col-md-8">
<h3>Welcome to Facebook!</h3>
<div ng-if="isLoggedIn == true">
<form ng-submit="postStatus()">
<div class="form-group">
<label>Status Update</label>
<textarea ng-model="body" class="form-control"></textarea>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<br><br>
<div ng-repeat="post in posts" class="stbody">
<div class="stimg">
<img ng-src="{{picture}}">
</div>
<div class="sttext">
{{post.message}}
<div class="sttime">{{post.updated_time}}</div>
</div>
</div>
</div>
<div ng-if="isLoggedIn == false">
<p>You need to login to post</p>
</div>
</div>
</div>

75
app/facebook/facebook.js Normal file
View File

@@ -0,0 +1,75 @@
'use strict';
angular.module('ngSocial.facebook', ['ngRoute','ngFacebook'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/facebook', {
templateUrl: 'facebook/facebook.html',
controller: 'FacebookCtrl'
});
}])
.config( function( $facebookProvider ) {
$facebookProvider.setAppId('846149575421651');
$facebookProvider.setPermissions("email,public_profile, user_posts, publish_actions, user_photos");
})
.run(function($rootScope){
(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_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
})
.controller('FacebookCtrl', ['$scope', '$facebook', function($scope, $facebook) {
$scope.isLoggedIn = false;
$scope.login = function(){
$facebook.login().then(function(){
$scope.isLoggedIn = true;
refresh();
});
}
$scope.logout = function(){
$facebook.logout().then(function(){
$scope.isLoggedIn = false;
refresh();
});
}
function refresh(){
$facebook.api("/me").then(function(response){
$scope.welcomeMsg = "Welcome "+ response.name;
$scope.isLoggedIn = true;
$scope.userInfo = response;
$facebook.api('/me/picture').then(function(response){
$scope.picture = response.data.url;
$facebook.api('/me/permissions').then(function(response){
$scope.permissions = response.data;
$facebook.api('/me/posts').then(function(response){
console.log(response.data);
$scope.posts = response.data;
});
});
});
},
function(err){
$scope.welcomeMsg = "Please Log In";
});
}
$scope.postStatus = function(){
var body = this.body;
$facebook.api('/me/feed', 'post', {message: body}).then(function(response){
$scope.msg = 'Thanks for Posting';
refresh();
});
}
refresh();
}]);

58
app/index-async.html Normal file
View File

@@ -0,0 +1,58 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="bower_components/html5-boilerplate/css/normalize.css">
<link rel="stylesheet" href="bower_components/html5-boilerplate/css/main.css">
<style>
[ng-cloak] {
display: none;
}
</style>
<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
<script>
// include angular loader, which allows the files to load in any order
//@@NG_LOADER_START@@
// You need to run `npm run update-index-async` to inject the angular async code here
//@@NG_LOADER_END@@
// include a third-party async loader library
/*!
* $script.js v1.3
* https://github.com/ded/script.js
* Copyright: @ded & @fat - Dustin Diaz, Jacob Thornton 2011
* Follow our software http://twitter.com/dedfat
* License: MIT
*/
!function(a,b,c){function t(a,c){var e=b.createElement("script"),f=j;e.onload=e.onerror=e[o]=function(){e[m]&&!/^c|loade/.test(e[m])||f||(e.onload=e[o]=null,f=1,c())},e.async=1,e.src=a,d.insertBefore(e,d.firstChild)}function q(a,b){p(a,function(a){return!b(a)})}var d=b.getElementsByTagName("head")[0],e={},f={},g={},h={},i="string",j=!1,k="push",l="DOMContentLoaded",m="readyState",n="addEventListener",o="onreadystatechange",p=function(a,b){for(var c=0,d=a.length;c<d;++c)if(!b(a[c]))return j;return 1};!b[m]&&b[n]&&(b[n](l,function r(){b.removeEventListener(l,r,j),b[m]="complete"},j),b[m]="loading");var s=function(a,b,d){function o(){if(!--m){e[l]=1,j&&j();for(var a in g)p(a.split("|"),n)&&!q(g[a],n)&&(g[a]=[])}}function n(a){return a.call?a():e[a]}a=a[k]?a:[a];var i=b&&b.call,j=i?b:d,l=i?a.join(""):b,m=a.length;c(function(){q(a,function(a){h[a]?(l&&(f[l]=1),o()):(h[a]=1,l&&(f[l]=1),t(s.path?s.path+a+".js":a,o))})},0);return s};s.get=t,s.ready=function(a,b,c){a=a[k]?a:[a];var d=[];!q(a,function(a){e[a]||d[k](a)})&&p(a,function(a){return e[a]})?b():!function(a){g[a]=g[a]||[],g[a][k](b),c&&c(d)}(a.join("|"));return s};var u=a.$script;s.noConflict=function(){a.$script=u;return this},typeof module!="undefined"&&module.exports?module.exports=s:a.$script=s}(this,document,setTimeout)
// load all of the dependencies asynchronously.
$script([
'bower_components/angular/angular.js',
'bower_components/angular-route/angular-route.js',
'app.js',
'view1/view1.js',
'view2/view2.js',
'components/version/version.js',
'components/version/version-directive.js',
'components/version/interpolate-filter.js'
], function() {
// when all is done, execute bootstrap angular application
angular.bootstrap(document, ['myApp']);
});
</script>
<title>My AngularJS App</title>
<link rel="stylesheet" href="app.css">
</head>
<body ng-cloak>
<ul class="menu">
<li><a href="#/view1">view1</a></li>
<li><a href="#/view2">view2</a></li>
</ul>
<div ng-view></div>
<div>Angular seed app: v<span app-version></span></div>
</body>
</html>

49
app/index.html Normal file
View File

@@ -0,0 +1,49 @@
<!DOCTYPE html>
<!--[if lt IE 7]> <html lang="en" ng-app="ngSocial" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html lang="en" ng-app="ngSocial" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html lang="en" ng-app="ngSocial" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" ng-app="ngSocial" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ngSocial App</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="app.css">
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">ngSocial</a>
</div>
</div>
</nav>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div class="container">
<div ng-view></div>
</div>
<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/ng-facebook/ngFacebook.js"></script>
<script src="app.js"></script>
<script src="view1/view1.js"></script>
<script src="view2/view2.js"></script>
<script src="facebook/facebook.js"></script>
</body>
</html>

0
app/models/__init__.py Normal file
View File

45
app/models/product.py Normal file
View File

@@ -0,0 +1,45 @@
from pymongo import MongoClient
import json
import re
from bson import ObjectId
class Product:
def __init__(self, id, name, description, price):
self.id = id
self.name = name
self.description = description
self.price = price
class MongoProduct:
def __init__(self):
config = json.load(open('./config.json', 'r'))
client = MongoClient(config['mongo_host'], config['mongo_port'])
self.db = client[config['db_name']]
def save(self, product):
self.db.products.insert_one(product)
def search_by_name(self, name):
result_cursor = self.db.products.find({'name': re.compile(name, re.IGNORECASE)})
matches = []
for prod in result_cursor:
matches.append(prod)
return matches
def delete_by_id(self, _id):
self.db.products.delete_one({'_id': ObjectId(_id)})
def update_by_id(self, _id, prod):
self.db.products.update_one({'_id': ObjectId(_id)}, {'$set': prod})
def list_all_products(self):
return self.db.products.find()
def add_stuff(self):
for i in range(10):
product = dict()
product['name'] = "name" + str(i)
product['description'] = "description" + str(i)
product['price'] = "price" + str(i)
self.db.products.insert_one(product)

112
app/models/user.py Normal file
View File

@@ -0,0 +1,112 @@
from pymongo import MongoClient
import re
from bson import ObjectId
import json
class User:
def __init__(self, name, email, username, password):
self.name = name
self.email = email
self.username = username
self.password = password
class MongoUser:
def __init__(self):
config = json.load(open('./config.json', 'r'))
client = MongoClient(config['mongo_host'], config['mongo_port'])
self.db = client[config['db_name']]
def save(self, user):
self.db.users.insert_one(user)
def search_by_name(self, name):
result_cursor = self.db.users.find({'name': name})
matches = []
for user in result_cursor:
matches.append(user)
return matches
def delete_by_id(self, _id):
self.db.users.delete_one({'_id': ObjectId(_id)})
def update_by_id(self, _id, user):
self.db.users.update_one({'_id': ObjectId(_id)}, {'$set': user})
def authenticate(self, user):
result_cursor = self.db.users.find({'username': user.username, 'password':user.password})
if result_cursor.count() == 0:
return False
else:
return True
def list_all_users(self):
return self.db.users.find()
def add_stuff(self):
for i in range(10):
user = dict()
user['name'] = "name" + str(i)
user['email'] = "email" + str(i)
user['username'] = "username" + str(i)
user['password'] = "password" + str(i)
self.db.users.insert_one(user)
def find_user_name_by_credentials(self, user):
a = 3 if True else 1
result_cursor = self.db.users.find({'username': user.username})
matches = []
for user in result_cursor:
matches.append(user)
return matches[0]['name'] if len(matches) > 0 else None
def check_if_user_exists(self, username):
result_cursor = self.db.users.find({'username': username})
matches = []
for user in result_cursor:
matches.append(user)
if len(matches) > 0:
return True
else:
return False
def add_to_cart(self, user_id, product_id):
condition = {'_id': ObjectId(user_id)}
cursor = self.db.users.find(condition)
user_data = cursor[0] if cursor.count() > 0 else None
if user_data is None:
return False
if 'cart' not in user_data:
user_data['cart'] = []
if ObjectId(product_id) not in user_data['cart']:
user_data['cart'].append(ObjectId(product_id))
self.db.users.update_one(filter=condition, update={'$set':user_data})
return True
def get_by_id(self, _id):
query = {
'_id': ObjectId(_id)
}
cursor = self.db.users.find(query)
user = cursor[0] if cursor.count() > 0 else None
return user
def get_id_by_username(self, username):
cursor = self.db.users.find({'username': username})
user_data = cursor[0] if cursor.count() > 0 else None
if user_data is None:
return "Anonymous"
else:
matches = []
for user in cursor:
matches.append(user)
return matches[0]['_id']
def get_usercart_by_userid(self, user_id):
user = self.get_by_id(user_id)
return user['cart']

32
app/static/admin.html Normal file
View File

@@ -0,0 +1,32 @@
<html>
<head><!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<h1>Welcome to Mini Amazon</h1>
<form action="/api/product" method="post">
<h3>Select operation type</h3>
<label for="operation_type">Select operation:</label>
<select class="form-control" id="operation_type" name="operation_type">
<option value="add">Add</option>
<option value="delete">Delete</option>
<option value="update">Update</option>
</select>
ID:<br>
<input type="text" name="_id" required><br>
Name:<br>
<input type="text" name="name" required><br>
Description:<br>
<input type="text" name="description" required><br>
Price:<br>
<input type="text" name="price" required><br>
<input type="submit">
</form>
</body>
</html>

84
app/static/blocks.css Normal file
View File

@@ -0,0 +1,84 @@
.pricing-table {
max-width: 368px;
margin: 0 auto;
transition: all .3s ease;
-o-transition: all .3s ease;
-moz-transition: all .3s ease;
-webkit-transition: all .3s ease;
border-radius: 0px;
}
.pricing-table:hover {
box-shadow: 0px 0px 30px rgba(0,0,0, .2);
}
.pricing-table:hover>.panel-footer-landing {
box-shadow: 0px 0px 30px rgba(0,0,0, .05) inset;
-webkit-transition: all .3s ease;
}
.pricing-table:hover>.panel>.panel-body-landing {
background: #5CB85C;
-webkit-transition: all .3s ease;
}
.pricing-table:hover>.panel>.panel-heading-landing-box {
background: #f0f0f0 !important;
color: #333 !important;
-webkit-transition: all .3s ease;
}
.pricing-table:hover>.panel>.controle-header {
background: #5CB85C !important;
/* border: solid 2px #5CB85C !important;*/
-webkit-transition: all .3s ease;
}
.pricing-table:hover>.panel>.panel-footer {
background: #5CB85C !important;
/* border: solid 2px #5CB85C !important;*/
-webkit-transition: all .3s ease;
}
.pricing-table:hover>.panel>.panel-footer>.btn {
border: solid 1px #fff !important;
-webkit-transition: all .3s ease;
}
.btn-price:hover {
background: #fff !important;
color: #5CB85C !important;
-webkit-transition: all .3s ease;
}
.pricing-table:hover>.panel>.controle-header>.panel-title-landing {
color: #fff !important;
-webkit-transition: all .3s ease;
}
.pricing-table:hover>.panel>.panel-body-landing>.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th {
color: #fff !important;
-webkit-transition: all .3s ease;
}
.panel-heading-landing {
background: #f7f7f7 !important;
padding: 20px !important;
border-top-left-radius: 10px !important;
border-top-right-radius: 10px !important;
border: solid 2px #5CB85C !important;
border-bottom: none !important;
}
.panel-heading-landing-box {
background: #5CB85C !important;
color: #fff !important;
font-size: 16px !important;
padding: 3px !important;
border: solid 2px #5CB85C !important;
border-top: none !important;
}
.panel-title-landing {
color: #626367 !important;
font-size: 25px;
font-weight: bold;
}
.panel-body-landing {
border: solid 2px #ccc !important;
border-top: none !important;
border-bottom: none !important;
}
.panel-footer-landing {
border: solid 2px #ccc !important;
border-bottom-left-radius: 10px !important;
border-bottom-right-radius: 10px !important;
border-top: none !important;
}

23
app/templates/cart.html Normal file
View File

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
<link rel="stylesheet" href="../blocks.css">
<title>Cart</title>
</head>
<body>
<div class="list-group">
{% for result in results %}
<a href="#" class="list-group-item">{{result.name}}</a>
{% endfor %}
</div>
</body>
</html>

64
app/templates/index.html Normal file
View File

@@ -0,0 +1,64 @@
<html>
<head><!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script></head>
<body>
<div class="container">
<h1>Welcome to Mini Amazon</h1>
<!--<div class="d-inline bg-success container">-->
<!--<a href="admin.html" >if you are an admin</a><br>-->
<!--<a href=search.html >if you want to search</a>-->
<!--</div>-->
<!--<div class="modal fade" id="myModal" role="dialog">-->
<!--<div class="modal-dialog">-->
<!--&lt;!&ndash; Modal content&ndash;&gt;-->
<!--<div class="modal-content">-->
<!--<div class="modal-header">-->
<!--<button type="button" class="close" data-dismiss="modal">&times;</button>-->
<!--<h4 class="modal-title">Error!</h4>-->
<!--</div>-->
<!--<div class="modal-body">-->
<!--<p>{{ message }}</p>-->
<!--</div>-->
<!--<div class="modal-footer">-->
<!--<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<b style="color:red"><h3>{{ message }}</h3></b>
<div class="panel panel-primary" style="width:300px; float:left; margin-right:20px">
<div class="panel-heading"><h2>Login</h2></div>
<div class="panel-body">
<form action="/api/user/login" method="POST">
Username: <input type="text" name="username" required><br>
Password: <input type="password" name="password" required><br><br>
<input type="submit" name="Login" class="btn btn-info btn-lg" required>
</form>
</div>
</div>
<b style="color:red"><h3>{{ user_exists_msg }}</h3></b>
<div class="panel panel-primary" style="width:300px; float:left; margin-right:20px">
<div class="panel-heading"><h2>Sign Up</h2></div>
<div class="panel-body">
<form action="/api/user/signup" method="POST">
Name: <input type="text" name="name" required><br>
Email: <input type="email" name="email" required><br>
Username: <input type="text" name="username" required><br>
Password: <input type="password" name="password" required><br><br>
<input type="submit" name="Sign Up!" class="btn btn-info btn-lg" required>
</form>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,11 @@
<b style="color:green"><h2>{{ sign_up_msg }}, {{ name }}</h2></b>
<header><b>You may perform a product search below:</b></header><br>
<div class="panel panel-primary">
<form action="/api/product" method="GET">
<input type="text" name="name" required/><br/><br/><br/>
<input type="text" name="output_type" value = "html" hidden/>
<input type="text" name="user_id" value = "{{ user_id }}" hidden/>
<input type="submit" name="Search">
</form>
</div>

View File

@@ -0,0 +1,93 @@
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
<link rel="stylesheet" href="../blocks.css">
<title>Search results</title>
</head>
<body>
<header>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="#">Mini Amazon</a>
<div class="collapse navbar-collapse" id="navbarCollapse">
<form class="form-inline mt-2 mt-md-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
</header>
<div class="container">
<h2>Found {{ results | length }} results for {{ query }}:</h2>
<br>
{% for result in results %}
<div class="col-md-12" style="margin-top: 20px;">
<div class="pricing-table">
<div class="panel panel-primary" style="border: none;">
<div class="controle-header panel-heading panel-heading-landing">
<h1 class="panel-title panel-title-landing">
{{result.name}}
</h1>
</div>
<div class="controle-panel-heading panel-heading panel-heading-landing-box">
</div>
<div class="panel-body panel-body-landing">
<table class="table">
<tr>
<td width="50px"><i class="fa fa-check"></i></td>
<td>{{result.name}}</td>
</tr>
<tr>
<td width="50px"><i class="fa fa-check"></i></td>
<td>{{result.description}}</td>
</tr>
<tr>
<td width="50px"><i class="fa fa-check"></i></td>
<td>{{result.price}}</td>
</tr>
</table>
</div>
<div class="panel-footer panel-footer-landing">
<a href="/api/cart/add?user_id={{user_id}}" class="btn btn-price btn-success btn-lg">ADD TO CART</a>
</div>
<div class="panel-body panel-body-landing">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="mohiit1502@gmail.com">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Hot Sauce-12oz. Bottle">
<input type="hidden" name="amount" value="5.95">
<input type="hidden" name="currency_code" value="INR">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
alt="Buy Now">
<img alt="" border="0" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</body>
</html>

38
app/templates/users.html Normal file
View File

@@ -0,0 +1,38 @@
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
<title>Users Manager</title>
</head>
<body>
<h2>Users {{ results | length }} displayed:</h2>
<br>
{% for result in results %}
<div class="panel panel-primary" style="width:300px; float:left; margin-right:10px">
<div class="panel-heading">{{result.name}}</div>
<form action="/api/product" method="POST">
<br><br>
Name:
<input type="text" name="name" value="{{result.name}}" required><br>
Username:
<input type="text" name="username" value="{{result.username}}" required><br>
Email:
<input type="text" name="email" value="{{result.email}}" required><br>
Password:
<input type="password" name="password" value="{{result.password}}" ><br>
<!--<input type="text" name="operation_type" value="delete" hidden />-->
<!--<input type="submit" value="update" >-->
<input type="submit" value="delete">
</form>
</div>
{% endfor %}
</body>
</html>

BIN
app/view1/._view1.html Normal file

Binary file not shown.

BIN
app/view1/._view1.js Normal file

Binary file not shown.

BIN
app/view1/._view1_test.js Normal file

Binary file not shown.

1
app/view1/view1.html Normal file
View File

@@ -0,0 +1 @@
<p>This is the partial for view 1.</p>

14
app/view1/view1.js Normal file
View File

@@ -0,0 +1,14 @@
'use strict';
angular.module('ngSocial.view1', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/view1', {
templateUrl: 'view1/view1.html',
controller: 'View1Ctrl'
});
}])
.controller('View1Ctrl', [function() {
}]);

16
app/view1/view1_test.js Normal file
View File

@@ -0,0 +1,16 @@
'use strict';
describe('myApp.view1 module', function() {
beforeEach(module('myApp.view1'));
describe('view1 controller', function(){
it('should ....', inject(function($controller) {
//spec body
var view1Ctrl = $controller('View1Ctrl');
expect(view1Ctrl).toBeDefined();
}));
});
});

BIN
app/view2/._view2.html Normal file

Binary file not shown.

BIN
app/view2/._view2.js Normal file

Binary file not shown.

BIN
app/view2/._view2_test.js Normal file

Binary file not shown.

5
app/view2/view2.html Normal file
View File

@@ -0,0 +1,5 @@
<p>This is the partial for view 2.</p>
<p>
Showing of 'interpolate' filter:
{{ 'Current version is v%VERSION%.' | interpolate }}
</p>

14
app/view2/view2.js Normal file
View File

@@ -0,0 +1,14 @@
'use strict';
angular.module('ngSocial.view2', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/view2', {
templateUrl: 'view2/view2.html',
controller: 'View2Ctrl'
});
}])
.controller('View2Ctrl', [function() {
}]);

16
app/view2/view2_test.js Normal file
View File

@@ -0,0 +1,16 @@
'use strict';
describe('myApp.view2 module', function() {
beforeEach(module('myApp.view2'));
describe('view2 controller', function(){
it('should ....', inject(function($controller) {
//spec body
var view2Ctrl = $controller('View2Ctrl');
expect(view2Ctrl).toBeDefined();
}));
});
});

7
app/views.py Normal file
View File

@@ -0,0 +1,7 @@
from mini_amazon import app
from flask import render_template
@app.route('/', methods=['GET'])
def index():
return render_template('index.html')

15
bower.json Normal file
View File

@@ -0,0 +1,15 @@
{
"name": "angular-seed",
"description": "A starter project for AngularJS",
"version": "0.0.0",
"homepage": "https://github.com/angular/angular-seed",
"license": "MIT",
"private": true,
"dependencies": {
"angular": "1.2.x",
"angular-route": "1.2.x",
"angular-loader": "1.2.x",
"angular-mocks": "~1.2.x",
"html5-boilerplate": "~4.3.0"
}
}

7
config.json Normal file
View File

@@ -0,0 +1,7 @@
{
"host":"0.0.0.0",
"port":5003,
"mongo_host":"localhost",
"mongo_port":27017,
"db_name":"mohit_amazon"
}

33
karma.conf.js Normal file
View File

@@ -0,0 +1,33 @@
module.exports = function(config){
config.set({
basePath : './',
files : [
'app/bower_components/angular/angular.js',
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/angular-mocks/angular-mocks.js',
'app/components/**/*.js',
'app/view*/**/*.js'
],
autoWatch : true,
frameworks: ['jasmine'],
browsers : ['Chrome'],
plugins : [
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-jasmine',
'karma-junit-reporter'
],
junitReporter : {
outputFile: 'test_out/unit.xml',
suite: 'unit'
}
});
};

34
package.json Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "angular-seed",
"private": true,
"version": "0.0.0",
"description": "A starter project for AngularJS",
"repository": "https://github.com/angular/angular-seed",
"license": "MIT",
"devDependencies": {
"karma": "~0.10",
"protractor": "^1.1.1",
"http-server": "^0.6.1",
"bower": "^1.3.1",
"shelljs": "^0.2.6",
"karma-junit-reporter": "^0.2.2"
},
"scripts": {
"postinstall": "bower install",
"prestart": "npm install",
"start": "http-server -a localhost -p 8000 -c-1",
"pretest": "npm install",
"test": "karma start karma.conf.js",
"test-single-run": "karma start karma.conf.js --single-run",
"preupdate-webdriver": "npm install",
"update-webdriver": "webdriver-manager update",
"preprotractor": "npm run update-webdriver",
"protractor": "protractor e2e-tests/protractor.conf.js",
"update-index-async": "node -e \"require('shelljs/global'); sed('-i', /\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/, '//@@NG_LOADER_START@@\\n' + sed(/sourceMappingURL=angular-loader.min.js.map/,'sourceMappingURL=bower_components/angular-loader/angular-loader.min.js.map','app/bower_components/angular-loader/angular-loader.min.js') + '\\n//@@NG_LOADER_END@@', 'app/index-async.html');\""
}
}

6
run.py Normal file
View File

@@ -0,0 +1,6 @@
from mini_amazon import app
import json
if __name__ == '__main__':
config = json.load(open('./config.json', 'r'))
app.run(config['host'], config['port'], debug=True, threaded=True)