Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Janusz Skonieczny committed May 29, 2014
1 parent c5d5053 commit 0fec54b
Show file tree
Hide file tree
Showing 15 changed files with 318 additions and 123 deletions.
13 changes: 13 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=======
Credits
=======

Development Lead
----------------

* Janus Skonieczny <[email protected]>

Contributors
------------

None yet. Why not be the first?
111 changes: 111 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
============
Contributing
============

Contributions are welcome, and they are greatly appreciated! Every
little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions
----------------------

Report Bugs
~~~~~~~~~~~

Report bugs at https://github.com/wooyek/flask-social-blueprint/issues.

If you are reporting a bug, please include:

* Your operating system name and version.
* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.

Fix Bugs
~~~~~~~~

Look through the GitHub issues for bugs. Anything tagged with "bug"
is open to whoever wants to implement it.

Implement Features
~~~~~~~~~~~~~~~~~~

Look through the GitHub issues for features. Anything tagged with "feature"
is open to whoever wants to implement it.

Write Documentation
~~~~~~~~~~~~~~~~~~~

Flask Social Blueprint could always use more documentation, whether as part of the
official Flask Social Blueprint docs, in docstrings, or even on the web in blog posts,
articles, and such.

Submit Feedback
~~~~~~~~~~~~~~~

The best way to send feedback is to file an issue at https://github.com/wooyek/flask-social-blueprint/issues.

If you are proposing a feature:

* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)

Get Started!
------------

Ready to contribute? Here's how to set up `flask-social-blueprint` for local development.

1. Fork the `flask-social-blueprint` repo on GitHub.
2. Clone your fork locally::

$ git clone [email protected]:your_name_here/flask-social-blueprint.git

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::

$ mkvirtualenv flask-social-blueprint
$ cd flask-social-blueprint/
$ python setup.py develop

4. Create a branch for local development::

$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.

5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox::

$ flake8 flask-social-blueprint tests
$ python setup.py test
$ tox

To get flake8 and tox, just pip install them into your virtualenv.

6. Commit your changes and push your branch to GitHub::

$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature

7. Submit a pull request through the GitHub website.

Pull Request Guidelines
-----------------------

Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check
https://travis-ci.org/wooyek/flask-social-blueprint/pull_requests
and make sure that the tests pass for all supported Python versions.

Tips
----

To run a subset of tests::

$ python -m unittest tests.test_flask-social-blueprint
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ flask-social-blueprint

An OAuth based authentication blueprint for flask. Easy to extend and override.

https://github.com/wooyek/flask-social-blueprint

## Demo

Based on `example/gae` codebase with secret `settings_prd.py` provided for
Expand Down Expand Up @@ -68,16 +70,22 @@ Done! No
This is just authentication blueprint there is no templates, models and stuff
that you would want to customize yourself.

## Examples

The example has a working model and templates, has a bunch of dependencies like
Flask-SLQAlchemy, you can take it as a wire frame modify and build your app
with that.

Examples are made from some existing apps, they may contain more stuff that's
really needed to showcase this module. When in trouble just ask questions.

Or just drop in this solution inside your working Flask app.
I should not create any conflicts with existing stuff. You maybe required to write
an adapter for your User model and SocialConnection model (or similar) but
that's 3 functions for the adapter. Any User model requirements come
from Flask_security.


## What to do more?

1. More providers
Expand Down
2 changes: 1 addition & 1 deletion example/gae/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,5 +245,5 @@ def init_app(app):
security = security.init_app(app, AppEngineUserDatastore(User, Role))
security.send_mail_task(send_mail)

from flask_social_blueprint import SocialBlueprint
from flask_social_blueprint.core import SocialBlueprint
SocialBlueprint.init_bp(app, SocialConnection, url_prefix="/_social")
2 changes: 1 addition & 1 deletion example/sqla/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,5 @@ def init_app(app):
security = security.init_app(app, SQLAlchemyUserDatastore(db, User, Role))
security.send_mail_task(send_mail)

from flask_social_blueprint import SocialBlueprint
from flask_social_blueprint.core import SocialBlueprint
SocialBlueprint.init_bp(app, SocialConnection, url_prefix="/_social")
6 changes: 3 additions & 3 deletions example/sqla/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
class InitDatabase(Command):
"""Initialize database"""
def run(self):
logging.debug("db.reate_all")
from website.database import db
db.create_all()
import website.database
website.database.init_db()


manager = Manager(app)
manager.add_command('initdb', InitDatabase())
Expand Down
30 changes: 30 additions & 0 deletions example/sqla/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# coding=utf-8
# Created 2014 by Janusz Skonieczny
import logging
import os
import tempfile
import unittest
import flask_social_blueprint

from main import app
from website import database


class TestFlaskSocialBlueprint(unittest.TestCase):
def setUp(self):
self.db_fd, self.db_file = tempfile.mkstemp()
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///" + self.db_file
self.app = app.test_client()
with app.app_context():
database.init_db()

def tearDown(self):
os.close(self.db_fd)
os.unlink(self.db_file)

def test_login_redirect(self):
# simple smoke test
rv = self.app.get('/')
logging.debug("rv: %s" % rv.headers)
self.assertEqual(302, rv.status_code)
assert rv.headers.get('Location').startswith("http://localhost/login")
6 changes: 6 additions & 0 deletions example/sqla/website/database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# coding=utf-8
# Created 2014 by Janusz Skonieczny
import logging
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()


def init_db():
logging.debug("db.create_all")
db.create_all()
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# extra development dependencies
pypandoc>=0.8.2
nose>=1.3.3
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Flask-Babel>=0.9
Flask-OAuth>=0.12
facebook-sdk>=0.4.0
google-api-python-client>=1.2
httplib2>=0.8
oauth2>=1.5.211
requests>=2.2.1
7 changes: 6 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[aliases]
rc = egg_info --tag-date --tag-build=.rc sdist
rtm = egg_info --tag-date --tag-build=.rtm sdist
rtm = egg_info --tag-date --tag-build=.rtm bdist

[egg_info]
tag_date = true

[wheel]
universal = 1
14 changes: 10 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# coding=utf-8
# Copyright 2014 Janusz Skonieczny

import sys
import os
from setuptools import setup, find_packages
from pip.req import parse_requirements
import pypandoc

install_requires = parse_requirements(os.path.join(os.path.dirname(__file__), "requires.txt"))
ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
SRC_DIR = os.path.join(ROOT_DIR, 'src')
sys.path.append(SRC_DIR)

import pypandoc
install_requires = parse_requirements(os.path.join(os.path.dirname(__file__), "requirements.txt"))
long_description = pypandoc.convert('README.md', 'rst', format='md')

from flask_social_blueprint import __version__ as version

setup_kwargs = {
'name': "flask-social-blueprint",
'version': "0.5.1",
'version': version,
'packages': find_packages("src"),
'package_dir': {'': 'src'},
'install_requires': [str(r.req) for r in install_requires],
Expand Down Expand Up @@ -40,6 +45,7 @@
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
'test_suite': 'flask_social_blueprint.tests.suite'
}

setup(**setup_kwargs)
Expand Down
Loading

0 comments on commit 0fec54b

Please sign in to comment.