承接 vannut/statamic-weather-addon 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vannut/statamic-weather-addon

Composer 安装命令:

composer require vannut/statamic-weather-addon

包简介

Get weather for a location

README 文档

README

Display the current weather or a 7-day forecast for any lat/lon on earth.

Attention: This version (2) is a complete rewrite of the addon. Although it does the same: display a weather forecast; the used weatherprovider is different and some of the fields are renamed. So please pay attention when upgrading.

Visual Crossing

The weather data itself is coming from the Visual Crossing api. It's free for the first 1,000 records a day.

Installation

  1. Install add on through composer: composer require vannut/statamic-weather-addon "^2.0"
  2. Create an account at Visual Crossing.
  3. After signing in go to your account, you'll find a Key
  4. Go to your Statamic Control Panel and look for the Weather entry in the sidebar.
  5. Fill out the settings-form with your api-key and create a location to fetch the forecast for.
  6. Hit the fetch forecast button.
  7. Or Go to the Command line and perform the first initial fetch of your specific data: php artisan weather:fetchForecast

Renewing the forecast

Nothing is as changeable as the weather. Therefore this addon adds a hourly call to the scheduler of Statamic/Laravel. All you have to do is make sure the scheduler is run, by means of a cron-job. Take a look at Laravels documentation on this!

Usage

This addon does not provide any styling, it just caches the json response and passes the raw data through to the two tags.

You can find every field in the api-response on the api-docs of Visual Crossing.

Next to the data provided by the API, the addon adds a couple of nice additional fields:

{{ icon_fa }}           A fontawesome icon derived fron weather.0.icon
{{ wind_compass }}   Converted wind direction to N/S/SSW etc
{{ wind_bft }}       Wind speed in Beaufort
{{ uvi_color }}      Color representation of  the UV Index
{{ uvi_percentage }} Percentage where UVI 10 = 100%;
{{ fetched_at }}     Unix Epoch timestamp of the datetime when fetched from API

You'll have two tags to your disposal: {{ forecast }} and {{ current_weather }}

Simple 7 day forecast

With the {{ forecast }} tag you will be able to display a card per day with the forecast. It's a loop of different days in the forecast. Typically 7 or 15 days depending on the location.

Make sure you specify from which location you want the forecast:

<div class="flex bg-neutral-100">
    {{ forecast :locale="site" location-identifier="xyz123" }}
        <div class="rounded-xl bg-white">
            <div class="lining-nums p-4 text-center">
                {{ datetimeEpoch | iso_format("dddd") }}<br>
                {{ datetimeEpoch | iso_format("D MMM Y") }}<br>
            </div>
            <div class="pb-4 text-5xl flex justify-center">
                <i class="fal {{ icon_fa }}"></i>
            </div>
            <div class="pb-2 flex items-center justify-center">
                <div>
                    {{ tempmax | round }}<span class="text-neutral-700">&deg;C</span>
                </div>
                <div class="text-sm">
                    <span class="text-neutral-700">&nbsp;&nbsp; / </span>
                    {{ tempmin | round }}<span class="text-neutral-700">&deg;C</span>
                </div>
            </div>
            <div class="flex items-center justify-center pb-4">
                <div>
                    <i class="fal fa-wind"></i>
                    {{ wind_compass }} {{ wind_bft  }}<span class="text-neutral-700">Bft</span>
                </div>
            </div>
        </div>
    {{/forecast }}
</div>

Current weather

Want to display the current weather of your location? Use the {{ current_weather }} tag. As this is a json-collection you can get its data as following:

    {{ current_weather :locale="site" location-identifier="xyz123" }}
        <div class="bg-neutral-200 rounded-xl p-4 m-4">
            <div class="pb-4 text-5xl flex justify-center">
                <i class="fal {{ icon }}"></i>
            </div>
            <div>
                Current temperature: {{  temp }}<span class="text-neutral-700">&deg;C</span>
            </div>
            <div>
                Feels like: {{ feels_like }}<span class="text-neutral-700">&deg;C</span>
            </div>
        </div>
    {{ /current_weather }}

Compatible with Statamic v5 Addon on Packagist

vannut/statamic-weather-addon 适用场景与选型建议

vannut/statamic-weather-addon 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.75k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2021 年 04 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 vannut/statamic-weather-addon 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 vannut/statamic-weather-addon 我们能提供哪些服务?
定制开发 / 二次开发

基于 vannut/statamic-weather-addon 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2.75k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2021-04-30