Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ nosetests.xml
.DS_Store
sellerinfo.py
static/js/templates.js
.venv/
wordsmashing.db
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
wordsmashing
============

WordSmashing.com an online word search puzzle game and app
WordSmashing.com an online word search puzzle game and app.

Word Smashing uses Twitter Bootstrap, JQuery and Python running on the Google app engine.
The application now runs using a local SQLite database and can upload files to a Cloudflare R2 bucket using the S3 API.

dependencies are managed through pip ```pip install -r requirements.txt```
Dependencies are managed through pip:

```
pip install -r requirements.txt
```


81 changes: 0 additions & 81 deletions app.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions appengine_config.py

This file was deleted.

46 changes: 46 additions & 0 deletions database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import sqlite3
from contextlib import contextmanager

DB_PATH = os.environ.get('DATABASE_URL', os.path.join(os.path.dirname(__file__), 'wordsmashing.db'))


def init_db():
"""Create required tables if they do not exist."""
with sqlite3.connect(DB_PATH) as conn:
conn.execute(
'CREATE TABLE IF NOT EXISTS page_views (path TEXT PRIMARY KEY, count INTEGER NOT NULL)'
)
conn.commit()


@contextmanager
def get_db():
conn = sqlite3.connect(DB_PATH)
try:
yield conn
finally:
conn.close()


def record_page_view(path):
with get_db() as conn:
cur = conn.cursor()
cur.execute(
'INSERT INTO page_views(path, count) VALUES(?, 1) '
'ON CONFLICT(path) DO UPDATE SET count=count+1',
(path,),
)
conn.commit()


def get_page_views():
with get_db() as conn:
cur = conn.cursor()
cur.execute('SELECT path, count FROM page_views')
return dict(cur.fetchall())


def get_page_view(path):
return get_page_views().get(path, 0)

10 changes: 5 additions & 5 deletions fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,24 +206,24 @@ def set_hardness(self, h):
# 2 more
]

for i in xrange(len(EASY_LEVELS)):
for i in range(len(EASY_LEVELS)):
EASY_LEVELS[i].set_hardness(i)

for i in xrange(len(MEDIUM_LEVELS)):
for i in range(len(MEDIUM_LEVELS)):
MEDIUM_LEVELS[i].set_hardness(i + len(EASY_LEVELS))
MEDIUM_LEVELS[i].difficulty = MEDIUM

for i in xrange(len(HARD_LEVELS)):
for i in range(len(HARD_LEVELS)):
HARD_LEVELS[i].set_hardness(i + len(EASY_LEVELS) + len(MEDIUM_LEVELS))
HARD_LEVELS[i].difficulty = HARD

for i in xrange(len(EXPERT_LEVELS)):
for i in range(len(EXPERT_LEVELS)):
EXPERT_LEVELS[i].set_hardness(i + len(EASY_LEVELS) + len(MEDIUM_LEVELS) + len(HARD_LEVELS))
EXPERT_LEVELS[i].difficulty = EXPERT

LEVELS = EASY_LEVELS + MEDIUM_LEVELS + HARD_LEVELS + EXPERT_LEVELS

for i in xrange(len(LEVELS)):
for i in range(len(LEVELS)):
LEVELS[i].id = i + 1


Expand Down
44 changes: 0 additions & 44 deletions index.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions init_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Initialize the SQLite database."""
import database

if __name__ == '__main__':
database.init_db()
print('Database initialized at', database.DB_PATH)
19 changes: 13 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import json
import urllib

from google.appengine.ext import ndb
import logging
import webapp2
import jinja2

import fixtures
from gameon import gameon
from gameon.gameon_utils import GameOnUtils
from ws import ws
import database


FACEBOOK_APP_ID = "138831849632195"
Expand All @@ -25,6 +23,8 @@
loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
extensions=['jinja2.ext.autoescape'])

database.init_db()


class BaseHandler(webapp2.RequestHandler):

Expand All @@ -37,7 +37,6 @@ def render(self, view_name, extraParams={}):
'fixtures': fixtures,
'ws': ws,
'json': json,
'GameOnUtils': GameOnUtils,
# 'facebook_app_id': FACEBOOK_APP_ID,
# 'glogin_url': users.create_login_url(self.request.uri),
# 'glogout_url': users.create_logout_url(self.request.uri),
Expand All @@ -50,6 +49,7 @@ def render(self, view_name, extraParams={}):
template_values.update(extraParams)

template = JINJA_ENVIRONMENT.get_template(view_name)
database.record_page_view(self.request.path)
self.response.write(template.render(template_values))


Expand Down Expand Up @@ -189,12 +189,18 @@ def get(self):
self.response.write(template.render(template_values))


class StatsHandler(BaseHandler):
def get(self):
self.response.headers['Content-Type'] = 'application/json'
self.response.write(json.dumps(database.get_page_views()))


class SlashMurdererApp(webapp2.RequestHandler):
def get(self, url):
self.redirect(url)


app = ndb.toplevel(webapp2.WSGIApplication([
app = webapp2.WSGIApplication([
('/', MainHandler),
('(.*)/$', SlashMurdererApp),

Expand Down Expand Up @@ -223,5 +229,6 @@ def get(self, url):

('/buy', BuyHandler),
('/sitemap', SitemapHandler),
('/stats', StatsHandler),

] + gameon.routes, debug=ws.debug, config=config))
], debug=ws.debug, config=config)
77 changes: 6 additions & 71 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,71 +1,6 @@
Flask==0.10.1
Jinja2==2.7.1
MarkupSafe==0.18
PIL==1.1.7
PyRSS2Gen==1.1
Twisted==13.0.0
WebOb==1.2.3
WebTest==2.0.9
Werkzeug==0.9.4
altgraph==0.10.2
bdist-mpkg==0.4.4
beautifulsoup4==4.2.1
bonjour-py==0.3
cssselect==0.9
itsdangerous==0.23
lxml==3.2.3
macholib==1.5.1
mock==1.0.1
modulegraph==0.10.4
nose==1.3.0
numpy==1.7.1
py2app==0.7.3
pyOpenSSL==0.13
pyobjc-core==2.3.2a0
pyobjc-framework-AddressBook==2.3.2a0
pyobjc-framework-AppleScriptKit==2.3.2a0
pyobjc-framework-AppleScriptObjC==2.3.2a0
pyobjc-framework-Automator==2.3.2a0
pyobjc-framework-CFNetwork==2.3.2a0
pyobjc-framework-CalendarStore==2.3.2a0
pyobjc-framework-Cocoa==2.3.2a0
pyobjc-framework-Collaboration==2.3.2a0
pyobjc-framework-CoreData==2.3.2a0
pyobjc-framework-CoreLocation==2.3.2a0
pyobjc-framework-CoreText==2.3.2a0
pyobjc-framework-DictionaryServices==2.3.2a0
pyobjc-framework-ExceptionHandling==2.3.2a0
pyobjc-framework-FSEvents==2.3.2a0
pyobjc-framework-InputMethodKit==2.3.2a0
pyobjc-framework-InstallerPlugins==2.3.2a0
pyobjc-framework-InstantMessage==2.3.2a0
pyobjc-framework-InterfaceBuilderKit==2.3.2a0
pyobjc-framework-LatentSemanticMapping==2.3.2a0
pyobjc-framework-LaunchServices==2.3.2a0
pyobjc-framework-Message==2.3.2a0
pyobjc-framework-OpenDirectory==2.3.2a0
pyobjc-framework-PreferencePanes==2.3.2a0
pyobjc-framework-PubSub==2.3.2a0
pyobjc-framework-QTKit==2.3.2a0
pyobjc-framework-Quartz==2.3.2a0
pyobjc-framework-ScreenSaver==2.3.2a0
pyobjc-framework-ScriptingBridge==2.3.2a0
pyobjc-framework-SearchKit==2.3.2a0
pyobjc-framework-ServerNotification==2.3.2a0
pyobjc-framework-ServiceManagement==2.3.2a0
pyobjc-framework-SyncServices==2.3.2a0
pyobjc-framework-SystemConfiguration==2.3.2a0
pyobjc-framework-WebKit==2.3.2a0
pyobjc-framework-XgridFoundation==2.3.2a0
pyquery==1.2.6
python-dateutil==2.1
selenium==2.36.0
six==1.3.0
splinter==0.5.4
unittest2==0.5.1
vboxapi==1.0
virtualenv==1.10.1
waitress==0.8.7
wsgiref==0.1.2
xattr==0.6.4
zope.interface==4.0.5
webapp2==2.5.2
Jinja2>=3.1
WebTest>=3.0.0
boto3>=1.28
moto>=4.1
pytest>=7.0
Loading