diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..7222211
Binary files /dev/null and b/.DS_Store differ
diff --git a/AWSLambda/control_tv_lambda_call.py b/AWSLambda/control_tv_lambda_call.py
new file mode 100644
index 0000000..1efa4e1
--- /dev/null
+++ b/AWSLambda/control_tv_lambda_call.py
@@ -0,0 +1,272 @@
+
+from __future__ import print_function
+
+import json
+from uuid import uuid4
+import urllib.request
+import urllib.parse
+import jwt
+from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient
+import random, string
+import requests
+
+
+ALEXA_REQUEST_DISCOVER = "Alexa.Discovery"
+ALEXA_REQUEST_POWER = "Alexa.PowerController"
+ALEXA_REQUEST_CHANNEL = "Alexa.ChannelController"
+ALEXA_REQUEST_STEP_SPEAKER = "Alexa.StepSpeaker"
+ALEXA_REQUEST_PLAYBACK = "Alexa.PlaybackController"
+JWT_PASSWORD = "ENTER_YOUR_JWT_PASSWORD"
+
+CONTROL_TURN_ON = "TurnOn"
+CONTROL_TURN_OFF = "TurnOff"
+CONTROL_CHANGE_CHANNEL = "ChangeChannel"
+CONTROL_SKIP_CHANNEL = "SkipChannels"
+CONTROL_PLAY = "Play"
+CONTROL_PAUSE = "Pause"
+CONTROL_STOP = "Stop"
+CONTROL_ADJUST_VOLUME = "AdjustVolume"
+CONTROL_MUTE = "SetMute"
+
+
+def randomId():
+ letters = string.ascii_lowercase
+ return ''.join(random.choice(letters) for i in range(15))
+
+def sendMessage(topic, event, json_data):
+ jwt_token = event['directive']['endpoint']['scope']['token']
+ endpointid = event['directive']['endpoint']['endpointId']
+ data = jwt.decode(jwt_token, JWT_PASSWORD, algorithms=['HS256'])
+ json_data["operation"] = event['directive']['header']['name']
+ json_data["endpointid"] = endpointid
+ print(data)
+
+ myMQTTClient = AWSIoTMQTTClient(randomId(), useWebsocket=True)
+ myMQTTClient.configureEndpoint("afkx1f9takwol.iot.us-east-1.amazonaws.com", 443)
+ myMQTTClient.configureOfflinePublishQueueing(-1) # Infinite offline Publish queueing
+ myMQTTClient.configureDrainingFrequency(2) # Draining: 2 Hz
+ myMQTTClient.configureConnectDisconnectTimeout(4) # 10 sec
+ myMQTTClient.configureMQTTOperationTimeout(4)
+ myMQTTClient.configureCredentials("root.pem")
+ myMQTTClient.configureIAMCredentials("YOUR_IAM_ACCESS_KEY", "YOUR_IAM_SECRET_KEY")
+ myMQTTClient.connect()
+ response = myMQTTClient.publish(topic + '/' + data['device_uuid'] , json.dumps(json_data), 0)
+ myMQTTClient.disconnect()
+ print(topic)
+
+def lambda_handler(event, context):
+
+ if event['directive']['header']['namespace'] == ALEXA_REQUEST_DISCOVER:
+ return discover_device(event)
+
+ if event['directive']['header']['namespace'] == ALEXA_REQUEST_POWER:
+ return power_device(event)
+
+ if event['directive']['header']['namespace'] == ALEXA_REQUEST_CHANNEL:
+ return change_channel_device(event)
+
+ if event['directive']['header']['namespace'] == ALEXA_REQUEST_STEP_SPEAKER:
+ return step_speaker_device(event)
+
+ if event['directive']['header']['namespace'] == ALEXA_REQUEST_PLAYBACK:
+ return playback_device(event)
+ print('un supported control request')
+ return None
+
+
+def discover_device(event):
+ print('discover_device')
+ discovered_appliances = {
+ "endpoints": get_appliances(event)
+ }
+ return build_discover_response(event['directive']['header'], discovered_appliances)
+
+
+def get_appliances(event):
+ tvs = []
+
+ jwt_token = event['directive']['payload']['scope']['token']
+ data = jwt.decode(jwt_token, JWT_PASSWORD, algorithms=['HS256'])
+ headers = {'content-type': 'application/json', 'jwt':jwt_token}
+ payload ={"uuid": data['device_uuid']}
+ response = requests.post('https://alexasmarttv.dev/api/v1/get_devices', data=json.dumps(payload), headers=headers)
+ json_data = json.loads(response.text)
+
+ for tv in json_data['tvs']:
+ tvs.append(
+ {
+ "endpointId": tv['mac_address'],
+ "manufacturerName": "Samsung",
+ "displayCategories":[ "TV"],
+ "friendlyName": tv['name'],
+ "description":"Samsung Smart TV",
+ "capabilities": [
+ {
+ "type":"AlexaInterface",
+ "interface":ALEXA_REQUEST_STEP_SPEAKER,
+ "version":"1.0",
+ "properties":{
+ "supported":[
+ {
+ "name":CONTROL_ADJUST_VOLUME,
+ },
+ {
+ "name":CONTROL_MUTE
+ }
+ ]
+ }
+ },
+ {
+ "type":"AlexaInterface",
+ "interface":ALEXA_REQUEST_CHANNEL,
+ "version":"1.0",
+ "properties":{
+ "supported":[
+ {
+ "name":CONTROL_CHANGE_CHANNEL
+ },
+ {
+ "name":CONTROL_SKIP_CHANNEL
+ }
+ ]
+ }
+ },
+ {
+ "type":"AlexaInterface",
+ "interface":ALEXA_REQUEST_POWER,
+ "version":"1.0",
+ "properties":{
+ "supported":[
+ {
+ "name":CONTROL_TURN_OFF
+ },
+ {
+ "name": CONTROL_TURN_ON
+ }
+ ]
+ }
+ },
+ {
+ "type":"AlexaInterface",
+ "interface":ALEXA_REQUEST_PLAYBACK,
+ "version":"1.0",
+ "properties":{
+ "supported":[
+ {
+ "name":CONTROL_PLAY
+ },
+ {
+ "name": CONTROL_PAUSE
+ },
+ {
+ "name": CONTROL_STOP
+ }
+ ]
+ }
+ }
+ ],
+ "additionalApplianceDetails": {}
+ }
+ )
+ return tvs
+
+
+def build_discover_response(event_header, discovered_appliances):
+ header = {
+ "payloadVersion": event_header['payloadVersion'],
+ "namespace": event_header['namespace'],
+ "name": "Discover.Response",
+ "messageId": str(uuid4())
+ }
+ response = {
+ "event": {
+ "header": header,
+ "payload": discovered_appliances
+ }
+ }
+
+ return response
+
+
+def power_device(event):
+ print('power_device')
+ value = ""
+
+ if event['directive']['header']['name'] == CONTROL_TURN_ON:
+ sendMessage('power',event,{})
+ value = "ON"
+
+ if event['directive']['header']['name'] == CONTROL_TURN_OFF:
+ sendMessage('power',event,{})
+ value = "OFF"
+
+ properties = [{
+ "namespace": ALEXA_REQUEST_POWER,
+ "name": "powerState",
+ "value": value,
+ "uncertaintyInMilliseconds": 500
+ }]
+
+ return build_control_response(event, properties)
+
+def change_channel_device(event):
+ print('channel')
+ value = ""
+
+ if event['directive']['header']['name'] == CONTROL_CHANGE_CHANNEL:
+ sendMessage('channel',event,{"channel_data": event['directive']['payload']})
+ value = event['directive']['payload']['channel']
+
+ if event['directive']['header']['name'] == CONTROL_SKIP_CHANNEL:
+ sendMessage('channel',event,{"channelCount": event['directive']['payload']['channelCount']})
+ value = {"channel":{"number":"1","callSign":"unknown","affiliateCallSign":"unknown"}} #who knows what channel we are on
+
+ properties = [{
+ "namespace": ALEXA_REQUEST_CHANNEL,
+ "name": "channel",
+ "value": value,
+ "uncertaintyInMilliseconds": 500
+ }]
+
+ return build_control_response(event, properties)
+
+def step_speaker_device(event):
+ print('speaker')
+
+ if event['directive']['header']['name'] == CONTROL_MUTE:
+ sendMessage('speaker',event,{})
+
+ if event['directive']['header']['name'] == CONTROL_ADJUST_VOLUME:
+ sendMessage('speaker',event,{"volumeSteps": event['directive']['payload']['volumeSteps']})
+
+ properties = []
+
+ return build_control_response(event, properties)
+
+def playback_device(event):
+ print('playback')
+
+ if event['directive']['header']['name'] == CONTROL_PLAY or event['directive']['header']['name'] == CONTROL_PAUSE or event['directive']['header']['name'] == CONTROL_STOP:
+ sendMessage('playback',event,{})
+
+ properties = []
+
+ return build_control_response(event, properties)
+
+def build_control_response(event, properties):
+ response = {"event" :{
+ "header": {
+ "namespace":"Alexa",
+ "messageId": str(uuid4()),
+ "name": "Response",
+ "payloadVersion": event['directive']['header']['payloadVersion'],
+ "correlationToken": event['directive']['header']['correlationToken']
+ },
+ "endpoint":event["directive"]["endpoint"],
+ "payload": {}
+ },
+ "context":{"properties": properties}
+ }
+
+
+ return response
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/.gitignore b/AlexaSmartTVBackend_RubyOnRails/.gitignore
new file mode 100644
index 0000000..e9d79bb
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/.gitignore
@@ -0,0 +1,26 @@
+log/*.log
+**/*.spec.log
+db/*.sqlite3
+db/schema.rb
+tmp
+shared/log/*
+tmp/**/*
+public/assets/*
+public/cache/*
+public/images/themes/*
+public/javascripts/cache/*
+public/stylesheets/cache/*
+public/themes
+public/files/*
+*.swp
+vendor/engines/adva_rbac/spec/db/*.sqlite3
+vendor/engines/adva_rbac/spec/log/*
+.DS_Store
+*.so
+*.dylib
+*.o
+*.bundle
+Makefile
+*.out
+mkmf.log
+coverage.data
diff --git a/AlexaSmartTVBackend_RubyOnRails/Gemfile b/AlexaSmartTVBackend_RubyOnRails/Gemfile
new file mode 100644
index 0000000..71687d6
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/Gemfile
@@ -0,0 +1,50 @@
+source 'https://rubygems.org'
+
+gem 'letsencrypt_plugin'
+# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
+gem 'rails', '5.1.4'
+# Use sqlite3 as the database for Active Record
+gem 'sqlite3'
+# Use SCSS for stylesheets
+gem 'sass-rails', '~> 5.0'
+# Use Uglifier as compressor for JavaScript assets
+gem 'uglifier', '>= 1.3.0'
+# Use CoffeeScript for .coffee assets and views
+gem 'coffee-rails', '~> 4.2'
+# See https://github.com/rails/execjs#readme for more supported runtimes
+# gem 'therubyracer', platforms: :ruby
+gem 'puma', '~> 3.0'
+# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
+gem 'turbolinks'
+# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
+gem 'jbuilder', '~> 2.5'
+# bundle exec rake doc:rails generates the API under doc/api.
+gem 'sdoc', '~> 0.4.0', group: :doc
+gem 'bcrypt', '~> 3.1.7'
+gem 'jwt'
+gem 'aws-sdk-iot', '~> 1'
+gem 'json-schema'
+gem 'pg'
+gem 'rest-client'
+# Use ActiveModel has_secure_password
+# gem 'bcrypt', '~> 3.1.7'
+
+# Use Unicorn as the app server
+# gem 'unicorn'
+
+# Use Capistrano for deployment
+# gem 'capistrano-rails', group: :development
+
+group :development, :test do
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
+ gem 'byebug'
+end
+
+group :development do
+ # Access an IRB console on exception pages or by using <%= console %> in views
+ gem 'web-console', '~> 2.0'
+
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
+ gem 'spring'
+end
+
diff --git a/AlexaSmartTVBackend_RubyOnRails/Gemfile.lock b/AlexaSmartTVBackend_RubyOnRails/Gemfile.lock
new file mode 100644
index 0000000..35741a6
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/Gemfile.lock
@@ -0,0 +1,220 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ acme-client (0.6.1)
+ faraday (~> 0.9, >= 0.9.1)
+ actioncable (5.1.4)
+ actionpack (= 5.1.4)
+ nio4r (~> 2.0)
+ websocket-driver (~> 0.6.1)
+ actionmailer (5.1.4)
+ actionpack (= 5.1.4)
+ actionview (= 5.1.4)
+ activejob (= 5.1.4)
+ mail (~> 2.5, >= 2.5.4)
+ rails-dom-testing (~> 2.0)
+ actionpack (5.1.4)
+ actionview (= 5.1.4)
+ activesupport (= 5.1.4)
+ rack (~> 2.0)
+ rack-test (>= 0.6.3)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
+ actionview (5.1.4)
+ activesupport (= 5.1.4)
+ builder (~> 3.1)
+ erubi (~> 1.4)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
+ activejob (5.1.4)
+ activesupport (= 5.1.4)
+ globalid (>= 0.3.6)
+ activemodel (5.1.4)
+ activesupport (= 5.1.4)
+ activerecord (5.1.4)
+ activemodel (= 5.1.4)
+ activesupport (= 5.1.4)
+ arel (~> 8.0)
+ activesupport (5.1.4)
+ concurrent-ruby (~> 1.0, >= 1.0.2)
+ i18n (~> 0.7)
+ minitest (~> 5.1)
+ tzinfo (~> 1.1)
+ addressable (2.5.2)
+ public_suffix (>= 2.0.2, < 4.0)
+ arel (8.0.0)
+ aws-partitions (1.30.0)
+ aws-sdk-core (3.6.0)
+ aws-partitions (~> 1.0)
+ aws-sigv4 (~> 1.0)
+ jmespath (~> 1.0)
+ aws-sdk-iot (1.0.0)
+ aws-sdk-core (~> 3)
+ aws-sigv4 (~> 1.0)
+ aws-sigv4 (1.0.2)
+ bcrypt (3.1.11)
+ binding_of_caller (0.7.3)
+ debug_inspector (>= 0.0.1)
+ builder (3.2.3)
+ byebug (9.1.0)
+ coffee-rails (4.2.2)
+ coffee-script (>= 2.2.0)
+ railties (>= 4.0.0)
+ coffee-script (2.4.1)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.12.2)
+ concurrent-ruby (1.0.5)
+ crass (1.0.2)
+ debug_inspector (0.0.3)
+ domain_name (0.5.20170404)
+ unf (>= 0.0.5, < 1.0.0)
+ erubi (1.7.0)
+ execjs (2.7.0)
+ faraday (0.13.1)
+ multipart-post (>= 1.2, < 3)
+ ffi (1.9.18)
+ globalid (0.4.1)
+ activesupport (>= 4.2.0)
+ http-cookie (1.0.3)
+ domain_name (~> 0.5)
+ i18n (0.9.0)
+ concurrent-ruby (~> 1.0)
+ jbuilder (2.7.0)
+ activesupport (>= 4.2.0)
+ multi_json (>= 1.2)
+ jmespath (1.3.1)
+ json (1.8.6)
+ json-schema (2.8.0)
+ addressable (>= 2.4)
+ jwt (2.1.0)
+ letsencrypt_plugin (0.0.10)
+ acme-client (~> 0.6.1)
+ rails (>= 4.2)
+ loofah (2.1.1)
+ crass (~> 1.0.2)
+ nokogiri (>= 1.5.9)
+ mail (2.6.6)
+ mime-types (>= 1.16, < 4)
+ method_source (0.9.0)
+ mime-types (3.1)
+ mime-types-data (~> 3.2015)
+ mime-types-data (3.2016.0521)
+ mini_portile2 (2.3.0)
+ minitest (5.10.3)
+ multi_json (1.12.2)
+ multipart-post (2.0.0)
+ netrc (0.11.0)
+ nio4r (2.1.0)
+ nokogiri (1.8.1)
+ mini_portile2 (~> 2.3.0)
+ pg (0.21.0)
+ public_suffix (3.0.0)
+ puma (3.10.0)
+ rack (2.0.3)
+ rack-test (0.7.0)
+ rack (>= 1.0, < 3)
+ rails (5.1.4)
+ actioncable (= 5.1.4)
+ actionmailer (= 5.1.4)
+ actionpack (= 5.1.4)
+ actionview (= 5.1.4)
+ activejob (= 5.1.4)
+ activemodel (= 5.1.4)
+ activerecord (= 5.1.4)
+ activesupport (= 5.1.4)
+ bundler (>= 1.3.0)
+ railties (= 5.1.4)
+ sprockets-rails (>= 2.0.0)
+ rails-dom-testing (2.0.3)
+ activesupport (>= 4.2.0)
+ nokogiri (>= 1.6)
+ rails-html-sanitizer (1.0.3)
+ loofah (~> 2.0)
+ railties (5.1.4)
+ actionpack (= 5.1.4)
+ activesupport (= 5.1.4)
+ method_source
+ rake (>= 0.8.7)
+ thor (>= 0.18.1, < 2.0)
+ rake (12.1.0)
+ rb-fsevent (0.10.2)
+ rb-inotify (0.9.10)
+ ffi (>= 0.5.0, < 2)
+ rdoc (4.3.0)
+ rest-client (2.0.2)
+ http-cookie (>= 1.0.2, < 2.0)
+ mime-types (>= 1.16, < 4.0)
+ netrc (~> 0.8)
+ sass (3.5.2)
+ sass-listen (~> 4.0.0)
+ sass-listen (4.0.0)
+ rb-fsevent (~> 0.9, >= 0.9.4)
+ rb-inotify (~> 0.9, >= 0.9.7)
+ sass-rails (5.0.6)
+ railties (>= 4.0.0, < 6)
+ sass (~> 3.1)
+ sprockets (>= 2.8, < 4.0)
+ sprockets-rails (>= 2.0, < 4.0)
+ tilt (>= 1.1, < 3)
+ sdoc (0.4.2)
+ json (~> 1.7, >= 1.7.7)
+ rdoc (~> 4.0)
+ spring (2.0.2)
+ activesupport (>= 4.2)
+ sprockets (3.7.1)
+ concurrent-ruby (~> 1.0)
+ rack (> 1, < 3)
+ sprockets-rails (3.2.1)
+ actionpack (>= 4.0)
+ activesupport (>= 4.0)
+ sprockets (>= 3.0.0)
+ sqlite3 (1.3.13)
+ thor (0.20.0)
+ thread_safe (0.3.6)
+ tilt (2.0.8)
+ turbolinks (5.0.1)
+ turbolinks-source (~> 5)
+ turbolinks-source (5.0.3)
+ tzinfo (1.2.3)
+ thread_safe (~> 0.1)
+ uglifier (3.2.0)
+ execjs (>= 0.3.0, < 3)
+ unf (0.1.4)
+ unf_ext
+ unf_ext (0.0.7.5)
+ web-console (2.3.0)
+ activemodel (>= 4.0)
+ binding_of_caller (>= 0.7.2)
+ railties (>= 4.0)
+ sprockets-rails (>= 2.0, < 4.0)
+ websocket-driver (0.6.5)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ aws-sdk-iot (~> 1)
+ bcrypt (~> 3.1.7)
+ byebug
+ coffee-rails (~> 4.2)
+ jbuilder (~> 2.5)
+ json-schema
+ jwt
+ letsencrypt_plugin
+ pg
+ puma (~> 3.0)
+ rails (= 5.1.4)
+ rest-client
+ sass-rails (~> 5.0)
+ sdoc (~> 0.4.0)
+ spring
+ sqlite3
+ turbolinks
+ uglifier (>= 1.3.0)
+ web-console (~> 2.0)
+
+BUNDLED WITH
+ 1.15.4
diff --git a/AlexaSmartTVBackend_RubyOnRails/README.md b/AlexaSmartTVBackend_RubyOnRails/README.md
new file mode 100644
index 0000000..e62d115
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/README.md
@@ -0,0 +1,24 @@
+
+ ,-----.,--. ,--. ,---. ,--.,------. ,------.
+ ' .--./| | ,---. ,--.,--. ,-| || o \ | || .-. \ | .---'
+ | | | || .-. || || |' .-. |`..' | | || | \ :| `--,
+ ' '--'\| |' '-' '' '' '\ `-' | .' / | || '--' /| `---.
+ `-----'`--' `---' `----' `---' `--' `--'`-------' `------'
+ -----------------------------------------------------------------
+
+
+Welcome to your Rails project on Cloud9 IDE!
+
+To get started, just do the following:
+
+1. Run the project with the "Run Project" button in the menu bar on top of the IDE.
+2. Preview your new app by clicking on the URL that appears in the Run panel below (https://HOSTNAME/).
+
+Happy coding!
+The Cloud9 IDE team
+
+
+## Support & Documentation
+
+Visit http://docs.c9.io for support, or to learn more about using Cloud9 IDE.
+To watch some training videos, visit http://www.youtube.com/user/c9ide
diff --git a/AlexaSmartTVBackend_RubyOnRails/README.rdoc b/AlexaSmartTVBackend_RubyOnRails/README.rdoc
new file mode 100644
index 0000000..dd4e97e
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/README.rdoc
@@ -0,0 +1,28 @@
+== README
+
+This README would normally document whatever steps are necessary to get the
+application up and running.
+
+Things you may want to cover:
+
+* Ruby version
+
+* System dependencies
+
+* Configuration
+
+* Database creation
+
+* Database initialization
+
+* How to run the test suite
+
+* Services (job queues, cache servers, search engines, etc.)
+
+* Deployment instructions
+
+* ...
+
+
+Please feel free to use a different markup language if you do not plan to run
+rake doc:app.
diff --git a/AlexaSmartTVBackend_RubyOnRails/Rakefile b/AlexaSmartTVBackend_RubyOnRails/Rakefile
new file mode 100644
index 0000000..ba6b733
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/Rakefile
@@ -0,0 +1,6 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+
+Rails.application.load_tasks
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/assets/images/.keep b/AlexaSmartTVBackend_RubyOnRails/app/assets/images/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/alexa_login.coffee b/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/alexa_login.coffee
new file mode 100644
index 0000000..24f83d1
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/alexa_login.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/application.js b/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/application.js
new file mode 100644
index 0000000..48ae006
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/application.js
@@ -0,0 +1,16 @@
+// This is a manifest file that'll be compiled into application.js, which will include all the files
+// listed below.
+//
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
+// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
+//
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// compiled file.
+//
+// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
+// about supported directives.
+//
+//= require turbolinks
+//= require_tree .
+
+
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/home.js b/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/home.js
new file mode 100644
index 0000000..c37e94a
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/home.js
@@ -0,0 +1,9 @@
+
+
+
+$(document).on("click", "#delete_submit", function(event){
+ if(!confirm("Are you sure you want to delete this device? This device will appear again if it comes back online.")){
+ event.preventDefault();
+ return false;
+ }
+});
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/profile.js b/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/profile.js
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/tutorial.js b/AlexaSmartTVBackend_RubyOnRails/app/assets/javascripts/tutorial.js
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/alexa_login.scss b/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/alexa_login.scss
new file mode 100644
index 0000000..c3cf695
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/alexa_login.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the alexa_login controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/application.css b/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/application.css
new file mode 100644
index 0000000..d6ade35
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/application.css
@@ -0,0 +1,83 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
+ * compiled file so the styles you add here take precedence over styles defined in any styles
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
+ * file per style scope.
+ *
+ *= require_tree .
+ *= require_self
+ */
+
+.page-color {
+ background-color: #373B44;
+}
+
+.container-color {
+ background-color: #FFFFFF;
+}
+
+.navbar-color {
+ background-color: #E1B866;
+}
+
+.dark-color {
+ color: #373B44;
+}
+
+.highlight-color {
+ color: #BD5532
+}
+
+.accent-color {
+ color: #E1B866
+}
+
+.light-color{
+ color: #DEE1B6;
+}
+
+.base-color{
+ color: #73C8A9;
+}
+
+.vertical-center {
+ display: inline-block;
+ vertical-align:middle;
+ float:none;
+}
+
+.horizontal-center{
+ float:none;
+ margin:0 auto;
+}
+
+div .inner-yield{
+ padding: 0 30px 20px 30px;
+}
+
+#circle_red {
+ width: 10px;
+ height: 10px;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px;
+ background: crimson;
+ display: inline-block;
+ }
+
+
+#circle_green {
+ width: 10px;
+ height: 10px;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px;
+ background: green;
+ display: inline-block;
+ }
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/home.scss b/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/home.scss
new file mode 100644
index 0000000..f0ddc68
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/home.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the home controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/profile.scss b/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/profile.scss
new file mode 100644
index 0000000..ffbfb7e
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/profile.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the profile controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/tutorial.scss b/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/tutorial.scss
new file mode 100644
index 0000000..d1b39ac
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/assets/stylesheets/tutorial.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the tutorial controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/certs/rootcert.key b/AlexaSmartTVBackend_RubyOnRails/app/certs/rootcert.key
new file mode 100644
index 0000000..48f647d
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/certs/rootcert.key
@@ -0,0 +1 @@
+[YOUR ROOT CERT GOES HERE]
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/certs/rootcert.pem b/AlexaSmartTVBackend_RubyOnRails/app/certs/rootcert.pem
new file mode 100644
index 0000000..48f647d
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/certs/rootcert.pem
@@ -0,0 +1 @@
+[YOUR ROOT CERT GOES HERE]
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/alexa_login_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/alexa_login_controller.rb
new file mode 100644
index 0000000..b0142a9
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/alexa_login_controller.rb
@@ -0,0 +1,31 @@
+class AlexaLoginController < ApplicationController
+ skip_before_action :authenticate_user
+ layout 'root'
+
+ def index
+ @state = params[:state]
+ @redirect_uri = params[:redirect_uri]
+ end
+
+ def create
+
+ user = User.find_by_email(params[:email].strip.downcase)
+ if user!= nil and user.authenticate(params[:password])
+ if user.devices.count == 0
+ redirect_to '/alexa_login?state=' + params[:state] + '&redirect_uri=' + params[:redirect_uri], :flash => { :error => "This account does not have any devices registered with it." }
+ elsif user.devices.count > 1
+ jwt_payload = {user_id: user.id}
+ token = JWT.encode jwt_payload, Rails.application.secrets[:jwt_key], 'HS256'
+ redirect_to '/choose_device?jwt=' + token + '&redirect_uri=' + params[:redirect_uri] + '&state=' + params[:state]
+ else
+ jwt_payload = {user_id: user.id, device_uuid: user.devices.where(deleted: false).first.uuid}
+ token = JWT.encode jwt_payload, Rails.application.secrets[:jwt_key], 'HS256'
+ redirect_to params[:redirect_uri] + '?state=' + params[:state] + '&code=' + token#, :overwrite_params => { :state => params[:state], :code => token}
+
+ end
+ else
+ redirect_to '/alexa_login?state=' + params[:state] + '&redirect_uri=' + params[:redirect_uri], :flash => { :error => "Incorrect Username or Password" }
+ end
+
+ end
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/auth_token_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/auth_token_controller.rb
new file mode 100644
index 0000000..4147397
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/auth_token_controller.rb
@@ -0,0 +1,7 @@
+class Api::V1::AuthTokenController < ApiController
+ skip_before_action :authenticate_user
+
+ def create
+ render json: {access_token: params[:code], token_type: 'Bearer'}
+ end
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/delete_device_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/delete_device_controller.rb
new file mode 100644
index 0000000..bcbf931
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/delete_device_controller.rb
@@ -0,0 +1,10 @@
+class Api::V1::DeleteDeviceController < ApiController
+
+
+ def create
+ device = @user.devices.find_by_uuid!(params[:uuid])
+
+ render json: {status: 200}
+ end
+
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/get_devices_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/get_devices_controller.rb
new file mode 100644
index 0000000..815e1db
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/get_devices_controller.rb
@@ -0,0 +1,10 @@
+class Api::V1::GetDevicesController < ApiController
+
+ def create
+ device = @user.devices.find_by_uuid!(params[:uuid])
+
+
+ render json: {tvs: device.tvs.as_json(:except => [:created_at, :updated_at, :device_id])}
+ end
+
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/login_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/login_controller.rb
new file mode 100644
index 0000000..3ad543d
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/login_controller.rb
@@ -0,0 +1,16 @@
+class Api::V1::LoginController < ApiController
+ skip_before_action :authenticate_user
+
+ def create
+ user = User.find_by_email(params[:email].strip.downcase)
+ if user!= nil and user.authenticate(params[:password])
+ jwt_payload = {user_id: user.id}
+ token = JWT.encode jwt_payload, Rails.application.secrets[:jwt_key], 'HS256'
+ render json: {jwt: token}
+ else
+ render json: ErrorGen.create_error(401,'Username or password is incorrect')
+
+ end
+ end
+
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/ping_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/ping_controller.rb
new file mode 100644
index 0000000..01260d8
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/ping_controller.rb
@@ -0,0 +1,11 @@
+class Api::V1::PingController < ApiController
+
+ def create
+ device = @user.devices.find_by_uuid!(params[:uuid])
+ device.touch(:last_pinged)
+ device.deleted = false
+ device.save
+ render json: {status: 200}
+ end
+
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/register_device_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/register_device_controller.rb
new file mode 100644
index 0000000..bd4fe75
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api/v1/register_device_controller.rb
@@ -0,0 +1,130 @@
+require 'openssl'
+require 'aws-sdk-iot'
+
+class Api::V1::RegisterDeviceController < ApiController
+
+
+ def create
+ if params[:uuid]
+ device = @user.devices.find_by_uuid!(params[:uuid])
+ private_key = device.private_key
+ pubic_certificate = device.pubic_certificate
+ uuid = device.uuid
+ device.name = params[:name]
+ device.user_id = @data[0]['user_id']
+ device.save
+ else
+ uuid = SecureRandom.uuid
+
+ Aws.config.update({
+ region: 'us-east-1',
+ credentials: Aws::Credentials.new('[YOUR_AWS_ACCESS_KEY]', '[YOUR_AWS_SECRET]')
+ })
+
+ root_ca = OpenSSL::X509::Certificate.new File.read(File.join(Rails.root, 'app','certs','rootcert.pem'))
+ root_key = OpenSSL::PKey::RSA.new File.read(File.join(Rails.root, 'app','certs','rootcert.key'))
+
+ device_key = OpenSSL::PKey::RSA.new 2048
+ cert = OpenSSL::X509::Certificate.new
+ cert.version = 2
+ cert.serial = 2
+ cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby certificate"
+ cert.issuer = root_ca.subject # root CA is the issuer
+ cert.public_key = device_key.public_key
+ cert.not_before = Time.now
+ cert.not_after = cert.not_before + 5000 * 365 * 24 * 60 * 60 # 5000 years validity. Can never be too careful... (im to lazy to implement reauth)
+ ef = OpenSSL::X509::ExtensionFactory.new
+ ef.subject_certificate = cert
+ ef.issuer_certificate = root_ca
+ cert.add_extension(ef.create_extension("keyUsage","digitalSignature", true))
+ cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false))
+ cert.sign(root_key, OpenSSL::Digest::SHA256.new)
+ device_and_CA = cert.to_s + root_ca.to_s
+
+ iot_client = Aws::IoT::Client.new
+ cert_resp = iot_client.register_certificate({
+ certificate_pem: cert.to_s,
+ set_as_active: root_ca.to_s,
+ status: "ACTIVE",
+ })
+
+ policy = "{
+ \"Version\": \"2012-10-17\",
+ \"Statement\": [
+ {
+ \"Effect\": \"Allow\",
+ \"Action\": \"iot:Connect\",
+ \"Resource\": \"arn:aws:iot:us-east-1:141651249291:client\/#{uuid}\"
+ },
+ {
+ \"Effect\": \"Allow\",
+ \"Action\": \"iot:Subscribe\",
+ \"Resource\": \"arn:aws:iot:us-east-1:141651249291:topicfilter\/power\/#{uuid}\"
+ },
+ {
+ \"Effect\": \"Allow\",
+ \"Action\": \"iot:Receive\",
+ \"Resource\": \"arn:aws:iot:us-east-1:141651249291:topic\/power\/#{uuid}\"
+ },
+ {
+ \"Effect\": \"Allow\",
+ \"Action\": \"iot:Subscribe\",
+ \"Resource\": \"arn:aws:iot:us-east-1:141651249291:topicfilter\/channel\/#{uuid}\"
+ },
+ {
+ \"Effect\": \"Allow\",
+ \"Action\": \"iot:Receive\",
+ \"Resource\": \"arn:aws:iot:us-east-1:141651249291:topic\/channel\/#{uuid}\"
+ },
+ {
+ \"Effect\": \"Allow\",
+ \"Action\": \"iot:Subscribe\",
+ \"Resource\": \"arn:aws:iot:us-east-1:141651249291:topicfilter\/speaker\/#{uuid}\"
+ },
+ {
+ \"Effect\": \"Allow\",
+ \"Action\": \"iot:Receive\",
+ \"Resource\": \"arn:aws:iot:us-east-1:141651249291:topic\/speaker\/#{uuid}\"
+ },
+ {
+ \"Effect\": \"Allow\",
+ \"Action\": \"iot:Subscribe\",
+ \"Resource\": \"arn:aws:iot:us-east-1:141651249291:topicfilter\/playback\/#{uuid}\"
+ },
+ {
+ \"Effect\": \"Allow\",
+ \"Action\": \"iot:Receive\",
+ \"Resource\": \"arn:aws:iot:us-east-1:141651249291:topic\/playback\/#{uuid}\"
+ }
+ ]
+ }"
+
+ policy_name = uuid + '_policy'
+
+ policy_resp = iot_client.create_policy({
+ policy_name: policy_name,
+ policy_document: policy
+ })
+
+
+ attach_resp = iot_client.attach_principal_policy({
+ policy_name: policy_name, # required
+ principal: cert_resp.certificate_arn # required
+ })
+
+ private_key = device_key.to_s
+ pubic_certificate = device_and_CA
+
+ device = @user.devices.create!(uuid: uuid, private_key: private_key, pubic_certificate: pubic_certificate, name: params[:name], last_pinged: Time.now())
+ end
+
+ device.tvs.delete_all
+
+ params[:tvs].each{|tv|
+ device.tvs.create!(name: tv[:name], mac_address: tv[:mac_address])
+ }
+
+ render json: {uuid: uuid, private_key: private_key, pubic_certificate: pubic_certificate}
+ end
+
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/api_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api_controller.rb
new file mode 100644
index 0000000..4f7daa0
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/api_controller.rb
@@ -0,0 +1,68 @@
+class ApiController < ActionController::API
+ before_action :authenticate_user
+ before_action :validate_schema, only: [:create]
+
+
+ rescue_from StandardError do |exception|
+ my_logger.error("error: #{exception.to_s}")
+ my_logger.error("backtrace: #{exception.backtrace.join("\n")}")
+
+ if Rails.env.production?
+ render :json => ErrorGen.create_error(500,'an unknown error occurred')
+ else
+ render :json => ErrorGen.create_error(500,exception.to_s)
+ end
+
+ end
+
+
+ rescue_from ActiveRecord::RecordNotFound do |exception|
+ my_logger.error("error: #{exception.to_s}")
+
+ if Rails.env.production?
+ render :json => ErrorGen.create_error(404,'item not found')
+ else
+ render :json => ErrorGen.create_error(404,exception.to_s)
+ end
+ end
+
+
+ def my_logger
+ @@my_logger ||= Logger.new("#{Rails.root}/log/#{Rails.env.to_s}_errors.log")
+ end
+
+
+ def authenticate_user
+ begin
+ @data = JWT.decode request.headers['jwt'], Rails.application.secrets[:jwt_key], true, { :algorithm => 'HS256' }
+ @user = User.find_by_id!(@data[0]['user_id'])
+
+ rescue => exception
+ # Handle invalid token
+ my_logger.error("error: #{exception.to_s}")
+
+ if Rails.env.production?
+ render :json => ErrorGen.create_error(401,'invalid session')
+ else
+ render :json => ErrorGen.create_error(401,exception.to_s)
+ end
+ false
+ end
+ end
+
+
+ def validate_schema
+ if not JSON::Validator.validate(SchemaValidator.get_schema(controller_name), params.as_json)
+ if Rails.env.production?
+ my_logger.error("error: #{controller_name}")
+ render :json => ErrorGen.create_error(400,'invalid input')
+ else
+ error = JSON::Validator.fully_validate(SchemaValidator.get_schema(controller_name), params.as_json).to_s
+ my_logger.error("error: #{error}")
+ render :json => ErrorGen.create_error(400,'input json did not match schema: ' + error)
+ end
+ false
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/application_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/application_controller.rb
new file mode 100644
index 0000000..893e2b1
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/application_controller.rb
@@ -0,0 +1,27 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery with: :exception
+ before_action :authenticate_user
+
+ def my_logger
+ @@my_logger ||= Logger.new("#{Rails.root}/log/#{Rails.env.to_s}_errors.log")
+ end
+
+
+ def authenticate_user
+ if not cookies[:jwt]
+ redirect_to "/login"
+ else
+ begin
+ @data = JWT.decode cookies[:jwt], Rails.application.secrets[:jwt_key], true, { :algorithm => 'HS256' }
+ @user = User.find_by_id!(@data[0]['user_id'])
+ rescue => exception
+ # Handle invalid token
+ cookies.delete :jwt
+ my_logger.error("error: #{exception.to_s}")
+ redirect_to "/login", :flash => { :error => "Invalid Session" }
+ end
+ end
+ end
+
+
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/choose_device_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/choose_device_controller.rb
new file mode 100644
index 0000000..14d57fb
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/choose_device_controller.rb
@@ -0,0 +1,42 @@
+class ChooseDeviceController < ApplicationController
+ skip_before_action :authenticate_user
+ layout 'root'
+
+
+ def index
+ @state = params[:state]
+ @redirect_uri = params[:redirect_uri]
+ @jwt = params[:jwt]
+ begin
+ data = JWT.decode params[:jwt], Rails.application.secrets[:jwt_key], true, { :algorithm => 'HS256' }
+ user = User.find_by_id!(data[0]['user_id'])
+ @devices = user.devices.where(:deleted => false).order(:created_at)
+
+ rescue => exception
+ # Handle invalid token
+ cookies.delete :jwt
+ my_logger.error("error: #{exception.to_s}")
+ redirect_to "/alexa_login?state=" + params[:state] + '&redirect_uri=' + params[:redirect_uri], :flash => { :error => "Invalid Session" }
+ end
+ end
+
+
+ def create
+ begin
+ data = JWT.decode params[:jwt], Rails.application.secrets[:jwt_key], true, { :algorithm => 'HS256' }
+ user = User.find_by_id!(data[0]['user_id'])
+
+ device = user.devices.find_by_uuid!(params[:id])
+ jwt_payload = {user_id: user.id, device_uuid: device.uuid}
+ token = JWT.encode jwt_payload, Rails.application.secrets[:jwt_key], 'HS256'
+ redirect_to params[:redirect_uri] + '?state=' + params[:state] + '&code=' + token
+ rescue => exception
+ # Handle invalid token
+ cookies.delete :jwt
+ my_logger.error("error: #{exception.to_s}")
+ redirect_to "/alexa_login?state=" + params[:state] + '&redirect_uri=' + params[:redirect_uri], :flash => { :error => "Invalid Session" }
+ end
+
+ end
+
+end
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/concerns/.keep b/AlexaSmartTVBackend_RubyOnRails/app/controllers/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/create_account_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/create_account_controller.rb
new file mode 100644
index 0000000..e3f453e
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/create_account_controller.rb
@@ -0,0 +1,30 @@
+class CreateAccountController < ApplicationController
+ skip_before_action :authenticate_user
+ layout 'root'
+
+ def index
+ end
+
+ def create
+ if User.find_by_email(params[:email])
+ redirect_to '/create_account', :flash => { :error => "Email already in use" }
+ elsif !isEmail(params[:email])
+ redirect_to '/create_account', :flash => { :error => "Invalid Email" }
+ elsif params[:password] != params[:c_password]
+ redirect_to '/create_account', :flash => { :error => "Passwords do not match" }
+ else
+ user = User.create!(email: params[:email].downcase, first_name: params[:first_name], last_name: params[:last_name], password: params[:password])
+ jwt_payload = {user_id: user.id}
+ token = JWT.encode jwt_payload, Rails.application.secrets[:jwt_key], 'HS256'
+ cookies[:jwt] = { :value => token, :expires => 3.months.from_now }
+ redirect_to '/'
+ end
+ end
+
+
+
+ def isEmail(str)
+ return str.match(/\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i)
+ end
+
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/forgot_password_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/forgot_password_controller.rb
new file mode 100644
index 0000000..dc90243
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/forgot_password_controller.rb
@@ -0,0 +1,46 @@
+class ForgotPasswordController < ApplicationController
+ skip_before_action :authenticate_user
+ layout 'root'
+
+ def index
+ end
+
+ def create
+ user = User.find_by_email(params[:email])
+ if user
+ reset_password(user)
+ end
+
+ redirect_to '/forgot_password', :flash => { :message => "If this user exists, a reset email password has been sent." }
+ end
+
+
+
+
+ def reset_password(user)
+ password = (0...15).map { ('a'..'z').to_a[rand(26)] }.join
+ user.password = password
+ user.save
+ RestClient.post "https://api.sendgrid.com/v3/mail/send", {
+ "personalizations": [
+ {
+ "to": [
+ {
+ "email": user.email
+ }
+ ]
+ }
+ ],
+ "from": {
+ "email": "forgotpassword@alexasmarttv.dev"
+ },
+ "subject": "Alexa Smart TV password reset",
+ "content": [
+ {
+ "type": "text/plain",
+ "value": "Hello,\n\nWe have generated a temporary password for you. Please go to alexasmarttv.dev/profile and change it. \n\nTemporary Password: " + password
+ }
+ ]
+ }.to_json, {content_type: :json, accept: :json, Authorization: 'Bearer [YOUR_SENDGRID_API_KEY]'}
+ end
+end
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/home_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/home_controller.rb
new file mode 100644
index 0000000..c83345e
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/home_controller.rb
@@ -0,0 +1,14 @@
+class HomeController < ApplicationController
+ def index
+ @devices = @user.devices.where(:deleted => false).order(:created_at)
+ end
+
+
+ def delete
+ device = @user.devices.find_by_uuid!(params[:id])
+ device.deleted = true
+ device.save
+ redirect_to '/'
+ end
+
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/login_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/login_controller.rb
new file mode 100644
index 0000000..ca62e3f
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/login_controller.rb
@@ -0,0 +1,23 @@
+class LoginController < ApplicationController
+ skip_before_action :authenticate_user
+ layout 'root'
+
+
+ def index
+
+ end
+
+
+ def create
+ user = User.find_by_email(params[:email].strip.downcase)
+ if user!= nil and user.authenticate(params[:password])
+ jwt_payload = {user_id: user.id}
+ token = JWT.encode jwt_payload, Rails.application.secrets[:jwt_key], 'HS256'
+ cookies[:jwt] = { :value => token, :expires => 3.months.from_now }
+ redirect_to '/'
+ else
+ redirect_to '/login', :flash => { :error => "Incorrect Username or Password" }
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/logout_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/logout_controller.rb
new file mode 100644
index 0000000..ee3916a
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/logout_controller.rb
@@ -0,0 +1,8 @@
+class LogoutController < ApplicationController
+skip_before_action :authenticate_user
+
+ def index
+ cookies.delete :jwt
+ redirect_to '/login'
+ end
+end
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/privacy_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/privacy_controller.rb
new file mode 100644
index 0000000..8223e8c
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/privacy_controller.rb
@@ -0,0 +1,11 @@
+class PrivacyController < ApplicationController
+ skip_before_action :authenticate_user
+ layout 'root'
+
+
+ def index
+ end
+
+
+
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/profile_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/profile_controller.rb
new file mode 100644
index 0000000..17f7015
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/profile_controller.rb
@@ -0,0 +1,38 @@
+class ProfileController < ApplicationController
+ def index
+ @email = @user.email
+ end
+
+
+
+ def create
+ if params[:email]
+ if !isEmail(params[:email])
+ redirect_to '/profile', :flash => { :error => "Invalid Email" }
+ else
+ @user.email = params[:email]
+ @user.save
+ redirect_to '/profile', :flash => { :message => "Email Updated" }
+ end
+ end
+
+ if params[:password] and params[:cpassword]
+ if params[:password] != params[:cpassword]
+ redirect_to '/profile', :flash => { :error => "Passwords do not match" }
+ else
+ @user.password = params[:password]
+ @user.save
+ redirect_to '/profile', :flash => { :message => "Password Updated" }
+ end
+ end
+
+ end
+
+
+
+ def isEmail(str)
+ return str.match(/\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i)
+ end
+
+
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/controllers/tutorial_controller.rb b/AlexaSmartTVBackend_RubyOnRails/app/controllers/tutorial_controller.rb
new file mode 100644
index 0000000..637def4
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/controllers/tutorial_controller.rb
@@ -0,0 +1,5 @@
+class TutorialController < ApplicationController
+ def index
+
+ end
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/helpers/application_helper.rb b/AlexaSmartTVBackend_RubyOnRails/app/helpers/application_helper.rb
new file mode 100644
index 0000000..de6be79
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/helpers/error_gen.rb b/AlexaSmartTVBackend_RubyOnRails/app/helpers/error_gen.rb
new file mode 100644
index 0000000..58c2a28
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/helpers/error_gen.rb
@@ -0,0 +1,5 @@
+class ErrorGen
+ def self.create_error(status, message)
+ {error:{status:status, message: message}}
+ end
+end
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/helpers/schema_validator.rb b/AlexaSmartTVBackend_RubyOnRails/app/helpers/schema_validator.rb
new file mode 100644
index 0000000..61ed1a8
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/helpers/schema_validator.rb
@@ -0,0 +1,65 @@
+class SchemaValidator
+
+ @@schemas = {
+ 'login':
+ {
+ :type => 'object',
+ :required => ['email','password'],
+ :properties => {
+ :email => {:type => 'string'},
+ :password => {:type => 'string'}
+ }
+ },
+ 'register_device':
+ {
+ :type => 'object',
+ :required => ['name','tvs'],
+ :properties => {
+ :name => {:type => 'string'},
+ :tvs => {:type => 'array',
+ 'items':{
+ :type => 'object',
+ :required => ['name','mac_address'],
+ :properties => {
+ :name => {:type => 'string'},
+ :mac_address => {:type => 'string'}
+ }
+ }
+ },
+ :uuid => {:type => 'string'}
+ }
+ },
+ 'ping':
+ {
+ :type => 'object',
+ :required => ['uuid'],
+ :properties => {
+ :uuid => {:type => 'string'}
+ }
+ },
+ 'get_devices':
+ {
+ :type => 'object',
+ :required => ['uuid'],
+ :properties => {
+ :uuid => {:type => 'string'}
+ }
+ },
+ 'auth_token':
+ {
+ :type => 'object',
+ :required => ['code'],
+ :properties => {
+ :code => {:type => 'string'},
+ :grant_type => {:type => 'string'},
+ :redirect_uri => {:type => 'string'},
+ :client_id => {:type => 'string'}
+ }
+ }
+
+ }
+
+ def self.get_schema(route)
+ @@schemas[route.to_sym]
+ end
+end
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/mailers/.keep b/AlexaSmartTVBackend_RubyOnRails/app/mailers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/models/.keep b/AlexaSmartTVBackend_RubyOnRails/app/models/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/models/concerns/.keep b/AlexaSmartTVBackend_RubyOnRails/app/models/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/models/device.rb b/AlexaSmartTVBackend_RubyOnRails/app/models/device.rb
new file mode 100644
index 0000000..d1b7e34
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/models/device.rb
@@ -0,0 +1,5 @@
+class Device < ActiveRecord::Base
+ belongs_to :user
+ has_many :tvs
+
+end
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/models/tv.rb b/AlexaSmartTVBackend_RubyOnRails/app/models/tv.rb
new file mode 100644
index 0000000..d632398
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/models/tv.rb
@@ -0,0 +1,3 @@
+class Tv < ActiveRecord::Base
+ belongs_to :device
+end
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/models/user.rb b/AlexaSmartTVBackend_RubyOnRails/app/models/user.rb
new file mode 100644
index 0000000..44ae95f
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/models/user.rb
@@ -0,0 +1,5 @@
+require 'csv'
+class User < ActiveRecord::Base
+ has_many :devices
+ has_secure_password
+end
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/views/alexa_login/index.html.erb b/AlexaSmartTVBackend_RubyOnRails/app/views/alexa_login/index.html.erb
new file mode 100644
index 0000000..db411bc
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/views/alexa_login/index.html.erb
@@ -0,0 +1,27 @@
+
+
+
SMART TV ACCOUNT LINKING
+
This app REQUIRES a raspberry pi running on your network already running the Custom Smart TV software. Unfortunately this is required and if you do not have this setup this app will not work for you.
+
+ This login is for your Custom Smart TV account. This is NOT for your Amazon, Alexa, or Samsung account. To create an account click here: Create Account
+
+ To see a tutorial on how to set up your Raspberry Pi Click Here
+
+
+
+
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/views/choose_device/index.html.erb b/AlexaSmartTVBackend_RubyOnRails/app/views/choose_device/index.html.erb
new file mode 100644
index 0000000..d4714af
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/views/choose_device/index.html.erb
@@ -0,0 +1,42 @@
+
+
+
+
Choose which device to link this alexa to:
+
+
+
+
+
+
ID
+
Name
+
TVs connected
+
Status
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/views/create_account/index.html.erb b/AlexaSmartTVBackend_RubyOnRails/app/views/create_account/index.html.erb
new file mode 100644
index 0000000..2884a7c
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/views/create_account/index.html.erb
@@ -0,0 +1,36 @@
+
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/views/forgot_password/index.html.erb b/AlexaSmartTVBackend_RubyOnRails/app/views/forgot_password/index.html.erb
new file mode 100644
index 0000000..a479a38
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/views/forgot_password/index.html.erb
@@ -0,0 +1,22 @@
+
+
+
+ FORGOT PASSWORD
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/views/home/index.html.erb b/AlexaSmartTVBackend_RubyOnRails/app/views/home/index.html.erb
new file mode 100644
index 0000000..3fac4aa
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/views/home/index.html.erb
@@ -0,0 +1,38 @@
+
+
+
+
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/views/login/index.html.erb b/AlexaSmartTVBackend_RubyOnRails/app/views/login/index.html.erb
new file mode 100644
index 0000000..0dbd4d1
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/views/login/index.html.erb
@@ -0,0 +1,24 @@
+
This privacy policy has been compiled to better serve those who are concerned with how their 'Personally Identifiable Information' (PII) is being used online. PII, as described in US privacy law and information security, is information that can be used on its own or with other information to identify, contact, or locate a single person, or to identify an individual in context. Please read our privacy policy carefully to get a clear understanding of how we collect, use, protect or otherwise handle your Personally Identifiable Information in accordance with our website.
What personal information do we collect from the people that visit our blog, website or app?
When ordering or registering on our site, as appropriate, you may be asked to enter your name, email address or other details to help you with your experience.
When do we collect information?
We collect information from you when you register on our site or enter information on our site.
How do we use your information?
We may use the information we collect from you when you register, make a purchase, sign up for our newsletter, respond to a survey or marketing communication, surf the website, or use certain other site features in the following ways:
• To personalize your experience and to allow us to deliver the type of content and product offerings in which you are most interested.
• To allow us to better service you in responding to your customer service requests.
How do we protect your information?
We do not use vulnerability scanning and/or scanning to PCI standards.
We only provide articles and information. We never ask for credit card numbers.
We use regular Malware Scanning.
Your personal information is contained behind secured networks and is only accessible by a limited number of persons who have special access rights to such systems, and are required to keep the information confidential. In addition, all sensitive/credit information you supply is encrypted via Secure Socket Layer (SSL) technology.
We implement a variety of security measures when a user enters, submits, or accesses their information to maintain the safety of your personal information.
All transactions are processed through a gateway provider and are not stored or processed on our servers.
Do we use 'cookies'?
Yes. Cookies are small files that a site or its service provider transfers to your computer's hard drive through your Web browser (if you allow) that enables the site's or service provider's systems to recognize your browser and capture and remember certain information. For instance, we use cookies to help us remember and process the items in your shopping cart. They are also used to help us understand your preferences based on previous or current site activity, which enables us to provide you with improved services. We also use cookies to help us compile aggregate data about site traffic and site interaction so that we can offer better site experiences and tools in the future.
We use cookies to:
• Understand and save user's preferences for future visits.
You can choose to have your computer warn you each time a cookie is being sent, or you can choose to turn off all cookies. You do this through your browser settings. Since browser is a little different, look at your browser's Help Menu to learn the correct way to modify your cookies.
If users disable cookies in their browser:
If you turn cookies off, Some of the features that make your site experience more efficient may not function properly.Some of the features that make your site experience more efficient and may not function properly.
Third-party disclosure
We do not sell, trade, or otherwise transfer to outside parties your Personally Identifiable Information unless we provide users with advance notice. This does not include website hosting partners and other parties who assist us in operating our website, conducting our business, or serving our users, so long as those parties agree to keep this information confidential. We may also release information when it's release is appropriate to comply with the law, enforce our site policies, or protect ours or others' rights, property or safety.
However, non-personally identifiable visitor information may be provided to other parties for marketing, advertising, or other uses.
Third-party links
We do not include or offer third-party products or services on our website.
Google
Google's advertising requirements can be summed up by Google's Advertising Principles. They are put in place to provide a positive experience for users. https://support.google.com/adwordspolicy/answer/1316548?hl=en
We have not enabled Google AdSense on our site but we may do so in the future.
California Online Privacy Protection Act
CalOPPA is the first state law in the nation to require commercial websites and online services to post a privacy policy. The law's reach stretches well beyond California to require any person or company in the United States (and conceivably the world) that operates websites collecting Personally Identifiable Information from California consumers to post a conspicuous privacy policy on its website stating exactly the information being collected and those individuals or companies with whom it is being shared. - See more at: http://consumercal.org/california-online-privacy-protection-act-caloppa/#sthash.0FdRbT51.dpuf
According to CalOPPA, we agree to the following:
Users can visit our site anonymously.
Once this privacy policy is created, we will add a link to it on our home page or as a minimum, on the first significant page after entering our website.
Our Privacy Policy link includes the word 'Privacy' and can easily be found on the page specified above.
You will be notified of any Privacy Policy changes:
• On our Privacy Policy Page
Can change your personal information:
• By logging in to your account
How does our site handle Do Not Track signals?
We honor Do Not Track signals and Do Not Track, plant cookies, or use advertising when a Do Not Track (DNT) browser mechanism is in place.
Does our site allow third-party behavioral tracking?
It's also important to note that we allow third-party behavioral tracking
COPPA (Children Online Privacy Protection Act)
When it comes to the collection of personal information from children under the age of 13 years old, the Children's Online Privacy Protection Act (COPPA) puts parents in control. The Federal Trade Commission, United States' consumer protection agency, enforces the COPPA Rule, which spells out what operators of websites and online services must do to protect children's privacy and safety online.
We do not specifically market to children under the age of 13 years old.
Do we let third-parties, including ad networks or plug-ins collect PII from children under 13?
Fair Information Practices
The Fair Information Practices Principles form the backbone of privacy law in the United States and the concepts they include have played a significant role in the development of data protection laws around the globe. Understanding the Fair Information Practice Principles and how they should be implemented is critical to comply with the various privacy laws that protect personal information.
In order to be in line with Fair Information Practices we will take the following responsive action, should a data breach occur:
We will notify you via email
• Within 7 business days
We also agree to the Individual Redress Principle which requires that individuals have the right to legally pursue enforceable rights against data collectors and processors who fail to adhere to the law. This principle requires not only that individuals have enforceable rights against data users, but also that individuals have recourse to courts or government agencies to investigate and/or prosecute non-compliance by data processors.
CAN SPAM Act
The CAN-SPAM Act is a law that sets the rules for commercial email, establishes requirements for commercial messages, gives recipients the right to have emails stopped from being sent to them, and spells out tough penalties for violations.
We collect your email address in order to:
• Send information, respond to inquiries, and/or other requests or questions
To be in accordance with CANSPAM, we agree to the following:
• Not use false or misleading subjects or email addresses.
• Identify the message as an advertisement in some reasonable way.
• Include the physical address of our business or site headquarters.
• Monitor third-party email marketing services for compliance, if one is used.
• Honor opt-out/unsubscribe requests quickly.
• Allow users to unsubscribe by using the link at the bottom of each email.
If at any time you would like to unsubscribe from receiving future emails, you can email us at
tomerjshemesh@gmail.com and we will promptly remove you from ALL correspondence.
Contacting Us
If there are any questions regarding this privacy policy, you may contact us using the information below.
alexasmarttv.tk
182 Twining Bridge Rd
Newtown, PA 18940
US
tomerjshemesh@gmail.com
Last Edited on 2017-11-20
+
+
+
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/views/profile/index.html.erb b/AlexaSmartTVBackend_RubyOnRails/app/views/profile/index.html.erb
new file mode 100644
index 0000000..bcf4a75
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/views/profile/index.html.erb
@@ -0,0 +1,31 @@
+
Email: <%=@email%>
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/app/views/tutorial/index.html.erb b/AlexaSmartTVBackend_RubyOnRails/app/views/tutorial/index.html.erb
new file mode 100644
index 0000000..e36081c
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/app/views/tutorial/index.html.erb
@@ -0,0 +1,30 @@
+
+
+
+ Steps:
+
+
Create an account here (I assume you already have one)
+
On your raspbery pi run the following inside any directory
Log in with your account, discover devices and you should be good to go
+
+
diff --git a/AlexaSmartTVBackend_RubyOnRails/bin/bundle b/AlexaSmartTVBackend_RubyOnRails/bin/bundle
new file mode 100755
index 0000000..66e9889
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/bin/bundle
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+load Gem.bin_path('bundler', 'bundle')
diff --git a/AlexaSmartTVBackend_RubyOnRails/bin/rails b/AlexaSmartTVBackend_RubyOnRails/bin/rails
new file mode 100755
index 0000000..0138d79
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/bin/rails
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+begin
+ load File.expand_path('../spring', __FILE__)
+rescue LoadError => e
+ raise unless e.message.include?('spring')
+end
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require_relative '../config/boot'
+require 'rails/commands'
diff --git a/AlexaSmartTVBackend_RubyOnRails/bin/rake b/AlexaSmartTVBackend_RubyOnRails/bin/rake
new file mode 100755
index 0000000..d87d5f5
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/bin/rake
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+begin
+ load File.expand_path('../spring', __FILE__)
+rescue LoadError => e
+ raise unless e.message.include?('spring')
+end
+require_relative '../config/boot'
+require 'rake'
+Rake.application.run
diff --git a/AlexaSmartTVBackend_RubyOnRails/bin/setup b/AlexaSmartTVBackend_RubyOnRails/bin/setup
new file mode 100755
index 0000000..acdb2c1
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/bin/setup
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+require 'pathname'
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+Dir.chdir APP_ROOT do
+ # This script is a starting point to setup your application.
+ # Add necessary setup steps to this file:
+
+ puts "== Installing dependencies =="
+ system "gem install bundler --conservative"
+ system "bundle check || bundle install"
+
+ # puts "\n== Copying sample files =="
+ # unless File.exist?("config/database.yml")
+ # system "cp config/database.yml.sample config/database.yml"
+ # end
+
+ puts "\n== Preparing database =="
+ system "bin/rake db:setup"
+
+ puts "\n== Removing old logs and tempfiles =="
+ system "rm -f log/*"
+ system "rm -rf tmp/cache"
+
+ puts "\n== Restarting application server =="
+ system "touch tmp/restart.txt"
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/bin/spring b/AlexaSmartTVBackend_RubyOnRails/bin/spring
new file mode 100755
index 0000000..fb2ec2e
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/bin/spring
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+# This file loads spring without using Bundler, in order to be fast.
+# It gets overwritten when you run the `spring binstub` command.
+
+unless defined?(Spring)
+ require 'rubygems'
+ require 'bundler'
+
+ lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
+ spring = lockfile.specs.detect { |spec| spec.name == "spring" }
+ if spring
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
+ gem 'spring', spring.version
+ require 'spring/binstub'
+ end
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/certificates/development-cert.pem b/AlexaSmartTVBackend_RubyOnRails/certificates/development-cert.pem
new file mode 100644
index 0000000..4eb1937
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/certificates/development-cert.pem
@@ -0,0 +1,30 @@
+-----BEGIN CERTIFICATE-----
+MIIFFjCCA/6gAwIBAgISA+WHgs7Ppss4KcSKEWffIpr0MA0GCSqGSIb3DQEBCwUA
+MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD
+ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xNzEwMjYxODMyMDJaFw0x
+ODAxMjQxODMyMDJaMBoxGDAWBgNVBAMTD2FsZXhhc21hcnR0di50azCCASIwDQYJ
+KoZIhvcNAQEBBQADggEPADCCAQoCggEBAM0wkjauN0eTACEwaqSh9BOtWR5RsMzB
+qalRdoNgHUdo/xL2EBYFMdwtCHtYb1mM8aCIebbq/GSMl9wIvD14chLV6B4dyhSc
+/nmiBzjbeu1jjXAxPTKRW13rRAIzKw4vwJnFcLxDB0IZ2BQtYbT038vmijGhNkwb
+LoP1NCGqSRmAt9oZLJhBNTN+Ued4WW/dJAg98OSCzQxcCQ5MmWWHDt3VcAxU7uGr
+/8Tr6PzuCDmXEw1tn9rZl27MbLCUUxV8pFJ0oEDXW6ZVzS7SzE6S+tJk1BLUadsM
+nEkS/Tg9YiVJDLYQiOO27QVZucJ5v/Mj1UWw9e2urZmDrg+xyFJCLaECAwEAAaOC
+AiQwggIgMA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYB
+BQUHAwIwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUfhrX5q0tUbtGq4ivq9POW3tE
+e+EwHwYDVR0jBBgwFoAUqEpqYwR93brm0Tm3pkVl7/Oo7KEwbwYIKwYBBQUHAQEE
+YzBhMC4GCCsGAQUFBzABhiJodHRwOi8vb2NzcC5pbnQteDMubGV0c2VuY3J5cHQu
+b3JnMC8GCCsGAQUFBzAChiNodHRwOi8vY2VydC5pbnQteDMubGV0c2VuY3J5cHQu
+b3JnLzAvBgNVHREEKDAmgg9hbGV4YXNtYXJ0dHYudGuCE3d3dy5hbGV4YXNtYXJ0
+dHYudGswgf4GA1UdIASB9jCB8zAIBgZngQwBAgEwgeYGCysGAQQBgt8TAQEBMIHW
+MCYGCCsGAQUFBwIBFhpodHRwOi8vY3BzLmxldHNlbmNyeXB0Lm9yZzCBqwYIKwYB
+BQUHAgIwgZ4MgZtUaGlzIENlcnRpZmljYXRlIG1heSBvbmx5IGJlIHJlbGllZCB1
+cG9uIGJ5IFJlbHlpbmcgUGFydGllcyBhbmQgb25seSBpbiBhY2NvcmRhbmNlIHdp
+dGggdGhlIENlcnRpZmljYXRlIFBvbGljeSBmb3VuZCBhdCBodHRwczovL2xldHNl
+bmNyeXB0Lm9yZy9yZXBvc2l0b3J5LzANBgkqhkiG9w0BAQsFAAOCAQEAZT3gz6/7
+SzhZxqQsLv9rDUm9E7V5XceDDip/bzepjXwxVrTQ+VCYplwDY4hGWA+Xuny3SFzK
+d98nEOMbaqetvRznr/cmEFVnkYYL5QCTiIvB1k834bMwdTz6yKJooYeVxZPH4vGl
+0nlUPWFBPHXuX97R+FQGib6TPBPoVHsyEtf7xnLitHeHOClzqo6VfeGJZsdCkaSD
+DezSSMhwQheWpnpQIBCMU40vW4SWz8hMsbm3BaoktOCitvwBUXaKq5BOG8FKH3G8
+y841Xc3j1cje4hYCwJYJSe+EWZbE/D/r4K8I5KnfDwvhroJvmpUrqK11fKi/RsdV
+pBqP+Fwinqb/Ng==
+-----END CERTIFICATE-----
diff --git a/AlexaSmartTVBackend_RubyOnRails/certificates/development-chain.pem b/AlexaSmartTVBackend_RubyOnRails/certificates/development-chain.pem
new file mode 100644
index 0000000..0002462
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/certificates/development-chain.pem
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/
+MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
+DkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMDMxNzE2NDA0Nlow
+SjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxIzAhBgNVBAMT
+GkxldCdzIEVuY3J5cHQgQXV0aG9yaXR5IFgzMIIBIjANBgkqhkiG9w0BAQEFAAOC
+AQ8AMIIBCgKCAQEAnNMM8FrlLke3cl03g7NoYzDq1zUmGSXhvb418XCSL7e4S0EF
+q6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOlZHP/uaZ6WA8
+SMx+yk13EiSdRxta67nsHjcAHJyse6cF6s5K671B5TaYucv9bTyWaN8jKkKQDIZ0
+Z8h/pZq4UmEUEz9l6YKHy9v6Dlb2honzhT+Xhq+w3Brvaw2VFn3EK6BlspkENnWA
+a6xK8xuQSXgvopZPKiAlKQTGdMDQMc2PMTiVFrqoM7hD8bEfwzB/onkxEz0tNvjj
+/PIzark5McWvxI0NHWQWM6r6hCm21AvA2H3DkwIDAQABo4IBfTCCAXkwEgYDVR0T
+AQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwfwYIKwYBBQUHAQEEczBxMDIG
+CCsGAQUFBzABhiZodHRwOi8vaXNyZy50cnVzdGlkLm9jc3AuaWRlbnRydXN0LmNv
+bTA7BggrBgEFBQcwAoYvaHR0cDovL2FwcHMuaWRlbnRydXN0LmNvbS9yb290cy9k
+c3Ryb290Y2F4My5wN2MwHwYDVR0jBBgwFoAUxKexpHsscfrb4UuQdf/EFWCFiRAw
+VAYDVR0gBE0wSzAIBgZngQwBAgEwPwYLKwYBBAGC3xMBAQEwMDAuBggrBgEFBQcC
+ARYiaHR0cDovL2Nwcy5yb290LXgxLmxldHNlbmNyeXB0Lm9yZzA8BgNVHR8ENTAz
+MDGgL6AthitodHRwOi8vY3JsLmlkZW50cnVzdC5jb20vRFNUUk9PVENBWDNDUkwu
+Y3JsMB0GA1UdDgQWBBSoSmpjBH3duubRObemRWXv86jsoTANBgkqhkiG9w0BAQsF
+AAOCAQEA3TPXEfNjWDjdGBX7CVW+dla5cEilaUcne8IkCJLxWh9KEik3JHRRHGJo
+uM2VcGfl96S8TihRzZvoroed6ti6WqEBmtzw3Wodatg+VyOeph4EYpr/1wXKtx8/
+wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu
+X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG
+PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6
+KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==
+-----END CERTIFICATE-----
diff --git a/AlexaSmartTVBackend_RubyOnRails/certificates/development-fullchain.pem b/AlexaSmartTVBackend_RubyOnRails/certificates/development-fullchain.pem
new file mode 100644
index 0000000..8e9c824
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/certificates/development-fullchain.pem
@@ -0,0 +1,57 @@
+-----BEGIN CERTIFICATE-----
+MIIFFjCCA/6gAwIBAgISA+WHgs7Ppss4KcSKEWffIpr0MA0GCSqGSIb3DQEBCwUA
+MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD
+ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xNzEwMjYxODMyMDJaFw0x
+ODAxMjQxODMyMDJaMBoxGDAWBgNVBAMTD2FsZXhhc21hcnR0di50azCCASIwDQYJ
+KoZIhvcNAQEBBQADggEPADCCAQoCggEBAM0wkjauN0eTACEwaqSh9BOtWR5RsMzB
+qalRdoNgHUdo/xL2EBYFMdwtCHtYb1mM8aCIebbq/GSMl9wIvD14chLV6B4dyhSc
+/nmiBzjbeu1jjXAxPTKRW13rRAIzKw4vwJnFcLxDB0IZ2BQtYbT038vmijGhNkwb
+LoP1NCGqSRmAt9oZLJhBNTN+Ued4WW/dJAg98OSCzQxcCQ5MmWWHDt3VcAxU7uGr
+/8Tr6PzuCDmXEw1tn9rZl27MbLCUUxV8pFJ0oEDXW6ZVzS7SzE6S+tJk1BLUadsM
+nEkS/Tg9YiVJDLYQiOO27QVZucJ5v/Mj1UWw9e2urZmDrg+xyFJCLaECAwEAAaOC
+AiQwggIgMA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYB
+BQUHAwIwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUfhrX5q0tUbtGq4ivq9POW3tE
+e+EwHwYDVR0jBBgwFoAUqEpqYwR93brm0Tm3pkVl7/Oo7KEwbwYIKwYBBQUHAQEE
+YzBhMC4GCCsGAQUFBzABhiJodHRwOi8vb2NzcC5pbnQteDMubGV0c2VuY3J5cHQu
+b3JnMC8GCCsGAQUFBzAChiNodHRwOi8vY2VydC5pbnQteDMubGV0c2VuY3J5cHQu
+b3JnLzAvBgNVHREEKDAmgg9hbGV4YXNtYXJ0dHYudGuCE3d3dy5hbGV4YXNtYXJ0
+dHYudGswgf4GA1UdIASB9jCB8zAIBgZngQwBAgEwgeYGCysGAQQBgt8TAQEBMIHW
+MCYGCCsGAQUFBwIBFhpodHRwOi8vY3BzLmxldHNlbmNyeXB0Lm9yZzCBqwYIKwYB
+BQUHAgIwgZ4MgZtUaGlzIENlcnRpZmljYXRlIG1heSBvbmx5IGJlIHJlbGllZCB1
+cG9uIGJ5IFJlbHlpbmcgUGFydGllcyBhbmQgb25seSBpbiBhY2NvcmRhbmNlIHdp
+dGggdGhlIENlcnRpZmljYXRlIFBvbGljeSBmb3VuZCBhdCBodHRwczovL2xldHNl
+bmNyeXB0Lm9yZy9yZXBvc2l0b3J5LzANBgkqhkiG9w0BAQsFAAOCAQEAZT3gz6/7
+SzhZxqQsLv9rDUm9E7V5XceDDip/bzepjXwxVrTQ+VCYplwDY4hGWA+Xuny3SFzK
+d98nEOMbaqetvRznr/cmEFVnkYYL5QCTiIvB1k834bMwdTz6yKJooYeVxZPH4vGl
+0nlUPWFBPHXuX97R+FQGib6TPBPoVHsyEtf7xnLitHeHOClzqo6VfeGJZsdCkaSD
+DezSSMhwQheWpnpQIBCMU40vW4SWz8hMsbm3BaoktOCitvwBUXaKq5BOG8FKH3G8
+y841Xc3j1cje4hYCwJYJSe+EWZbE/D/r4K8I5KnfDwvhroJvmpUrqK11fKi/RsdV
+pBqP+Fwinqb/Ng==
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/
+MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
+DkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMDMxNzE2NDA0Nlow
+SjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxIzAhBgNVBAMT
+GkxldCdzIEVuY3J5cHQgQXV0aG9yaXR5IFgzMIIBIjANBgkqhkiG9w0BAQEFAAOC
+AQ8AMIIBCgKCAQEAnNMM8FrlLke3cl03g7NoYzDq1zUmGSXhvb418XCSL7e4S0EF
+q6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOlZHP/uaZ6WA8
+SMx+yk13EiSdRxta67nsHjcAHJyse6cF6s5K671B5TaYucv9bTyWaN8jKkKQDIZ0
+Z8h/pZq4UmEUEz9l6YKHy9v6Dlb2honzhT+Xhq+w3Brvaw2VFn3EK6BlspkENnWA
+a6xK8xuQSXgvopZPKiAlKQTGdMDQMc2PMTiVFrqoM7hD8bEfwzB/onkxEz0tNvjj
+/PIzark5McWvxI0NHWQWM6r6hCm21AvA2H3DkwIDAQABo4IBfTCCAXkwEgYDVR0T
+AQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwfwYIKwYBBQUHAQEEczBxMDIG
+CCsGAQUFBzABhiZodHRwOi8vaXNyZy50cnVzdGlkLm9jc3AuaWRlbnRydXN0LmNv
+bTA7BggrBgEFBQcwAoYvaHR0cDovL2FwcHMuaWRlbnRydXN0LmNvbS9yb290cy9k
+c3Ryb290Y2F4My5wN2MwHwYDVR0jBBgwFoAUxKexpHsscfrb4UuQdf/EFWCFiRAw
+VAYDVR0gBE0wSzAIBgZngQwBAgEwPwYLKwYBBAGC3xMBAQEwMDAuBggrBgEFBQcC
+ARYiaHR0cDovL2Nwcy5yb290LXgxLmxldHNlbmNyeXB0Lm9yZzA8BgNVHR8ENTAz
+MDGgL6AthitodHRwOi8vY3JsLmlkZW50cnVzdC5jb20vRFNUUk9PVENBWDNDUkwu
+Y3JsMB0GA1UdDgQWBBSoSmpjBH3duubRObemRWXv86jsoTANBgkqhkiG9w0BAQsF
+AAOCAQEA3TPXEfNjWDjdGBX7CVW+dla5cEilaUcne8IkCJLxWh9KEik3JHRRHGJo
+uM2VcGfl96S8TihRzZvoroed6ti6WqEBmtzw3Wodatg+VyOeph4EYpr/1wXKtx8/
+wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu
+X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG
+PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6
+KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==
+-----END CERTIFICATE-----
diff --git a/AlexaSmartTVBackend_RubyOnRails/certificates/development-key.pem b/AlexaSmartTVBackend_RubyOnRails/certificates/development-key.pem
new file mode 100644
index 0000000..f2b271e
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/certificates/development-key.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEowIBAAKCAQEAzTCSNq43R5MAITBqpKH0E61ZHlGwzMGpqVF2g2AdR2j/EvYQ
+FgUx3C0Ie1hvWYzxoIh5tur8ZIyX3Ai8PXhyEtXoHh3KFJz+eaIHONt67WONcDE9
+MpFbXetEAjMrDi/AmcVwvEMHQhnYFC1htPTfy+aKMaE2TBsug/U0IapJGYC32hks
+mEE1M35R53hZb90kCD3w5ILNDFwJDkyZZYcO3dVwDFTu4av/xOvo/O4IOZcTDW2f
+2tmXbsxssJRTFXykUnSgQNdbplXNLtLMTpL60mTUEtRp2wycSRL9OD1iJUkMthCI
+47btBVm5wnm/8yPVRbD17a6tmYOuD7HIUkItoQIDAQABAoIBACioaTCAkN+T10C8
+UUVR+gU0IiaJ1VidPzsXsz4Q+3w8594f98wFN34DRlz6hwXdkbtXj5aZNW3PFgA5
+kuMzTJdC332oNXSkLyB25Kt1ggQr58jFWPT+LHaNuaod7XggKi/OGaqUNYn5iQFm
+hKfQpc/HXLa81P97m1n2amAJV/a/WdYPb6MtqTjghq+s6lz9AQestvLXpp/r5o2n
+S461ulPiGlJ29ACGoVk4bkTIIvl5WG8A/l/xGcANh+832pazmcXQXrJr9/YDGYD4
+u7/TVa2ngS7wQvAIo4qEjuziLALBUUTXk6744+9mBdNjnW1FbMyIyhN5p2ojtW28
+flLQu+ECgYEA6c0BwfPFCX8MCuqbiZfDsrm5mglZoTTM7yrpRSeuP3Yg8phboyxd
+xAXPZCQL7Hulzfd4LJBoEu4I7Xld1so1R7jJu3u8XuK28YhzO9roVRndwGcIqjJ8
+B32JiI1DO3CG2CQ4Yv70sbv14XIiCJV7ePruRyCnulA2pDv4+ZJZO2UCgYEA4Kwd
+foqENLkaj4eTKU5aiU3uOmYC29BBLxHB2fBO1ZpSJ6YFZAFtQ9T/bowIKQlcMqqc
+Mx/fXhQJt4C1hftvaQgFaHruEoc8nYLsdmEnZ4ZaY7MFoUs1tc/pUF3WDsuFcp/x
+SslYeGSYdLuOToMEiiWCj/a09sKOdNfS6Duwq40CgYEA04AnNONmvZ52sHFnXuMx
+n76vjg8jS9fOBBXXjD3HPZWJXKxDSata73cqE7cgKj/40AgsaHQCEg3PebQvFZ06
+8bTSmY3n7BY/1OPRCraPMl0B44nRptWgqc4A2syfo2e6NFEfyT5G8XnNhrKO4yEG
+33xwjVuXH85sf8nZAzxHCJkCgYA27R0Q0KBdm1tI96YclRFBPBIfqMzOHG2zKi4w
+L7W2NtIa61WqC0dBLBN+XTGphqZJpLgnL4WWJGPzvr2iEcQ88z8POe52DSXehCF3
+F21gu9HhSeT4d8CbwEaT5TztxQfM7Bk7ZVoBpOY4s5mozBMSCvWOaIv5P7tACXuA
+VwdsCQKBgE7uOEIDZNlGqyU4LQ7EPfMlsEOskLSkVUNGOAqTGYuhWPdWnlGx6n5B
+NzXcvylPcXtLs57cNzoATFvQi52jTdghJt9wEY+cWQrtcvdu79g0dvyO1hSqEhFz
+v53mb9HxgVo3ZRH4eyyeZJjWeuYcdow1xTSBvfl36JWBFIZ0Ouqr
+-----END RSA PRIVATE KEY-----
diff --git a/AlexaSmartTVBackend_RubyOnRails/challenge/challenge b/AlexaSmartTVBackend_RubyOnRails/challenge/challenge
new file mode 100644
index 0000000..c6c88bc
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/challenge/challenge
@@ -0,0 +1 @@
+5qN__qsn_5eGuyrf8nQQ4NXTb5k5NI6-7Ep0-ckmDQk.7FxelsSy1Lv2SSilrqdSWdEXsUigQ9bY7HpJ63THCBc
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/config.ru b/AlexaSmartTVBackend_RubyOnRails/config.ru
new file mode 100644
index 0000000..bd83b25
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Rails.application
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/application.rb b/AlexaSmartTVBackend_RubyOnRails/config/application.rb
new file mode 100644
index 0000000..3667d4c
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/application.rb
@@ -0,0 +1,26 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups)
+
+module Workspace
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+# config.force_ssl = true
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # Do not swallow errors in after_commit/after_rollback callbacks.
+ #config.active_record.raise_in_transactional_callbacks = true
+ end
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/boot.rb b/AlexaSmartTVBackend_RubyOnRails/config/boot.rb
new file mode 100644
index 0000000..6b750f0
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/boot.rb
@@ -0,0 +1,3 @@
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+
+require 'bundler/setup' # Set up gems listed in the Gemfile.
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/database.yml b/AlexaSmartTVBackend_RubyOnRails/config/database.yml
new file mode 100644
index 0000000..1c1a37c
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/database.yml
@@ -0,0 +1,25 @@
+# SQLite version 3.x
+# gem install sqlite3
+#
+# Ensure the SQLite 3 gem is defined in your Gemfile
+# gem 'sqlite3'
+#
+default: &default
+ adapter: sqlite3
+ pool: 5
+ timeout: 5000
+
+development:
+ <<: *default
+ database: db/development.sqlite3
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ <<: *default
+ database: db/test.sqlite3
+
+production:
+ <<: *default
+ database: db/production.sqlite3
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/environment.rb b/AlexaSmartTVBackend_RubyOnRails/config/environment.rb
new file mode 100644
index 0000000..ee8d90d
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the Rails application.
+require File.expand_path('../application', __FILE__)
+
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/environments/development.rb b/AlexaSmartTVBackend_RubyOnRails/config/environments/development.rb
new file mode 100644
index 0000000..b55e214
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/environments/development.rb
@@ -0,0 +1,41 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
+
+ # Do not eager load code on boot.
+ config.eager_load = false
+
+ # Show full error reports and disable caching.
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send.
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger.
+ config.active_support.deprecation = :log
+
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+
+ # Debug mode disables concatenation and preprocessing of assets.
+ # This option may cause significant delays in view rendering with a large
+ # number of complex assets.
+ config.assets.debug = true
+
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
+ # yet still be able to expire them through the digest params.
+ config.assets.digest = true
+
+ # Adds additional error checking when serving assets at runtime.
+ # Checks for improperly declared sprockets dependencies.
+ # Raises helpful error messages.
+ config.assets.raise_runtime_errors = true
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/environments/production.rb b/AlexaSmartTVBackend_RubyOnRails/config/environments/production.rb
new file mode 100644
index 0000000..5c1b32e
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/environments/production.rb
@@ -0,0 +1,79 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # Code is not reloaded between requests.
+ config.cache_classes = true
+
+ # Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = true
+
+ # Full error reports are disabled and caching is turned on.
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
+ # Add `rack-cache` to your Gemfile before enabling this.
+ # For large-scale production use, consider using a caching reverse proxy like
+ # NGINX, varnish or squid.
+ # config.action_dispatch.rack_cache = true
+
+ # Disable serving static files from the `/public` folder by default since
+ # Apache or NGINX already handles this.
+ config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
+
+ # Compress JavaScripts and CSS.
+ config.assets.js_compressor = :uglifier
+ # config.assets.css_compressor = :sass
+
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
+ config.assets.compile = false
+
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
+ # yet still be able to expire them through the digest params.
+ config.assets.digest = true
+
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
+
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # Use the lowest log level to ensure availability of diagnostic information
+ # when problems arise.
+ config.log_level = :debug
+
+ # Prepend all log lines with the following tags.
+ # config.log_tags = [ :subdomain, :uuid ]
+
+ # Use a different logger for distributed setups.
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.action_controller.asset_host = 'http://assets.example.com'
+
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners.
+ config.active_support.deprecation = :notify
+
+ # Use default logging formatter so that PID and timestamp are not suppressed.
+ config.log_formatter = ::Logger::Formatter.new
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/environments/test.rb b/AlexaSmartTVBackend_RubyOnRails/config/environments/test.rb
new file mode 100644
index 0000000..1c19f08
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/environments/test.rb
@@ -0,0 +1,42 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Do not eager load code on boot. This avoids loading your whole application
+ # just for the purpose of running a single test. If you are using a tool that
+ # preloads Rails for running tests, you may have to set it to true.
+ config.eager_load = false
+
+ # Configure static file server for tests with Cache-Control for performance.
+ config.serve_static_files = true
+ config.static_cache_control = 'public, max-age=3600'
+
+ # Show full error reports and disable caching.
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates.
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment.
+ config.action_controller.allow_forgery_protection = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Randomize the order test cases are executed.
+ config.active_support.test_order = :random
+
+ # Print deprecation notices to the stderr.
+ config.active_support.deprecation = :stderr
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/initializers/assets.rb b/AlexaSmartTVBackend_RubyOnRails/config/initializers/assets.rb
new file mode 100644
index 0000000..01ef3e6
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/initializers/assets.rb
@@ -0,0 +1,11 @@
+# Be sure to restart your server when you modify this file.
+
+# Version of your assets, change this if you want to expire all your assets.
+Rails.application.config.assets.version = '1.0'
+
+# Add additional assets to the asset load path
+# Rails.application.config.assets.paths << Emoji.images_path
+
+# Precompile additional assets.
+# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
+# Rails.application.config.assets.precompile += %w( search.js )
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/initializers/backtrace_silencers.rb b/AlexaSmartTVBackend_RubyOnRails/config/initializers/backtrace_silencers.rb
new file mode 100644
index 0000000..59385cd
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/initializers/cookies_serializer.rb b/AlexaSmartTVBackend_RubyOnRails/config/initializers/cookies_serializer.rb
new file mode 100644
index 0000000..7f70458
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/initializers/cookies_serializer.rb
@@ -0,0 +1,3 @@
+# Be sure to restart your server when you modify this file.
+
+Rails.application.config.action_dispatch.cookies_serializer = :json
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/initializers/filter_parameter_logging.rb b/AlexaSmartTVBackend_RubyOnRails/config/initializers/filter_parameter_logging.rb
new file mode 100644
index 0000000..4a994e1
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/initializers/filter_parameter_logging.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure sensitive parameters which will be filtered from the log file.
+Rails.application.config.filter_parameters += [:password]
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/initializers/inflections.rb b/AlexaSmartTVBackend_RubyOnRails/config/initializers/inflections.rb
new file mode 100644
index 0000000..ac033bf
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/initializers/inflections.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
+
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.acronym 'RESTful'
+# end
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/initializers/mime_types.rb b/AlexaSmartTVBackend_RubyOnRails/config/initializers/mime_types.rb
new file mode 100644
index 0000000..dc18996
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/initializers/mime_types.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/initializers/session_store.rb b/AlexaSmartTVBackend_RubyOnRails/config/initializers/session_store.rb
new file mode 100644
index 0000000..bdcfe0c
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/initializers/session_store.rb
@@ -0,0 +1,3 @@
+# Be sure to restart your server when you modify this file.
+
+Rails.application.config.session_store :cookie_store, key: '_workspace_session'
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/initializers/wrap_parameters.rb b/AlexaSmartTVBackend_RubyOnRails/config/initializers/wrap_parameters.rb
new file mode 100644
index 0000000..33725e9
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/initializers/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
+end
+
+# To enable root element in JSON for ActiveRecord objects.
+# ActiveSupport.on_load(:active_record) do
+# self.include_root_in_json = true
+# end
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/locales/en.yml b/AlexaSmartTVBackend_RubyOnRails/config/locales/en.yml
new file mode 100644
index 0000000..0653957
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/locales/en.yml
@@ -0,0 +1,23 @@
+# Files in the config/locales directory are used for internationalization
+# and are automatically loaded by Rails. If you want to use locales other
+# than English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t 'hello'
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t('hello') %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# To learn more, please read the Rails Internationalization guide
+# available at http://guides.rubyonrails.org/i18n.html.
+
+en:
+ hello: "Hello world"
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/puma.rb b/AlexaSmartTVBackend_RubyOnRails/config/puma.rb
new file mode 100644
index 0000000..0fb820d
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/puma.rb
@@ -0,0 +1,17 @@
+#daemonize true
+
+app_dir = File.expand_path("../..", __FILE__)
+shared_dir = "#{app_dir}/shared"
+bind "unix://#{shared_dir}/sockets/puma.sock"
+
+pidfile 'tmp/pids/puma.pid'
+state_path 'tmp/pids/puma.state'
+
+stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true
+
+
+# ssl_bind '0.0.0.0', '443', {
+# key: 'certificates/development-key.pem',
+# cert: 'certificates/development-cert.pem'
+# }
+
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/routes.rb b/AlexaSmartTVBackend_RubyOnRails/config/routes.rb
new file mode 100644
index 0000000..02d098b
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/routes.rb
@@ -0,0 +1,47 @@
+Rails.application.routes.draw do
+
+ get 'alexa_login/index'
+
+ get 'profile/index'
+
+ # The priority is based upon order of creation: first created -> highest priority.
+ # See how all your routes lay out with "rake routes".
+ mount LetsencryptPlugin::Engine, at: '/'
+
+ root 'home#index'
+ match 'login', to: 'login#index', :via => 'get'
+ match 'login', to: 'login#create', :via => 'post'
+ match 'alexa_login', to: 'alexa_login#index', :via => 'get'
+ match 'alexa_login', to: 'alexa_login#create', :via => 'post'
+ match 'choose_device', to: 'choose_device#index', :via => 'get'
+ match 'choose_device', to: 'choose_device#create', :via => 'post'
+
+ match 'logout', to: 'logout#index', :via => 'get'
+
+ match 'create_account', to: 'create_account#index', :via => 'get'
+ match 'create_account', to: 'create_account#create', :via => 'post'
+ match 'forgot_password', to: 'forgot_password#create', :via => 'post'
+ match 'forgot_password', to: 'forgot_password#index', :via => 'get'
+
+ match 'profile', to: 'profile#create', :via => 'post'
+
+ match 'tutorial', to: 'tutorial#index', :via => 'get'
+ match 'profile', to: 'profile#index', :via => 'get'
+ match 'privacy', to: 'privacy#index', :via => 'get'
+
+ match '/', to: 'home#delete', :via => 'delete'
+
+
+ namespace :api, :defaults => {:format => :json} do
+ namespace :v1 do
+ match '/login', to: 'login#create' , :via => 'post'
+ match '/auth_token', to: 'auth_token#create', :via => 'post'
+ match '/register_device', to: 'register_device#create' , :via => 'post'
+ match '/ping', to: 'ping#create' , :via => 'post'
+ match '/get_devices', to: 'get_devices#create' , :via => 'post'
+
+ end
+ end
+
+
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/config/secrets.yml b/AlexaSmartTVBackend_RubyOnRails/config/secrets.yml
new file mode 100644
index 0000000..8ecc938
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/config/secrets.yml
@@ -0,0 +1,25 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key is used for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+# You can use `rake secret` to generate a secure secret key.
+
+# Make sure the secrets in this file are kept private
+# if you're sharing your code publicly.
+
+development:
+ secret_key_base: [YOUR_SECRET_KEY_BASE]
+ jwt_key: [YOUR_JWT_KEY]
+
+test:
+ secret_key_base: [YOUR_SECRET_KEY_BASE]
+ jwt_key: [YOUR_JWT_KEY]
+
+# Do not keep production secrets in the repository,
+# instead read values from the environment.
+production:
+ secret_key_base: [YOUR_SECRET_KEY_BASE]
+ jwt_key: [YOUR_JWT_KEY]
\ No newline at end of file
diff --git a/AlexaSmartTVBackend_RubyOnRails/db/migrate/20171030170254_init.rb b/AlexaSmartTVBackend_RubyOnRails/db/migrate/20171030170254_init.rb
new file mode 100644
index 0000000..cf0a914
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/db/migrate/20171030170254_init.rb
@@ -0,0 +1,37 @@
+class Init < ActiveRecord::Migration[5.1]
+ def change
+
+ create_table :users do |t|
+ t.text :email
+ t.text :first_name
+ t.text :last_name
+ t.text :password_digest
+ t.timestamps
+ end
+
+
+ create_table :devices do |t|
+ t.text :name
+ t.boolean :deleted, null: false, default: 'f'
+ t.text :location
+ t.text :uuid
+ t.text :private_key
+ t.text :pubic_certificate
+ t.datetime :last_pinged
+ t.timestamps
+ end
+
+ create_table :tvs do |t|
+ t.text :name
+ t.text :mac_address
+ t.text :model_number
+ t.timestamps
+ end
+
+ add_reference :devices, :user, foreign_key: true
+ add_reference :tvs, :device, foreign_key: true
+ add_index :devices, :uuid, unique: true
+ add_index :users, :email, unique: true
+
+ end
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/db/seeds.rb b/AlexaSmartTVBackend_RubyOnRails/db/seeds.rb
new file mode 100644
index 0000000..4edb1e8
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
+# Mayor.create(name: 'Emanuel', city: cities.first)
diff --git a/AlexaSmartTVBackend_RubyOnRails/lib/assets/.keep b/AlexaSmartTVBackend_RubyOnRails/lib/assets/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/lib/tasks/.keep b/AlexaSmartTVBackend_RubyOnRails/lib/tasks/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/log/.keep b/AlexaSmartTVBackend_RubyOnRails/log/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/public/404.html b/AlexaSmartTVBackend_RubyOnRails/public/404.html
new file mode 100644
index 0000000..b612547
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/public/404.html
@@ -0,0 +1,67 @@
+
+
+
+ The page you were looking for doesn't exist (404)
+
+
+
+
+
+
+
+
+
The page you were looking for doesn't exist.
+
You may have mistyped the address or the page may have moved.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/AlexaSmartTVBackend_RubyOnRails/public/422.html b/AlexaSmartTVBackend_RubyOnRails/public/422.html
new file mode 100644
index 0000000..a21f82b
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/public/422.html
@@ -0,0 +1,67 @@
+
+
+
+ The change you wanted was rejected (422)
+
+
+
+
+
+
+
+
+
The change you wanted was rejected.
+
Maybe you tried to change something you didn't have access to.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/AlexaSmartTVBackend_RubyOnRails/public/500.html b/AlexaSmartTVBackend_RubyOnRails/public/500.html
new file mode 100644
index 0000000..061abc5
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/public/500.html
@@ -0,0 +1,66 @@
+
+
+
+ We're sorry, but something went wrong (500)
+
+
+
+
+
+
+
+
+
We're sorry, but something went wrong.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/AlexaSmartTVBackend_RubyOnRails/public/favicon.ico b/AlexaSmartTVBackend_RubyOnRails/public/favicon.ico
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/public/robots.txt b/AlexaSmartTVBackend_RubyOnRails/public/robots.txt
new file mode 100644
index 0000000..3c9c7c0
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/public/robots.txt
@@ -0,0 +1,5 @@
+# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
+#
+# To ban all spiders from the entire site uncomment the next two lines:
+# User-agent: *
+# Disallow: /
diff --git a/AlexaSmartTVBackend_RubyOnRails/shared/default b/AlexaSmartTVBackend_RubyOnRails/shared/default
new file mode 100644
index 0000000..82e62db
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/shared/default
@@ -0,0 +1,47 @@
+upstream AlexaSmartTVBackend {
+ server unix:///home/ubuntu/AlexaSmartTVBackend/shared/sockets/puma.sock;
+}
+
+server {
+ listen 80;
+ rewrite ^(.*) https://$host$1 permanent;
+ }
+
+# for redirecting to non-www version of the site
+server {
+ listen 80;
+ server_name www.alexasmarttv.tk;
+ rewrite ^(.*) http://alexasmarttv.tk$1 permanent;
+}
+
+
+server {
+ listen 443 default ssl;
+ server_name alexasmarttv.tk; # change to your live domain
+ root /home/ubuntu/AlexaSmartTVBackend/public;
+
+ ssl on;
+
+ ssl_certificate /home/ubuntu/AlexaSmartTVBackend/certificates/development-cert.pem;
+ ssl_certificate_key /home/ubuntu/AlexaSmartTVBackend/certificates/development-key.pem;
+
+ ssl_session_timeout 5m;
+
+ ssl_protocols SSLv2 SSLv3 TLSv1;
+ ssl_ciphers HIGH:!aNULL:!MD5;
+ ssl_prefer_server_ciphers on;
+
+ try_files $uri/index.html $uri @AlexaSmartTVBackend;
+ location @AlexaSmartTVBackend {
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header Host $host;
+ proxy_set_header X-Forwarded-Proto https;
+ proxy_redirect off;
+ proxy_pass http://AlexaSmartTVBackend;
+ }
+
+ error_page 500 502 503 504 /500.html;
+ client_max_body_size 4G;
+ keepalive_timeout 10;
+}
+
diff --git a/AlexaSmartTVBackend_RubyOnRails/start.sh b/AlexaSmartTVBackend_RubyOnRails/start.sh
new file mode 100755
index 0000000..fd338e0
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/start.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+rvmsudo pumactl start -sysbind
+
diff --git a/AlexaSmartTVBackend_RubyOnRails/test/controllers/.keep b/AlexaSmartTVBackend_RubyOnRails/test/controllers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/test/controllers/alexa_login_controller_test.rb b/AlexaSmartTVBackend_RubyOnRails/test/controllers/alexa_login_controller_test.rb
new file mode 100644
index 0000000..30d1cc8
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/test/controllers/alexa_login_controller_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class AlexaLoginControllerTest < ActionDispatch::IntegrationTest
+ test "should get index" do
+ get alexa_login_index_url
+ assert_response :success
+ end
+
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/test/fixtures/.keep b/AlexaSmartTVBackend_RubyOnRails/test/fixtures/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/test/helpers/.keep b/AlexaSmartTVBackend_RubyOnRails/test/helpers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/test/integration/.keep b/AlexaSmartTVBackend_RubyOnRails/test/integration/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/test/mailers/.keep b/AlexaSmartTVBackend_RubyOnRails/test/mailers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/test/models/.keep b/AlexaSmartTVBackend_RubyOnRails/test/models/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/test/test_helper.rb b/AlexaSmartTVBackend_RubyOnRails/test/test_helper.rb
new file mode 100644
index 0000000..92e39b2
--- /dev/null
+++ b/AlexaSmartTVBackend_RubyOnRails/test/test_helper.rb
@@ -0,0 +1,10 @@
+ENV['RAILS_ENV'] ||= 'test'
+require File.expand_path('../../config/environment', __FILE__)
+require 'rails/test_help'
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+end
diff --git a/AlexaSmartTVBackend_RubyOnRails/vendor/assets/javascripts/.keep b/AlexaSmartTVBackend_RubyOnRails/vendor/assets/javascripts/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/AlexaSmartTVBackend_RubyOnRails/vendor/assets/stylesheets/.keep b/AlexaSmartTVBackend_RubyOnRails/vendor/assets/stylesheets/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/LICENSE b/RaspPiModule/LICENSE
similarity index 100%
rename from LICENSE
rename to RaspPiModule/LICENSE
diff --git a/README.md b/RaspPiModule/README.md
similarity index 100%
rename from README.md
rename to RaspPiModule/README.md
diff --git a/alexasmartcli.py b/RaspPiModule/alexasmartcli.py
similarity index 100%
rename from alexasmartcli.py
rename to RaspPiModule/alexasmartcli.py
diff --git a/helpers/mqtt_server.py b/RaspPiModule/helpers/mqtt_server.py
similarity index 100%
rename from helpers/mqtt_server.py
rename to RaspPiModule/helpers/mqtt_server.py
diff --git a/helpers/prefHelper.py b/RaspPiModule/helpers/prefHelper.py
similarity index 100%
rename from helpers/prefHelper.py
rename to RaspPiModule/helpers/prefHelper.py
diff --git a/helpers/pywakeonlan.py b/RaspPiModule/helpers/pywakeonlan.py
similarity index 100%
rename from helpers/pywakeonlan.py
rename to RaspPiModule/helpers/pywakeonlan.py
diff --git a/helpers/ssdp.py b/RaspPiModule/helpers/ssdp.py
similarity index 100%
rename from helpers/ssdp.py
rename to RaspPiModule/helpers/ssdp.py
diff --git a/requirements.txt b/RaspPiModule/requirements.txt
similarity index 100%
rename from requirements.txt
rename to RaspPiModule/requirements.txt
diff --git a/samsungctl_ts/__init__.py b/RaspPiModule/samsungctl_ts/__init__.py
similarity index 100%
rename from samsungctl_ts/__init__.py
rename to RaspPiModule/samsungctl_ts/__init__.py
diff --git a/samsungctl_ts/__main__.py b/RaspPiModule/samsungctl_ts/__main__.py
similarity index 100%
rename from samsungctl_ts/__main__.py
rename to RaspPiModule/samsungctl_ts/__main__.py
diff --git a/samsungctl_ts/exceptions.py b/RaspPiModule/samsungctl_ts/exceptions.py
similarity index 100%
rename from samsungctl_ts/exceptions.py
rename to RaspPiModule/samsungctl_ts/exceptions.py
diff --git a/samsungctl_ts/interactive.py b/RaspPiModule/samsungctl_ts/interactive.py
similarity index 100%
rename from samsungctl_ts/interactive.py
rename to RaspPiModule/samsungctl_ts/interactive.py
diff --git a/samsungctl_ts/remote.py b/RaspPiModule/samsungctl_ts/remote.py
similarity index 100%
rename from samsungctl_ts/remote.py
rename to RaspPiModule/samsungctl_ts/remote.py
diff --git a/samsungctl_ts/remote_legacy.py b/RaspPiModule/samsungctl_ts/remote_legacy.py
similarity index 100%
rename from samsungctl_ts/remote_legacy.py
rename to RaspPiModule/samsungctl_ts/remote_legacy.py
diff --git a/samsungctl_ts/remote_websocket.py b/RaspPiModule/samsungctl_ts/remote_websocket.py
similarity index 100%
rename from samsungctl_ts/remote_websocket.py
rename to RaspPiModule/samsungctl_ts/remote_websocket.py
diff --git a/tvconfig.py b/RaspPiModule/tvconfig.py
similarity index 100%
rename from tvconfig.py
rename to RaspPiModule/tvconfig.py