Social nets DB

Gem Version

Скачен 5 115 раз

Что оно делает

A non-comprehensive database of social nets packed in a Ruby gem

Как оно это делает

It stores data about popular social nets, video hostings etc. in a YAML file db.yml:

behance:
  name: Behance
  icons:
    font_awesome_4: behance
  color: "#1769ff"
  domain: behance.com
  tags:
    — art
    — design
    — recruiting
  profile_url:
    by_username: "https://${domain}/${uid}"
    by_account_id: "https://${domain}/${uid}"

Everything else is just helpers around this simple DB: finders, accessors & view helpers.

For example, one can build a <select> with social nets when storing user's account link:

= form_for @user do |f|
  = f.fields_for :social_net_accounts do |sna|
    .form-group
      = sna.label  :social_net_uid, class: "control-label"
      = sna.select :social_net_uid, SocialNetsDB::SocialNet.values_for_select, {}, class: "form-control"

which produces

<form action="/users" method="POST">
  <div class="form-group">
    <label for="user_social_net_accounts_attributes_123_social_net_uid">Social net UID</label>
    <select required="required" class="form-control" name="user[social_net_accounts_attributes][123][social_net_uid]">
      <option value="">Choose a social net:</option>
      <option value="behance">Behance</option>
      <option value="dribble">Dribble</option>
      <option value="facebook">Facebook</option>
      <!-- ... -->
    </select>
  </div>
</form>

Ссылки