Алексей Горобец - building drupal distributions. why? when? and how?

66
Делаем дистрибутивы Почему, Зачем и Как? Алексей Горобец asgorobets

Upload: ledc-2014

Post on 07-Jul-2015

91 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Делаем дистрибутивыПочему, Зачем и Как?

Алексей Горобецasgorobets

Page 2: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Обо мне

* Senior Drupal Developer @ Propeople

* 2 года в Drupal

* Трейнер

* Комьюнити лидер

Page 3: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

O Propeople

http://wearepropeople.com

Page 4: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

O Propeople

Page 5: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

В зале у нас?

* Разработчики

Page 6: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

В зале у нас?

* Разработчики

* Сайт-билдеры

Page 7: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

В зале у нас?

* Разработчики

* Сайт-билдеры

* Front-end разработчики

Page 8: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

В зале у нас?

* Разработчики

* Сайт-билдеры

* Front-end разработчики

* Менеджеры проектов

Page 9: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

На повестке дня

1. Что такое дистрибутив и зачем они

нужны?

2. В каких случаях стоит создавать свой

дистрибутив?

3. Как создать и поддерживать свой

дистрибутив

Page 10: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Немного фактов

По данным http://w3techs.com/

Page 11: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Немного фактов

По данным http://w3techs.com/

Page 12: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Чего же не хватает в Drupal?

* Листинг контента?

* WYSIWYG?

* Удобный интерфейс?

* Менеджемент медиа?

* Поле типа Date и Link?

Page 13: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Два типа пользователей

Все есть, только

надо настроить. Вот

тебе туториалы,

смотри как все

просто!К черту ваш Drupal.

Неюзабельный и

сложный он!

Page 14: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Что такое дистрибутив?

Page 15: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Что такое дистрибутив?

Дистрибутивы предоставляют

упакованную версию ядра Drupal

с контриб модулями

предварительно настроенными

под определенный тип сайта.

Page 16: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Ядро Drupal и contrib

Page 17: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Drupal distribution

Page 18: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Популярные дистрибутивы

Page 19: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Commerce Kickstart

Page 20: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

OpenPublish

Page 21: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

OpenPublic

Page 22: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Drupal Commons

Page 23: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Open Atrium

Page 24: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

COD

Page 25: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Почему дистрибутивы

существуют?

Не изобретай колесо!

Page 26: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Почему дистрибутивы

существуют?

Наши услуги не всем по корману

Page 27: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Distribution vs Install

Profile

Page 28: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Так вы хотите разработать

дистрибутив?

А стоит ли?

So You Guys Want to Build a Drupal Distribution

http://www.youtube.com/watch?v=ECrUuRGzuH0

http://prezi.com/k2d_x8eczfzu/so-you-want-to-build-a-drupal-distro/

Page 29: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Так вы хотите разработать

дистрибутив?

Page 30: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Может вам нужен Install

Profile?

Distribution:

* Брендированный продукт

* Решает определенный

юзкейс

* Является публичным

проектом и поддерживается

сообществом

* Фокус на конечного

пользователя (готов к

использованию)

Install Profile:

* Предустанавливает модули

* Создает конфигурации

* Для внутреннего

использования

* Фокус на разработчика

(готов к началу разработки)

Page 31: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Или build base?

* У вас Continuous Integration?

* Распределенная команда разработчиков?

* Нужна стандартизация?

* Нужно автоматическое тестирование?

* Надоело повторяться?

Page 32: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

С чего начать?

Install Profile

myprofile.info

myprofile.profile

myprofile.install

Page 33: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Install Profile

myprofile.info

name = My Profile

description = Description of what the profile does.

core = 7.x

dependencies[] = block

dependencies[] = color

dependencies[] = comment

dependencies[] = contextual

dependencies[] = dashboard

dependencies[] = help

dependencies[] = image

dependencies[] = list

dependencies[] = menu

dependencies[] = number

dependencies[] = options

Page 34: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Install Profile

myprofile.profile

То же что и .module для модулей. Здесь удобно

определять hook_install_tasks и подобные вещи

связанные с процессом инсталяции.

Page 35: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Install Profile

Page 36: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Install Profile

myprofile.install

<?php/** * Implement hook_install(). * * Perform actions to set up

the site for this profile. */function profilename_install() {

include_once DRUPAL_ROOT . '/profiles/minimal/minimal.install';

minimal_install();

}?>

Page 37: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Основные инструменты

Features

Page 38: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Features

Page 39: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Features

Page 40: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

FAQ и подводные камни

* Как правильно упаковывать компоненты?

Не создавайте фичи по принципу общего типа

компонента. Гиганты вроде Acme Content Types, или

Acme Views зделают вашу систему сильно-

зависимой, их нельзя будет отключить, а

реорганизация покажется адом.

Организовывайте фичи по принципу независимого

функционала.

Например:

Blog, Gallery, Voting

Page 41: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

FAQ и подводные камни

* Как организовать фичи для реутилизации

полей

Нет необходимости дублировать поля общего

назначения. Создавайте общие поля указывая их

характеристики в имени поля.

Например:

field_file_single_public

Поле типа файл, принимающее единственное

значение, использует Public директорию.

field_link_single, field_content_ref,

field_body_no_summary

Page 42: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

FAQ и подводные камни

* Как избежать конфликтов с base fields

Все field_base полезно экспортировать в отдельную

фичу, а уже field_instance в фичу с контент тайпом.

Например:

Acme Base Fields - field_base:field_body

Acme Blog - field_instance:field_body

Acme Article - field_instance:field_body

Page 43: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

FAQ и подводные камни

* Как экспортить мои File Display в фичу если они

определяются в hook_default_COMPONENT?

Любую фичу можно переиспользовать экспортирую

только необходимые изменения с помошью Features

Override

Page 44: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

FAQ и подводные камни

* Как экспортить variables

Не волнуемся, на помошь приходит модуль

Strongarm

Page 45: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Основные инструменты

FeaturesDrush make

Page 46: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Простой Drush make

api = 2

; Core projectprojects[drupal][version] = 7

; Modules; --------projects[ctools][version] = 1.3projects[ctools][type] = "module"projects[libraries][version] = 2.1projects[libraries][type] = "module"projects[wysiwyg][version] = 2.2projects[wysiwyg][type] = "module"projects[views][version] = 3.7projects[views][type] = "module"

Page 47: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Drush make для дистрибутива

Stub make

Подтягивает ядро Drupal и сам install profile.

Здесь есть одно преимущество - удобно подтягивать

несколько install profiles в вашем дистрибутиве.

Profile make

Подтягивает модули, темы, библиотеки, применяет

патчи

Page 48: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Stub make

api = 2core = 7.x

projects[drupal][type] = coreprojects[drupal][version] = "7.23"; This fixes multiple upload fields in gsb_media_center. http://drupal.org/node/1620030projects[drupal][patch][1620030] = http://drupal.org/files/1620030-d7-2.patchprojects[drupal][patch][1702132] = http://drupal.org/files/drupal-7.14-ajax-showeffect-not-function-1702132.patchprojects[drupal][patch][1783278] = https://drupal.org/files/schema-relative-1783278-7-D7-do-not-test.patchprojects[drupal][patch][1232416] = https://drupal.org/files/issues/autocomplete-1232416-17-7x.patch

; Add GSB Public Profileprojects[gsb_public][type] = profileprojects[gsb_public][download][type] = gitprojects[gsb_public][download][url] = https://github.com/gsbitse/gsb_public.gitprojects[gsb_public][download][branch] = 1.4

distro.make

Page 49: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Profile make

api = 2core = 7.x

; Feature Flagprojects[feature_flag][type] = moduleprojects[feature_flag][download][type] = gitprojects[feature_flag][download][url] = [email protected]:gsbitse/feature_flag.gitprojects[feature_flag][download][tag] = 1.0projects[feature_flag][subdir] = custom

; GSB Acquia Tokensprojects[gsb_acquia_tokens][type] = moduleprojects[gsb_acquia_tokens][download][type] = gitprojects[gsb_acquia_tokens][download][url] = [email protected]:gsbitse/gsb_acquia_tokens.gitprojects[gsb_acquia_tokens][download][tag] = 1.0projects[gsb_acquia_tokens][subdir] = custom

etc...

profile.make

Page 50: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Основные инструменты

FeaturesХукиDrush make

Page 51: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Обновления с hook_update_N()

/** * Add a 'year' date format. */function myprofile_update_7000() {

// Insert custom format: 2011

db_insert('date_formats')

->fields(array('format' => 'Y', 'type' => 'custom', 'locked' => 0))

->execute();

// Insert custom format: 2011

db_insert('date_format_type')

->fields(array('type' => 'year', 'title' => 'Year', 'locked' => 0))

->execute();

// Date Year Format

variable_set('date_format_year', 'Y');

}

Page 52: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Обновления с hook_update_N()

* Все обновления из hook_update_N также идут в

hook_install!

* Новые модули активируем в:

- dependencies (для первой инсталяции)

- hook_update_N при помощи module_enable

Page 53: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Билдим дистрибутив

drush make distro.make

Page 54: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Билдим дистрибутив

drush make distro.make

Drush make рекурсивно вызывает .make файлы из подтягиваемых

проектов! Таким образом запустив distro.make подтянются все модули

из profile.make и так далее.

Page 55: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Свой дистрибутив (варианты)

1. Начать с нуля

2. Использовать base distribution

3. Унаследовать дистрибутив

Page 56: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Подход “с нуля”

Преимущества

* Включай только то что нужно (гибкость)

Недостатки

* Изобретение велосипеда. Придется все

настраивать самим и экспортить в фичи, которые

потом поддерживать

* Дорого поддерживать контриб модули и следить за

их обновлениями

Page 57: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Подход “с базовой дистро”

Преимущества

* Готовые фичи из коробки

* Поддержка базовой дистрибутив сообществом

Недостатки

* Не все фичи нужны, что-то придется отключать, а

что-то переписыватьi

* Big Drupal, больше модулей, больше шансов что

всплывет баг

Page 58: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Представляем Panopoly

Page 59: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Дистро на базе Panopoly

projects[panopoly_core][version] = 1.0-rc5projects[panopoly_core][subdir] = panopolyprojects[panopoly_core][patch][2087414] = https://drupal.org/files/issue-2087414.patch

projects[panopoly_images][version] = 1.0-rc5projects[panopoly_images][subdir] = panopoly

projects[panopoly_theme][version] = 1.0-rc5projects[panopoly_theme][subdir] = panopoly

projects[panopoly_magic][version] = 1.0-rc5projects[panopoly_magic][subdir] = panopoly

projects[panopoly_widgets][version] = 1.0-rc5projects[panopoly_widgets][subdir] = panopoly

projects[panopoly_admin][version] = 1.0-rc5projects[panopoly_admin][subdir] = panopoly

projects[panopoly_users][version] = 1.0-rc5projects[panopoly_users][subdir] = panopoly

; The Panopoly Toolset

projects[panopoly_pages][version] = 1.0-rc5projects[panopoly_pages][subdir] = panopoly

projects[panopoly_wysiwyg][version] = 1.0-rc5projects[panopoly_wysiwyg][subdir] = panopoly

projects[panopoly_search][version] = 1.0-rc5projects[panopoly_search][subdir] = panopoly

Включить в profile.make фичи Panopoly:

Page 60: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Яркий пример

Попробуйте собрать свой GSB отсюда

Page 61: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Подход “наследование”

Преимущества

* Сканирует базовый инстал профайл на модули и

темы

* Возможность переписать родительский модуль

поместив этот же модуль в дочерний профайл

Недостатки

* Патчим ядро

* Пока никак нельзя унаследовать инсталл таски

родителя

Page 62: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Подход “наследование”

1. Ставим патч

Make install profiles inheritable

2. Указываем родителя в .info

base = BASE_PROFILE

3. Подробнее читаем

Inheriting your Drupal profile from an existing

distribution

Page 63: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

К дальнейшему изучению?

* DrupalCon London 2011: BUILDING AND MAINTAINING A

DISTRIBUTION IN DRUPAL 7

* Kit specification

* Drush make

* Apps

Учимся по примеру:

https://github.com/Gizra/Garment-Box

https://github.com/gsbitse/gsb-distro

а также проекты на drupal.org

Page 64: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Demo

Page 65: Алексей Горобец - Building Drupal Distributions. Why? When? and How?

Q&A

Page 66: Алексей Горобец - Building Drupal Distributions. Why? When? and How?