tramway-profiles 1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1929442fe4e91ad52f21e32b79dc300cf81de3dd53e3bd8ae2c78e2b9714f3b1
4
+ data.tar.gz: 67938301e65db6adee04d53d93f787314cc26c5a5d58dfc1f1ff45cbde2dfae3
5
+ SHA512:
6
+ metadata.gz: 46c0953ee0fd1930d61fcc4b07bd531b9fe47cfa1f73e3cf7a60a37a03dd417e3c37055daeebfc7d3acfdfcba1f5f114cfca1dbaf841ba414382c792b8b0c58d
7
+ data.tar.gz: 368b5093f100c6409183927f12e52156423fef66a6371dd19c6f17767f004c31c022bcf56211f4f941de24956d162c761ddb8b2853368f7733a7cea8a1347172
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Pavel Kalashnikov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Tramway::Profiles
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'tramway-profiles'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install tramway-profiles
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Tramway::Profiles'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'test'
31
+ t.pattern = 'test/**/*_test.rb'
32
+ t.verbose = false
33
+ end
34
+
35
+
36
+ task default: :test
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/tramway/profiles .js
2
+ //= link_directory ../stylesheets/tramway/profiles .css
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,7 @@
1
+ module Tramway
2
+ module Profiles
3
+ class ApplicationController < ActionController::Base
4
+ protect_from_forgery with: :exception
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class ::Tramway::Profiles::SocialNetworkDecorator < ::Tramway::Core::ApplicationDecorator
2
+ class << self
3
+ def collections
4
+ [ :all ]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ class Tramway::Profiles::SocialNetworkForm < ::Tramway::Core::ApplicationForm
2
+ properties :title, :network_name, :record_id, :record_type, :uid
3
+
4
+ def initialize(object)
5
+ form_object = super object
6
+ form_properties title: :string,
7
+ network_name: :default,
8
+ record_id: :integer,
9
+ record_type: :default,
10
+ uid: :string
11
+ form_object
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ module Tramway::Profiles::LinksHelper
2
+ def profile_link(profile)
3
+ send profile.network_name, profile.uid
4
+ end
5
+
6
+ private
7
+
8
+ def vk(uid)
9
+ profile_link_template uid, "https://vk.com/#{uid}", :vk
10
+ end
11
+
12
+ def facebook(uid)
13
+ profile_link_template uid, "https://facebook.com/#{uid}", :facebook
14
+ end
15
+
16
+ def twitter(uid)
17
+ profile_link_template uid, "https://twitter.com/#{uid}", :twitter
18
+ end
19
+
20
+ def profile_link_template(uid, link, icon)
21
+ link_to link, target: '_blank' do
22
+ concat fa_icon icon
23
+ concat ' '
24
+ concat uid
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,6 @@
1
+ module Tramway
2
+ module Profiles
3
+ class ApplicationJob < ActiveJob::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module Tramway
2
+ module Profiles
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: 'from@example.com'
5
+ layout 'mailer'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ class Tramway::Profiles::SocialNetwork < ::Tramway::Core::ApplicationRecord
2
+ belongs_to :record, polymorphic: true
3
+
4
+ enumerize :network_name, in: [ :vk, :facebook, :twitter ]
5
+ #enumerize :record_type, in: ::Tramway::Profiles.records
6
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Tramway profiles</title>
5
+ <%= stylesheet_link_tag "tramway/profiles/application", media: "all" %>
6
+ <%= javascript_include_tag "tramway/profiles/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1 @@
1
+ ::Tramway::Admin.set_available_models ::Tramway::Profiles::SocialNetwork
@@ -0,0 +1,15 @@
1
+ ru:
2
+ activerecord:
3
+ models:
4
+ tramway/profiles/social_network: Социальная сеть
5
+ attributes:
6
+ tramway/profiles/social_network:
7
+ title: Имя профиля
8
+ network_name: Социальная сеть
9
+ record_id: ID записи
10
+ record_type: Тип записи
11
+ uid: Имя пользователя
12
+ cases:
13
+ tramway/profiles/social_network:
14
+ plural: социальные сети
15
+ genitive: социальную сеть
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Tramway::Profiles::Engine.routes.draw do
2
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :tramway_profiles do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,7 @@
1
+ module Tramway
2
+ module Profiles
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace Tramway::Profiles
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,21 @@
1
+ require 'rails/generators'
2
+ require 'tramway/core/generators/install_generator'
3
+
4
+ module Tramway::Profiles::Generators
5
+ class InstallGenerator < ::Tramway::Core::Generators::InstallGenerator
6
+ include Rails::Generators::Migration
7
+ source_root File.expand_path('../templates', __FILE__)
8
+
9
+ def run_other_generators
10
+ end
11
+
12
+ def self.next_migration_number(path)
13
+ next_migration_number = current_migration_number(path) + 1
14
+ ActiveRecord::Migration.next_migration_number next_migration_number
15
+ end
16
+
17
+ def copy_migrations
18
+ migration_template 'create_tramway_profiles_social_networks.rb', 'db/migrate/create_tramway_profiles_social_networks.rb'
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ class CreateTramwayProfilesSocialNetworks < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :tramway_profiles_social_networks do |t|
4
+ t.text :title
5
+ t.text :uid
6
+ t.text :record_id
7
+ t.text :record_type
8
+ t.text :network_name
9
+ t.text :state, default: :active
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ module Tramway
2
+ module Profiles
3
+ VERSION = '1.0'
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require "tramway/profiles/engine"
2
+ require 'tramway/profiles/generates/install_generator'
3
+
4
+ module Tramway
5
+ module Profiles
6
+ class << self
7
+ def records=(models)
8
+ @records = models
9
+ end
10
+
11
+ def records
12
+ @records
13
+ end
14
+ end
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tramway-profiles
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Pavel Kalashnikov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Rails engine for social networks profiles
14
+ email:
15
+ - kalashnikovisme@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - MIT-LICENSE
21
+ - README.md
22
+ - Rakefile
23
+ - app/assets/config/tramway_profiles_manifest.js
24
+ - app/assets/javascripts/tramway/profiles/application.js
25
+ - app/assets/stylesheets/tramway/profiles/application.css
26
+ - app/controllers/tramway/profiles/application_controller.rb
27
+ - app/decorators/tramway/profiles/social_network_decorator.rb
28
+ - app/forms/tramway/profiles/social_network_form.rb
29
+ - app/helpers/tramway/profiles/links_helper.rb
30
+ - app/jobs/tramway/profiles/application_job.rb
31
+ - app/mailers/tramway/profiles/application_mailer.rb
32
+ - app/models/tramway/profiles/social_network.rb
33
+ - app/views/layouts/tramway/profiles/application.html.erb
34
+ - config/initializers/tramway.rb
35
+ - config/locales/models.yml
36
+ - config/routes.rb
37
+ - lib/tasks/tramway/profiles_tasks.rake
38
+ - lib/tramway/profiles.rb
39
+ - lib/tramway/profiles/engine.rb
40
+ - lib/tramway/profiles/generates/install_generator.rb
41
+ - lib/tramway/profiles/generates/templates/create_tramway_profiles_social_networks.rb
42
+ - lib/tramway/profiles/version.rb
43
+ homepage: https://github.com/ulmic/tramway-profiles
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.7.3
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Rails engine for social networks profiles
67
+ test_files: []