Compare commits

...

5 Commits

5 changed files with 131 additions and 72 deletions

10
Gemfile
View File

@ -3,9 +3,9 @@ source 'http://rubygems.org'
gem 'rails', '4.0.5' gem 'rails', '4.0.5'
gem 'jquery-rails', '3.0.4' gem 'jquery-rails', '3.0.4'
gem 'rails_autolink' gem 'rails_autolink'
gem 'mysql2' gem 'mysql2', '~> 0.3.18'
gem 'devise' gem 'devise'
gem 'twitter_oauth', git: 'git://github.com/moomerman/twitter_oauth.git' gem 'twitter_oauth', git: 'https://github.com/moomerman/twitter_oauth.git'
gem 'therubyracer' gem 'therubyracer'
gem 'exception_notification' gem 'exception_notification'
gem 'nested_form' gem 'nested_form'
@ -23,13 +23,13 @@ gem 'redis'
gem 'resque-scheduler', '2.3.1', :require => 'resque_scheduler' gem 'resque-scheduler', '2.3.1', :require => 'resque_scheduler'
gem 'daemons' gem 'daemons'
#gem 'db2fog' (not compatible with Rails 4, see https://github.com/hakanensari/db2fog for Rails 4 version) #gem 'db2fog' (not compatible with Rails 4, see https://github.com/hakanensari/db2fog for Rails 4 version)
gem 'simplificator-rwebthumb', :git => "git://github.com/simplificator/rwebthumb.git" gem 'simplificator-rwebthumb', :git => "https://github.com/simplificator/rwebthumb.git"
gem 'tweetstream' gem 'tweetstream'
gem 'capistrano', '~> 2.15.4' gem 'capistrano', '~> 2.15.4'
gem 'rack-utf8_sanitizer' gem 'rack-utf8_sanitizer'
gem 'newrelic_rpm' gem 'newrelic_rpm'
gem 'actionpack-xml_parser' gem 'actionpack-xml_parser'
gem 'activeadmin', github: 'gregbell/active_admin' gem 'activeadmin', git: 'https://github.com/activeadmin/activeadmin.git', tag: 'v1.0.0.pre5'
gem 'chronic' gem 'chronic'
gem 'non-stupid-digest-assets' gem 'non-stupid-digest-assets'
gem 'em-http-request' gem 'em-http-request'
@ -38,6 +38,7 @@ gem 'tzinfo-data'
gem 'turbolinks' gem 'turbolinks'
gem 'geokit-rails' gem 'geokit-rails'
gem 'clockwork' gem 'clockwork'
gem 'activerecord-native_db_types_override'
# to use debugger # to use debugger
# gem 'ruby-debug' # gem 'ruby-debug'
@ -67,4 +68,3 @@ group :test do
gem 'ZenTest' gem 'ZenTest'
gem 'database_cleaner', '~> 1.2.0' gem 'database_cleaner', '~> 1.2.0'
end end

118
README.md Normal file
View File

@ -0,0 +1,118 @@
# ThingSpeak
[ThingSpeak](https://thingspeak.com) ist eine OpenSource "Internet of Things" Anwendung und API, mit der Daten von "Dingen" per HTTP über das Internet (oder LAN) empfangen und gespeichert werden können. Mit ThingSpeak, kann man verschiedene Anwendungen erstellen, die Sensor-Daten speichern, Standortdaten verwenden oder ein "soziales Netzwerk der Dinge" mit Status Updates versorgt.
Die ThinkSpeak API empfängt und speichert numerische und alphanumerische Daten und erlaubt eine Datenverarbeitung (Zeitskalen, Duchschnittswerte, Median, Summen und runden). Jeder ThingSpeak Channel unterstützt bis zu 8 Datenfelder, Breitengrad, Längengrad, Höhe und Status. Zur Integration in weitere Anwendungen werden JSON, XML, und das CSV Format unterstützt.
Unterstützung für ThingSpeak gibt es bei der [ThingSpeak Community](http://community.thingspeak.com/), wo sich ein [Blog](http://community.thingspeak.com/), ein [Forum](http://community.thingspeak.com/forum/), [Dokumentation](https://thingspeak.com/docs), und [Tutorials](https://thingspeak.com/docs/tutorials/) finden.
## Besonderheiten zur Installation
Dieser Fork ist dazu gedacht, auf einem eigenen Debian 12 Server installiert zu werden.
Leider ist das [IOBridge-Repository](https://github.com/iobridge/thingspeak) veraltet und nur für Ubuntu 12.04 LTS geeignet.
Hauptproblem sind die veralteten Programme und Bibliotheken, auf die ThingSpeak aufbaut. Namentlich ist das libssl1.0-dev, aber auch Ruby 2 und Rails 4.
Aktuell ist die Basis die [Installation auf Ubuntu 16.04](https://www.cnx-software.com/2016/12/07/how-to-install-thingspeak-in-ubuntu-16-04/)
Darüber hinaus gibt es auch weitere Ressoucen, die bei einem OS-Upgrade hilfreich sind:
Neben einer [Erfolgsmeldung für Debian 10](https://github.com/iobridge/thingspeak/issues/70) gibt es ein aktuelleres [Repository von ELR](https://github.com/EllenLouiseRipley/thingspeak), aber auch eine ausführlichere [Schritt-für-Schritt-Anleitung für Ubuntu 14.04 LTS](https://gist.github.com/MarconiLab/f9f49cc473fa78ecfa72).
Aber auch ein paar Hilfestellungen zum Umgang mit veränderten Datenbanken ([hier](https://stackoverflow.com/questions/37315546/uninitialized-constant-activerecordconnectionadaptersmysql2adapternative-d) und [dort](https://stackoverflow.com/questions/37315546/uninitialized-constant-activerecordconnectionadaptersmysql2adapternative-d)) bzw. [ActiveAdmin](https://github.com/iobridge/thingspeak/issues/43)
Das Problem mit openssl1.0-dev kann vermutlich mit den Quellen des veralteten Debian 9 (Stretch) umgangen werden:
```
deb http://archive.debian.org/debian stretch main
deb http://archive.debian.org/debian-security stretch/updates main
```
Die genauen in Stretch verfügbaren Programmversionen findet man heraus mit: ```apt cache show ruby```.
Danach installiert man diese mit:
```
??? apt install rails=2:4.2.7.1-1+deb9u5 ruby-rails=2:4.2.7.1-1+deb9u5 ruby=1:2.3.3
??? apt install ruby: mit stretch-Quellen und Version (wegen Abhängigkeit aus Bullseye)
??? apt install rails: nur mit stretch-Quellen (wegen Dependency-Chaos)
```
### Vorbereitungen
1. Installiere Ruby 2, RubyGems, Rails 4, git, und eine Datenbank wie MySQL / MariaDB
2. Lade die Anwendung mit git herunter: git clone https://rlp.schule/gitea/c_meyer/thingspeak.git
3. Wechsele in das Verzeichnis thingspeak und installiere die entsprechenden gems: sudo bundle install
### Konfiguration
1. Set your database configuration file at config/database.yml (see config/database.yml.example for an example)
2. Erstelle die Datenbank: rake db:create
3. Erstelle die Datenbank-Tabellen: rake db:schema:load
### Starte die Anwendung
1. Starte den Server: rails server
Danach ist die Anwendung erreichbar unter ```http://localhost:3000/```
## Ändere den Text der Anwendung
Make changes to config/locales/en.yml
To avoid errors, please ensure your lines start with spaces, not tabs.
Set your application name using the 'application_name' key.
## (Optional) Email Setup
Set your domain, user_name, and password in config/environment.rb
## (Optional) Admin Setup
Open a rails console: ```rails console``` or ```RAILS_ENV=production rails console```, depending on your environment
Add the admin user: ```AdminUser.create!(email: 'YOUR_ADMIN_EMAIL@EXAMPLE.COM', password: 'YOUR_PASSWORD', password_confirmation: 'YOUR_PASSWORD')```
Exit the rails console: ```exit```
Login via the admin web interface at: "http://YOUR_DOMAIN.COM/admin"
# Installation auf Debian 11
Arbeiten als root:
```
command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
curl -sSL https://get.rvm.io | bash -s stable --ruby
rvm install ruby-2.1.0
sudo apt update
sudo apt dist-upgrade
sudo apt purge ruby
sudo apt-get -y install build-essential mysql-server mysql-client libmysqlclient-dev libxml2-dev libxslt-dev git-core curl rubygems gnupg2
```
Arbeiten als user:
```
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install ruby 2.1.0
git clone https://rlp.schule/gitea/c_meyer/thingspeak.git
cd thingspeak
gem install bundler
rvm --force rubygems 2.1.0
gem install bundler -v 1.17.3
gem install jquery-rails -v 3.0.4
gem install tzinfo -v 1.2.2
gem install 'activerecord-native_db_types_override'; für die Datenbank
bundle update mysql2
bundle install
cp config/database.yml.example config/database.yml
rake db:create
# mysql -u root -p
rake db:schema:load
rails server webrick
```
# Upgrading existing installations
```
git pull origin master
bundle install
rake db:migrate
```
If your server is active you can restart it by going to the active terminal, hitting Ctrl-c, and then typing:
```rails server```

View File

@ -1,67 +0,0 @@
h1. ThingSpeak
"ThingSpeak":https://thingspeak.com is an open source "Internet of Things" application and API to store and retrieve data from things using HTTP over the Internet or via a Local Area Network. With ThingSpeak, you can create sensor logging applications, location tracking applications, and a social network of things with status updates.
In addition to storing and retrieving numeric and alphanumeric data, the ThingSpeak API allows for numeric data processing such as timescaling, averaging, median, summing, and rounding. Each ThingSpeak Channel supports data entries of up to 8 data fields, latitude, longitude, elevation, and status. The channel feeds support JSON, XML, and CSV formats for integration into applications.
The ThingSpeak application also features time zone management, read/write API key management and JavaScript-based charts from Highslide Software / Torstein Hønsi.
Support for ThingSpeak is available on the "ThingSpeak Community":http://community.thingspeak.com/ site which features a "Blog":http://community.thingspeak.com/, "Forum":http://community.thingspeak.com/forum/, "Documentation":https://thingspeak.com/docs, and "Tutorials":https://thingspeak.com/docs/tutorials/.
h3. Before You Begin
1. Install Ruby 2, RubyGems, Rails 4, git, and a database like MySQL
2. Download the application using git: git clone git@github.com:iobridge/thingspeak.git
3. Change to the thingspeak directory and install the appropriate gems: sudo bundle install
h3. Configuration
1. Set your database configuration file at config/database.yml (see config/database.yml.example for an example)
2. Create the database: rake db:create
3. Create the database tables: rake db:schema:load
h3. Run The Application
1. Start the server: rails server
Your application will now be running at http://localhost:3000/
h2. Changing Application Text
Make changes to config/locales/en.yml
To avoid errors, please ensure your lines start with spaces, not tabs.
Set your application name using the 'application_name' key.
h2. (Optional) Email Setup
Set your domain, user_name, and password in config/environment.rb
h2. (Optional) Admin Setup
Open a rails console: <code>rails console</code> or <code>RAILS_ENV=production rails console</code>, depending on your environment
Add the admin user: <code>AdminUser.create!(email: 'YOUR_ADMIN_EMAIL@EXAMPLE.COM', password: 'YOUR_PASSWORD', password_confirmation: 'YOUR_PASSWORD')</code>
Exit the rails console: <code>exit</code>
Login via the admin web interface at: "http://YOUR_DOMAIN.COM/admin"
h1. Installation on clean install of Ubuntu 12.04 LTS
<code>sudo apt-get upgrade</code>
<code>sudo apt-get -y install build-essential mysql-server mysql-client libmysqlclient-dev libxml2-dev libxslt-dev git-core curl rubygems</code>
<code>\curl -sSL https://get.rvm.io | bash -s stable</code>
<code>rvm install 2.1</code>
<code>git clone https://github.com/iobridge/thingspeak.git</code>
<code>cd thingspeak</code>
<code>bundle install</code>
<code>cp config/database.yml.example config/database.yml</code>
<code>rake db:create</code>
<code>rake db:schema:load</code>
<code>rails server</code>
h2. Upgrading existing installations
<code>git pull origin master</code>
<code>bundle install</code>
<code>rake db:migrate</code>
If your server is active you can restart it by going to the active terminal, hitting Ctrl-c, and then typing:
<code>rails server</code>

View File

@ -19,3 +19,5 @@ end
# Initialize the rails application # Initialize the rails application
Thingspeak::Application.initialize! Thingspeak::Application.initialize!
require File.expand_path('../../config/initializers/abstract_mysql2_adapter', __FILE__)

View File

@ -0,0 +1,6 @@
require 'active_record/connection_adapters/mysql2_adapter'
NativeDbTypesOverride.configure({
ActiveRecord::ConnectionAdapters::Mysql2Adapter => {
primary_key: "int(11) auto_increment PRIMARY KEY"
}
})