]> git.openstreetmap.org Git - rails.git/commitdiff
Merge branch 'master' into feature/add-communities-page
authorAdam Hoyle <atomoil@gmail.com>
Thu, 12 Aug 2021 18:41:12 +0000 (19:41 +0100)
committerAdam Hoyle <atomoil@gmail.com>
Thu, 12 Aug 2021 18:41:12 +0000 (19:41 +0100)
app/abilities/ability.rb
app/controllers/site_controller.rb
app/models/communities.rb [new file with mode: 0644]
app/views/layouts/_header.html.erb
app/views/site/communities.html.erb [new file with mode: 0644]
config/locales/en.yml
config/routes.rb
package.json
yarn.lock

index 018ce00966bd295e347fe8a5d8fa9c3b9bd4701b..ec32a4607f93dca19bf1d0ddb9efbc99e010a103 100644 (file)
@@ -7,7 +7,7 @@ class Ability
     can [:relation, :relation_history, :way, :way_history, :node, :node_history,
          :changeset, :note, :new_note, :query], :browse
     can :search, :direction
-    can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :preview, :copyright, :key, :id], :site
+    can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :key, :id], :site
     can [:finish, :embed], :export
     can [:search, :search_latlon, :search_ca_postcode, :search_osm_nominatim,
          :search_geonames, :search_osm_nominatim_reverse, :search_geonames_reverse], :geocoder
index 00b3e78da4c858b7c36e0211106ba1190e69436c..73e4ef51d5ced1dca199062575554ac35308fa80 100644 (file)
@@ -106,6 +106,11 @@ class SiteController < ApplicationController
     @locale = params[:about_locale] || I18n.locale
   end
 
+  def communities
+    @locale = params[:communities_locale] || I18n.locale
+    @local_chapters = Communities.local_chapters
+  end
+
   def export; end
 
   def offline; end
diff --git a/app/models/communities.rb b/app/models/communities.rb
new file mode 100644 (file)
index 0000000..f318157
--- /dev/null
@@ -0,0 +1,29 @@
+
+class Communities
+
+  def self.local_chapters
+    @local_chapters ||= self.load_local_chapters
+  end
+
+  protected
+
+  def self.load_local_chapters
+
+    json_file = File.expand_path("node_modules/osm-community-index/dist/completeFeatureCollection.json", Dir.pwd);
+    community_index = JSON.parse(File.read(json_file))
+
+    local_chapters = []
+    community_index['features'].each do |feature|
+      feature['properties']['resources'].each do |id, data|
+        data.each do |key, value|
+          if key == "type" and value == "osm-lc" and data['strings']['community']
+            local_chapters.push({ id: id, name: data['strings']['community'], url: data['strings']['url'] });
+          end
+        end
+      end
+    end
+
+    return local_chapters
+  end
+
+end
index a20474b57a2ed9624bb40265635e414e93b08c43..bd1c10c392fc4019a702db0f513d54316d884c11 100644 (file)
@@ -50,6 +50,9 @@
       <li class="compact-hide nav-item <%= current_page_class(diary_entries_path) %>">
         <%= link_to t("layouts.user_diaries"), diary_entries_path, :class => "nav-link" %>
       </li>
+      <li class="compact-hide nav-item <%= current_page_class(communities_path) %>">
+        <%= link_to t("layouts.communities"), communities_path, :class => "nav-link" %>
+      </li>
       <li class="compact-hide nav-item <%= current_page_class(copyright_path) %>">
         <%= link_to t("layouts.copyright"), copyright_path, :class => "nav-link" %>
       </li>
@@ -72,6 +75,7 @@
           <% end %>
           <li class="<%= current_page_class(traces_path) %>"><%= link_to t("layouts.gps_traces"), traces_path, :class => "dropdown-item" %></li>
           <li class="<%= current_page_class(diary_entries_path) %>"><%= link_to t("layouts.user_diaries"), diary_entries_path, :class => "dropdown-item" %></li>
+          <li class="<%= current_page_class(communities_path) %>"><%= link_to t("layouts.communities"), communities_path, :class => "dropdown-item" %></li>
           <li class="<%= current_page_class(copyright_path) %>"><%= link_to t("layouts.copyright"), copyright_path, :class => "dropdown-item" %></li>
           <li class="<%= current_page_class(help_path) %>"><%= link_to t("layouts.help"), help_path, :class => "dropdown-item" %></li>
           <li class="<%= current_page_class(about_path) %>"><%= link_to t("layouts.about"), about_path, :class => "dropdown-item" %></li>
diff --git a/app/views/site/communities.html.erb b/app/views/site/communities.html.erb
new file mode 100644 (file)
index 0000000..b92b314
--- /dev/null
@@ -0,0 +1,19 @@
+<% content_for :heading do %>
+  <%= tag.h1 :lang => @locale, :dir => t("html.dir", :locale => @locale) do %>
+    <%= t ".title", :locale => @locale %>
+  <% end %>
+<% end %>
+
+<%= tag.div :lang => @locale, :dir => t("html.dir", :locale => @locale) do %>
+  <p><%= t ".lede_text", :locale => @locale %></p>
+  <h2><%= t ".local_chapters.title", :locale => @locale %></h2>
+  <p><%= t ".local_chapters.about_text", :locale => @locale %></p>
+  <p><%= t ".local_chapters.list_text", :locale => @locale %></p>
+  <ul>
+    <% @local_chapters.each do |chapter| %>
+      <li><a href="<%= chapter[:url] %>"><%= chapter[:name] %></a></li>
+    <% end %>
+  </ul>
+  <h2><%= t ".other_groups.title", :locale => @locale %></h2>
+  <p><%= t ".other_groups.about_html", :locale => @locale %></p>
+<% end %>
\ No newline at end of file
index 5b1686c6b81b6eddf6c2f63304d00b9428bcde85..d361dc852dbccd4c08c7c1d4839a9b4619c692b7 100644 (file)
@@ -1431,6 +1431,7 @@ en:
     help: Help
     about: About
     copyright: Copyright
+    communities: Communities
     community: Community
     community_blogs: "Community Blogs"
     community_blogs_title: "Blogs from members of the OpenStreetMap community"
@@ -2197,6 +2198,30 @@ en:
           Just go to <a href='%{map_url}'>the map</a> and click the note icon:
           <span class='icon note'></span>. This will add a marker to the map, which you can move
           by dragging. Add your message, then click save, and other mappers will investigate.
+    communities:
+      title: Communities
+      lede_text: |
+        People from all over the world contribute to or use OpenStreetMap.
+        Whilst some are content to participate as individuals, others have formed communities.
+        These groups come in a range of sizes and represent geographies from small towns to large multi-country regions.
+        They can also be formal or informal.
+      local_chapters:
+        title: Local Chapters
+        about_text: |
+          Local Chapters are country-level or region-level groups that have taken the formal step of
+          establishing not-for-profit legal entities. They represent the area's map and mappers when
+          dealing with local government, business, and media. They have also formed an affiliation
+          with the OpenStreetMap Foundation (OSMF), giving them a link to the legal and copyright
+          governing body.
+        list_text: |
+          So far we have the following formally established foundation Local Chapters:
+      other_groups:
+        title: Other Groups
+        about_html: |
+          There is no need to formally establish a group to the same extent as the Local Chapters.
+          Indeed many groups exist very sucessfully as an informal gathering of people or as a
+          community group. Anyone can set up or join these. Read more on the
+          <a href="https://wiki.openstreetmap.org/wiki/User_group">Communities wiki page</a>.
   traces:
     visibility:
       private: "Private (only shared as anonymous, unordered points)"
index dc10818b99aba08f26841b7a6eb3ed24db3107a2..1295772f1c4c75c48aa99d83921a748ae6302ba8 100644 (file)
@@ -147,6 +147,8 @@ OpenStreetMap::Application.routes.draw do
   get "/help" => "site#help"
   get "/about/:about_locale" => "site#about"
   get "/about" => "site#about"
+  get "/communities" => "site#communities"
+  get "/communities/:communities_locale" => "site#communities"
   get "/history" => "changesets#index"
   get "/history/feed" => "changesets#feed", :defaults => { :format => :atom }
   get "/history/comments/feed" => "changeset_comments#index", :as => :changesets_comments_feed, :defaults => { :format => "rss" }
index 8e4ac857efd6cb66866a96d2e67a18389e57a013..89c0a83a5df9312a343fe59aa2ed31655b0813d8 100644 (file)
@@ -8,6 +8,7 @@
     "js-cookie": "^3.0.0",
     "leaflet": "^1.6.0",
     "leaflet.locatecontrol": "^0.74.0",
+    "osm-community-index": "^5.1.2",
     "qs": "^6.9.4"
   },
   "devDependencies": {
index 15b11abd46edd773744544178ba55ac25c89fdbe..d95a1b317c5158ba706268f8670682969a7bffce 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -229,6 +229,11 @@ deep-is@^0.1.3:
   resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
   integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=
 
+diacritics@^1.3.0:
+  version "1.3.0"
+  resolved "https://registry.yarnpkg.com/diacritics/-/diacritics-1.3.0.tgz#3efa87323ebb863e6696cebb0082d48ff3d6f7a1"
+  integrity sha1-PvqHMj67hj5mls67AILUj/PW96E=
+
 doctrine@^3.0.0:
   version "3.0.0"
   resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961"
@@ -654,6 +659,13 @@ optionator@^0.9.1:
     type-check "^0.4.0"
     word-wrap "^1.2.3"
 
+osm-community-index@^5.1.2:
+  version "5.1.2"
+  resolved "https://registry.yarnpkg.com/osm-community-index/-/osm-community-index-5.1.2.tgz#dbae073ce3f10177bfc1749623b632e62b12eeaf"
+  integrity sha512-4kYj81tFZZwDBYY1Kl+JyACNuwYPBqNrwlmxWEK7+tFCqmIg/pYBKzSDP1M5z+NuNfyuAtLR4opwN3dpCUI/uQ==
+  dependencies:
+    diacritics "^1.3.0"
+
 parent-module@^1.0.0:
   version "1.0.1"
   resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"