MooTools 備有不少 plugin 在所謂 MooTools More,官網亦提供 More Builder 方便自訂下載。

不過若要下載 1)整套 More 所有元件,或 2)最新開發版本 有沒有簡單辦法呢?

寫這篇時才發現,原來 download 頁就有「Edge Build」可以抓最新 core build ,把網址 core 換成 more 應該就是最新的 More 了(其實也不確定,沒看到說明)

似乎已解決,只好把本文放分隔線後面……


另一個作法是到 More 的 GitHub Repository 把檔案複製下來,裡面就有 build.rb,會把各元件的原始碼合併起成一份 .js(預設包含 Core + More),附帶好處是要包哪些東西可以寫設定檔存起來。

記具體過程:

  1. cd some_directory
  2. git clone git://github.com/mootools/mootools-more.git
    cd mootools-more
  3. 這裡 Core 是以 submodule 方式管理,也要更新一下:
    git submodule init
    git submodule update
  4. 有興趣的話,看看 build.yml 的設定:
    • dependency_paths - 用來尋找相依檔案的路徑,預設為 Core 和 More 的 Source 目錄
    • build_path - 最後輸出的檔名
    • dependency_file -(原檔案中沒有這個項目)預設是 scripts.json,即每個 dependency_paths 下的 scripts.json 檔;內容描述具體會用到的檔案,以及各檔案的相依性
  5. 若想定義要排除哪些檔案,可以把每個 scripts.json 複製一份,改成自己的設定。
    當然 build.yml 裡的 dependency_file 也要跟著改名。
  6. 不確定是我的問題還是怎樣,開動前要修改一下 build.rb:
    1. def build
        @string ||= full_build
        @string.sub!('%build%', build_number)
        @string  # 加入這行才會傳回 @string,否則會輸出空檔案
      end
    2. builder = MooTools::Build.new({
        :dependency_paths => conf[:dependency_paths],
        :build_path => conf[:build_path],
        :dependency_file => conf[:dependency_file]   # 原本沒吃到這個設定
      })
  7. ruby build.rb

註:寫這文章的時候 Source/Native/URI.js 檔案編碼有問題,若輸出檔案不是 utf-8,可以檢查這個檔案。