ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Aleksey Avdeev <solo@solin.spb.ru>
To: ALT Linux Team development discussions <devel@lists.altlinux.org>
Subject: Re: [devel] Q: alterator/installer: Какова политика взаимодействия между index.scm и ajax.scm?
Date: Tue, 6 Oct 2015 15:07:05 +0300
Message-ID: <5613B969.2030103@solin.spb.ru> (raw)
In-Reply-To: <560E82CD.6010701@solin.spb.ru>

[-- Attachment #1: Type: text/plain, Size: 3242 bytes --]

02.10.2015 16:12, Aleksey Avdeev пишет:
> Приветствую.
> 
>   Я запутался в текущих реалях alterator`а и installer`а. Прошу помощи:
> 
> 1. Какова текущая политика взаимодействия между index.scm и ajax.scm у
> интерфейсных модулей?
> 
> 2. Доступны ли действия определённые в ajax.scm, при выполнении
> index.scm в контексте инсталлятора?
> 
> 3. Каким образом определять функции, общие для index.scm и ajax.scm?
> (Вижу что во многих модулях такие функции сдублированы.)

  Анализируя документацию и код, удалось раскопать следующее:

1. Для отображения интерфейса модуля alteratora в инсталляторе
используется alterator-wizard, из пакета alterator-wizardface. При этом
для задания обработки действий по кнопкам next/previous/finish
используется модуль (alterator wizard) из пакета alterator-lookout.

2. В модуле (alterator wizard), в частности, определены следующие
функции, вполне работающие в ajax.scm (после подключения модуля):

а) wizard? -- возвращает #t, если wizard интерфейс активирован;

б) wizard-bind -- позволяет задавать указанное для кнопок
next/previous/finish;

в) wizard-update-activity -- позволяет управлять признаком активности
кнопок next/previous/finish;

  Т. е. для модуля, не имеющего кнопки Apply при выполнении в среде
installer`а (там её функционал, вызов ui-write, переложен на Next/Finish
из ui/wizard/index.scm, пакета alterator-wizardface), при отсутствии
логики в index.scm, ajax.scm выглядит при мерно так:

(define-module (ui <имя> ajax)
    ...
    :use-module (alterator ajax)
    ...
    :use-module (alterator wizard)
    ...
    :export (on-load))

...

(define (on-load)
  ...
  (if (wizard?)
    (begin
      (wizard-bind "next" (lambda() (and (ui-write) 'forward)))
      (wizard-bind "finish" (lambda() (and (ui-write) 'finish)))
    (form-bind "apply_button" "click" ui-write))
  ...
  )

  Но для web интерфейса, данный ajax.scm нельзя -- ahttpd не может
грузить (alterator wizard)...

3. Т. к. ahttpd грузить (alterator wizard) не может (и похоже что от
слов "вообще"), ajax.scm должен грузить (alterator wizard) динамически,
_только_ если он доступен.

  В конечном итоге, под alterator-standalone, alterator-wizard и ahttpd
у меня заработал следующий ajax.scm:

(define-module (ui <имя> ajax)
    ...
    :use-module (alterator ajax)
    ...
    :use-module (alterator algo) ; для dynamic-require
    ...
    :export (on-load))

...

(define (ui-apply-bind) ; функция задания действий
                        ; для динамический кнопок
  (form-bind "apply_button" "click" ui-write)) ; по умолчанию

(and (dynamic-require '(alterator wizard) 'wizard-bind) ; проверка
                        ; доступности модуля (alterator wizard) и
                        ; наличия в нём функции wizard-bind
  (use-modules (alterator wizard)) ; загрузка модуля, если он есть
  (and (wizard?)
    (define (ui-apply-bind) ; замена ui-apply-bind, если активен wizard
      (wizard-bind "next" (lambda() (and (ui-write) 'forward)))
      (wizard-bind "finish" (lambda() (and (ui-write) 'finish))))))

(define (on-load)
  ...
  (ui-apply-bind)
  ...
  )

  В общем, как-то так...

-- 

С уважением. Алексей.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 278 bytes --]

      reply	other threads:[~2015-10-06 12:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-02 13:12 Aleksey Avdeev
2015-10-06 12:07 ` Aleksey Avdeev [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5613B969.2030103@solin.spb.ru \
    --to=solo@solin.spb.ru \
    --cc=devel@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git