Blockscout 相关笔记

Dockerfile打包

打包ID

由于最新版本的打包websocket推送区块总感觉一卡一卡的,具体后台会有这个打印application=indexer fetcher=block_catchup first_block_number=1243301 last_block_number=0 missing_block_count=2 shrunk=false [info] Index had to catch up,旧版本不会这样。所以选择某个点 git checkout d7954e032792 修复了erc721的链接 ...instance/1/token-transfers 的进行打包 (应该Mar 26, 2022 at 10:24 pm都行)。

内容修改

因为有些内容不想显示,采用sed替换掉一些东西。

ARG COIN
ARG THEME
ARG LOGO
ARG FAVICON
RUN if [ "$COIN" != "" ]; then \
        sed -i s/"POA"/"${COIN}"/g apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po; \
        sed -i "/msgid \"Ether\"/{n;s/msgstr \"\"/msgstr \"${COIN}\"/g}" apps/block_scout_web/priv/gettext/default.pot; \
        sed -i "/msgid \"Ether\"/{n;s/msgstr \"\"/msgstr \"${COIN}\"/g}" apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po; \
    fi && \
    sed -i s/"<div class=\"footer-body container\">"/"<div class=\"footer-body container\" style=\"display:none\">"/g apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex && \
    sed -i 176c"        <li class=\"nav-item dropdown\" style=\"display:none\">" apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex && \
    sed -i s/"export function compareChainIDs (explorerChainId, walletChainIdHex) {"/"export function compareChainIDs (explorerChainId, walletChainIdHex) { return Promise.resolve()"/g apps/block_scout_web/assets/js/lib/smart_contract/common_helpers.js && \
    sed -i s/"memory_limit: 1 <<< 30"/"memory_limit: 5 <<< 30"/g apps/indexer/config/config.exs && \
    if [ "$THEME" != "" ]; then \
        sed -i s/"neutral_variables"/"${THEME}"/g apps/block_scout_web/assets/css/theme/_variables.scss; \
    fi && \
    if [ "$LOGO" != "" ]; then \
        wget -O apps/block_scout_web/assets/static/images/custom_logo.png "$LOGO"; \
    fi && \
    if [ "$FAVICON" != "" ]; then \
        rm apps/block_scout_web/assets/static/images/favicon.ico; \
        rm apps/block_scout_web/assets/static/images/favicon-16x16.png; \
        rm apps/block_scout_web/assets/static/images/favicon-32x32.png; \
        wget -O apps/block_scout_web/assets/static/images/favicon.ico "$FAVICON"; \
        wget -O apps/block_scout_web/assets/static/images/favicon-16x16.png "$FAVICON"; \
        wget -O apps/block_scout_web/assets/static/images/favicon-32x32.png "$FAVICON"; \
    fi

替换的内容分别是:货币单位,页脚不显示,菜单不显示链链接,排除只能用metamask调用以太坊链,获取交易数据内存够加大,替换logo,替换favicon。

打包命令

  • 打包 docker build -t luchenqun/blockscout:nelo -f ./docker/Dockerfile .
  • 更新货币单位 docker build --build-arg COIN=Nelo -t luchenqun/blockscout:nelo -f ./docker/Dockerfile .
  • docker build --build-arg COIN=Nelo --build-arg LOGO=https://s3.bmp.ovh/imgs/2022/03/e3d7db6dfa9a4656.png --build-arg FAVICON=https://s3.bmp.ovh/imgs/2022/03/8f307ca0c331d0eb.png -t luchenqun/blockscout:nelo -f ./docker/Dockerfile .
  • docker build --build-arg COIN=VLS --build-arg THEME=rsk_variables -t luchenqun/blockscout:vls -f ./docker/Dockerfile .

增加首页

修改文件:apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex

<li class="nav-item">
    <%= link to: webapp_url(@conn), class: "nav-link topnav-nav-link" do %>
      <span class="nav-link-icon">
        <svg t="1643349338854" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2096" width="18" height="18" xmlns:xlink="http://www.w3.org/1999/xlink">
          <path d="M960.211687 366.359427l-82.416759-57.578831L877.794928 88.061742c0-3.38699-2.257993-5.644983-5.644983-5.644983l-109.512679 0c-3.38699 0-5.644983 2.257993-5.644983 5.644983l0 136.6086L526.676957 63.223815c-2.822492-1.693495-6.209482-2.822492-9.031974-2.257993-2.822492 0-6.209482 0.564498-9.031974 2.257993L72.820287 364.101433c-5.644983 3.951488-7.338479 11.289967-3.951488 16.370452l25.966924 37.821389c3.38699 5.080485 11.289967 6.209482 16.93495 2.257993l405.309813-279.99118 403.616318 282.249173c5.644983 3.951488 13.54796 3.38699 16.93495-1.693495l26.531422-37.821389C968.114664 378.213892 965.85667 370.875413 960.211687 366.359427zM151.285557 445.953693l0 256.846748L151.285557 937.067255l0 3.951488c0 6.209482 5.080485 11.289967 11.289967 11.289967L163.70452 952.30871c1.693495 0.564498 2.822492 0.564498 4.515987 0.564498l235.39581-0.564498 16.370452 0c6.209482 0 11.289967-5.080485 11.289967-11.289967l0-10.16097 0 0 0-283.37817 170.478501 0 0 164.269019 0 130.399118c0 6.209482 5.080485 11.289967 11.289967 11.289967l11.289967 0 241.040794 0 5.080485 0c6.209482 0 11.289967-5.080485 11.289967-11.289967l0-1.128997c0-1.128997 0.564498-2.257993 0.564498-3.38699L882.310915 445.953693 521.596472 194.187431 151.285557 445.953693z" p-id="2097">
          </path>
        </svg>
      </span>
      Home
    <% end %>
</li>

替换图片

为了不修改代码,可以使用nginx进行转发。将图片上传到Imgurl之后进行替换。

location ^~ /images/blockscout_logo {
    rewrite ^(.*) https://s3.bmp.ovh/imgs/2022/03/3caec5efce6a5222.png;
}
location ^~ /images/favicon {
    rewrite ^(.*) https://s3.bmp.ovh/imgs/2022/03/8f307ca0c331d0eb.png;
}

也可以在打包docker的时候,下载图片放到目录里面wget -O apps/block_scout_web/assets/static/images/logo.png https://nft.nelo.world/images/logo.png
还可以在打包docker的时候,采用sed图片 sed -i s/"<%= static_path(@conn, logo()) %>"/"https://s3.bmp.ovh/imgs/2022/03/ecb20a8e76813b9c.png"/g apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex

同理,替换文件app.html.eex 中的 <link rel="shortcut icon" type='image/x-icon' href="<%= static_path(@conn, "/images/favicon.ico") %>"> 可替换favicon。

主题更换

blockscout 在 apps/block_scout_web/assets/css/theme/_variables.scss 放了一些主题。只需要注释@import "neutral_variables";然后打开需要的主题即可。在调试环境下面。需要先删除 apps/block_scout_web/priv/static 已经编译好的目录,然后再次使用命令 mix phx.server 启动程序,启动程序一会儿后,它会主动编译静态文件。参考链接CSS Configuration & Presets

暂无评论

发送评论 编辑评论


				
上一篇
下一篇