about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAsh Furrow <ash@ashfurrow.com>2017-04-20 21:30:59 -0400
committerEugen <eugen@zeonfederated.com>2017-04-21 03:30:59 +0200
commita0ed88a99b736cc786b048126580a7e73c68b07e (patch)
treea1d53aa9f65a0cfe4717ca3f31819bb3c74bd490
parent25d2853db2cb6603c398b6622526e579e974d593 (diff)
Adds version to about/more and API (#2181)
* Adds version.

* Cleans up code.

* Removes standalone endpoint and adds version to instance endpoint.

* Addresses feedback from #2181.
-rw-r--r--app/presenters/instance_presenter.rb4
-rw-r--r--app/views/about/_version.html.haml4
-rw-r--r--app/views/about/more.html.haml1
-rw-r--r--app/views/api/v1/instances/show.rabl1
-rw-r--r--config/application.rb1
-rw-r--r--config/locales/en.yml1
-rw-r--r--lib/mastodon/version.rb5
7 files changed, 17 insertions, 0 deletions
diff --git a/app/presenters/instance_presenter.rb b/app/presenters/instance_presenter.rb
index 4188650d5..e583a38d0 100644
--- a/app/presenters/instance_presenter.rb
+++ b/app/presenters/instance_presenter.rb
@@ -25,4 +25,8 @@ class InstancePresenter
   def domain_count
     Rails.cache.fetch('distinct_domain_count') { Account.distinct.count(:domain) }
   end
+
+  def version_number
+    Mastodon::VERSION
+  end
 end
diff --git a/app/views/about/_version.html.haml b/app/views/about/_version.html.haml
new file mode 100644
index 000000000..f8ebc4c6d
--- /dev/null
+++ b/app/views/about/_version.html.haml
@@ -0,0 +1,4 @@
+.panel
+  .panel-header= t 'about.version'
+  .panel-body
+    %strong= version.version_number
diff --git a/app/views/about/more.html.haml b/app/views/about/more.html.haml
index 8f9cd2f6a..ab5b21850 100644
--- a/app/views/about/more.html.haml
+++ b/app/views/about/more.html.haml
@@ -30,3 +30,4 @@
     .sidebar
       = render 'contact', contact: @instance_presenter
       = render 'links'
+      = render 'version', version: @instance_presenter
diff --git a/app/views/api/v1/instances/show.rabl b/app/views/api/v1/instances/show.rabl
index f5598fde3..e1d4700a0 100644
--- a/app/views/api/v1/instances/show.rabl
+++ b/app/views/api/v1/instances/show.rabl
@@ -4,3 +4,4 @@ node(:uri)         { site_hostname }
 node(:title)       { Setting.site_title }
 node(:description) { Setting.site_description }
 node(:email)       { Setting.site_contact_email }
+node(:version)     { Mastodon::VERSION }
diff --git a/config/application.rb b/config/application.rb
index 59aa7b5f5..e67e3e051 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -9,6 +9,7 @@ Bundler.require(*Rails.groups)
 require_relative '../app/lib/exceptions'
 require_relative '../lib/paperclip/gif_transcoder'
 require_relative '../lib/paperclip/video_transcoder'
+require_relative '../lib/mastodon/version'
 
 Dotenv::Railtie.load
 
diff --git a/config/locales/en.yml b/config/locales/en.yml
index c7b6a17d6..c1438134f 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -29,6 +29,7 @@ en:
     terms: Terms
     user_count_after: users
     user_count_before: Home to
+    version: Version
   accounts:
     follow: Follow
     followers: Followers
diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb
new file mode 100644
index 000000000..51cf2e5f8
--- /dev/null
+++ b/lib/mastodon/version.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+module Mastodon
+  VERSION = '1.2.2'
+end