updates
This commit is contained in:
@@ -3,6 +3,6 @@ class HomeController < ApplicationController
|
||||
def index
|
||||
Time.zone = 'Pacific Time (US & Canada)'
|
||||
@year = params['year'].nil? ? Date.today.year : params['year'].to_i
|
||||
@events = [Event.new]
|
||||
@events = CalendarService.new.events + CalendarService.new.vacations
|
||||
end
|
||||
end
|
||||
|
||||
52
app/models/calendar_service.rb
Normal file
52
app/models/calendar_service.rb
Normal file
@@ -0,0 +1,52 @@
|
||||
require 'http'
|
||||
|
||||
class CalendarService
|
||||
|
||||
def vacations
|
||||
Rails.cache.fetch("vacations", expires_in: 5.minutes) do
|
||||
entries("https://static.nocoda.io/remote.php/dav/calendars/pkamin/593FC5A0-746B-48C7-A57B-3A0315976412/?export", "ff00ff")
|
||||
end
|
||||
end
|
||||
|
||||
def events
|
||||
Rails.cache.fetch("events", expires_in: 5.minutes) do
|
||||
entries("https://static.nocoda.io/remote.php/dav/calendars/pkamin/774BE10B-AEAD-4D20-BF09-9C0FFD135E56/?export", "0000ff")
|
||||
end
|
||||
end
|
||||
|
||||
def sports
|
||||
entries("https://static.nocoda.io/remote.php/dav/calendars").map do |entry|
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def entries(url, color)
|
||||
#
|
||||
a = HTTP.basic_auth(user: 'pkamin', pass: 'QDH*@8fhWekxwWjeX8MQ3H').get(url).body.to_s
|
||||
# a = File.read('/Users/pkamin/Desktop/vacation.vcalendar')
|
||||
|
||||
b = a.split("\r\n")
|
||||
|
||||
events = []
|
||||
e = nil
|
||||
|
||||
b.each do |line|
|
||||
if line == "BEGIN:VEVENT"
|
||||
e = Event.new
|
||||
e.color = color
|
||||
elsif line == "END:VEVENT"
|
||||
events << e unless e.nil?
|
||||
elsif line.start_with?("DTSTART") && ! e.nil?
|
||||
e.begin_at = DateTime.parse(line.split(":").last)
|
||||
elsif line.start_with?("DTEND") && ! e.nil?
|
||||
e.end_at = DateTime.parse(line.split(":").last)
|
||||
e.end_at = e.end_at - 1.minute
|
||||
elsif line.start_with?("SUMMARY") && ! e.nil?
|
||||
e.name = line.split(":").last
|
||||
end
|
||||
end
|
||||
|
||||
events
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
class Event
|
||||
attr_reader :begin_at, :end_at
|
||||
attr_accessor :begin_at, :end_at, :name, :color
|
||||
|
||||
def initialize
|
||||
@begin_at = DateTime.now.beginning_of_day
|
||||
@end_at = DateTime.now + 1.day
|
||||
def initialize(begin_at = DateTime.now.beginning_of_day, end_at = DateTime.now.end_of_day)
|
||||
@begin_at = begin_at
|
||||
@end_at = end_at
|
||||
end
|
||||
|
||||
def during?(d)
|
||||
self.begin_at <= d && d <= self.end_at
|
||||
end
|
||||
|
||||
def first_day?(d)
|
||||
self.begin_at.beginning_of_day <= d && d <= self.begin_at.end_of_day
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,12 @@
|
||||
</div>
|
||||
<div class="w-full flex-grow flex justify-end">
|
||||
<% todays_events.each do |event| %>
|
||||
<div class="w-2 bg-red-700 cursor-pointer" title="test" data-toggle="tooltip" data-placement="right"></div>
|
||||
<div class="text-xs">
|
||||
<% event.name if event.first_day?(day)%>
|
||||
</div>
|
||||
<div class="w-2 cursor-pointer" style="background-color: #<%=event.color %>;" title="<%= event.name %>" data-toggle="tooltip" data-placement="right">
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
16
node_modules/.yarn-integrity
generated
vendored
Normal file
16
node_modules/.yarn-integrity
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"systemParams": "darwin-x64-111",
|
||||
"modulesFolders": [
|
||||
"node_modules"
|
||||
],
|
||||
"flags": [],
|
||||
"linkedModules": [],
|
||||
"topLevelPatterns": [
|
||||
"stimulus-popover@^6.2.0"
|
||||
],
|
||||
"lockfileEntries": {
|
||||
"stimulus-popover@^6.2.0": "https://registry.yarnpkg.com/stimulus-popover/-/stimulus-popover-6.2.0.tgz#67bcf725d9077f213869905e7b5c80212a92d802"
|
||||
},
|
||||
"files": [],
|
||||
"artifacts": {}
|
||||
}
|
||||
1
node_modules/stimulus-popover/.eslintignore
generated
vendored
Normal file
1
node_modules/stimulus-popover/.eslintignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
dist
|
||||
3
node_modules/stimulus-popover/.prettierrc
generated
vendored
Normal file
3
node_modules/stimulus-popover/.prettierrc
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"printWidth": 120
|
||||
}
|
||||
98
node_modules/stimulus-popover/CHANGELOG.md
generated
vendored
Normal file
98
node_modules/stimulus-popover/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [6.2.0] - 2022-12-23
|
||||
|
||||
### Added
|
||||
|
||||
- Adding `name` in library export to use the package with CDN, Sprockets and `import-maps`.
|
||||
|
||||
### Chore
|
||||
|
||||
- Bump dependencies.
|
||||
- Upgrading to Vite `4.x`.
|
||||
- Docs new UI.
|
||||
|
||||
## [6.1.0] - 2022-08-12
|
||||
|
||||
### Chore
|
||||
|
||||
- Using `mouseenter` and `mouseleave` events
|
||||
- Fix error when target is null
|
||||
|
||||
## [6.0.0] - 2022-08-12
|
||||
|
||||
### Chore
|
||||
|
||||
- **Breaking** Upgrading Stimulus to `3.x` and change namespace from `stimulus` to `@hotwired/stimulus`.
|
||||
- Upgrading dependencies
|
||||
- Upgrading Node to 16
|
||||
- Updating Workflows
|
||||
|
||||
## [5.0.1] - 2021-06-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- Using `currentTarget` instead of `target` to select the element.
|
||||
|
||||
## [5.0.0] - 2021-06-02
|
||||
|
||||
### Chore
|
||||
|
||||
- Moving from [Snowpack](https://www.snowpack.dev/) to [Vite](https://vitejs.dev/)
|
||||
- Using stimulus as external library reducing bundle size from `40.66kb` to `0.61kb`.
|
||||
- Moving to [TypeScript](https://www.typescriptlang.org/).
|
||||
- Upgrading Node to 14.17.0
|
||||
|
||||
## [4.0.0] - 2020-12-05
|
||||
|
||||
### Added
|
||||
|
||||
- Support for Stimulus 2.0
|
||||
- Prevent error if the url is empty when using remote card.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Breaking** Using the new `values` static property
|
||||
|
||||
```diff
|
||||
- <div data-controller="popover" data-popover-url="/card.html">
|
||||
+ <div data-controller="popover" data-popover-url-value="/card.html">
|
||||
```
|
||||
|
||||
- **Breaking** Using the new syntax for `targets`.
|
||||
|
||||
```diff
|
||||
- <div data-controller="popover" data-target="popover.card">
|
||||
+ <div data-controller="popover" data-popover-target="card">
|
||||
```
|
||||
|
||||
## [3.0.0] - 2020-11-18
|
||||
|
||||
### Changed
|
||||
**Breaking** - Removing Tippy as dependency.
|
||||
**Breaking** - Rename `mouseOver` to `show`.
|
||||
|
||||
### Added
|
||||
- Add `hide` action.
|
||||
|
||||
## [2.0.0] - 2020-11-10
|
||||
### Added
|
||||
- Adding `tippyOptions` getter to simply override default options.
|
||||
- `tippy` instance is now a singleton.
|
||||
- Destroy `tippy` instance on disconnect.
|
||||
|
||||
### Changed
|
||||
**Breaking** - Removing `mouseOut` action.
|
||||
**Breaking** - `popover` action does not return a new `tippy` instance.
|
||||
|
||||
## [1.0.0] - 2020-10-20
|
||||
|
||||
### Added
|
||||
|
||||
- Adding controller
|
||||
21
node_modules/stimulus-popover/LICENSE
generated
vendored
Normal file
21
node_modules/stimulus-popover/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Guillaume Briday
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
22
node_modules/stimulus-popover/README.md
generated
vendored
Normal file
22
node_modules/stimulus-popover/README.md
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Stimulus Popover
|
||||
|
||||
[](https://www.npmjs.com/package/stimulus-popover)
|
||||
[](https://www.npmjs.com/package/stimulus-popover)
|
||||
[](https://github.com/stimulus-components/stimulus-popover)
|
||||
[](https://github.com/stimulus-components/stimulus-popover)
|
||||
|
||||
## Getting started
|
||||
|
||||
A Stimulus controller to deal with HTML popover.
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
See [stimulus-popover documentation](https://www.stimulus-components.com/docs/stimulus-popover/).
|
||||
|
||||
## 👷♂️ Contributing
|
||||
|
||||
Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.
|
||||
|
||||
## 📝 License
|
||||
|
||||
This project is released under the [MIT](http://opensource.org/licenses/MIT) license.
|
||||
18
node_modules/stimulus-popover/card.html
generated
vendored
Normal file
18
node_modules/stimulus-popover/card.html
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<div
|
||||
data-popover-target="card"
|
||||
class="max-w-sm rounded shadow-lg bg-white absolute left-0"
|
||||
style="bottom: 2rem; width: max-content;"
|
||||
>
|
||||
<div class="px-6 py-4 flex">
|
||||
<img
|
||||
class="rounded-full h-16 w-16"
|
||||
src="https://avatars0.githubusercontent.com/u/8252238?s=460&u=3ba211d048536bfe01d120894eba9d3254db70d5&v=4"
|
||||
alt=""
|
||||
/>
|
||||
|
||||
<div class="ml-4">
|
||||
<div class="font-bold text-xl mb-2 text-black">Guillaume Briday</div>
|
||||
<p class="text-gray-500 text-sm">This content is loaded with AJAX.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
32
node_modules/stimulus-popover/dist/stimulus-popover.mjs
generated
vendored
Normal file
32
node_modules/stimulus-popover/dist/stimulus-popover.mjs
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Controller as o } from "@hotwired/stimulus";
|
||||
class r extends o {
|
||||
async show(e) {
|
||||
const n = e.currentTarget;
|
||||
let t = null;
|
||||
if (this.hasContentTarget ? t = this.contentTarget.innerHTML : t = await this.fetch(), !t)
|
||||
return;
|
||||
const a = document.createRange().createContextualFragment(t);
|
||||
n.appendChild(a);
|
||||
}
|
||||
hide() {
|
||||
this.hasCardTarget && this.cardTarget.remove();
|
||||
}
|
||||
async fetch() {
|
||||
if (!this.remoteContent) {
|
||||
if (!this.hasUrlValue) {
|
||||
console.error("[stimulus-popover] You need to pass an url to fetch the popover content.");
|
||||
return;
|
||||
}
|
||||
const e = await fetch(this.urlValue);
|
||||
this.remoteContent = await e.text();
|
||||
}
|
||||
return this.remoteContent;
|
||||
}
|
||||
}
|
||||
r.targets = ["card", "content"];
|
||||
r.values = {
|
||||
url: String
|
||||
};
|
||||
export {
|
||||
r as default
|
||||
};
|
||||
1
node_modules/stimulus-popover/dist/stimulus-popover.umd.js
generated
vendored
Normal file
1
node_modules/stimulus-popover/dist/stimulus-popover.umd.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(function(t,e){typeof exports=="object"&&typeof module<"u"?module.exports=e(require("@hotwired/stimulus")):typeof define=="function"&&define.amd?define(["@hotwired/stimulus"],e):(t=typeof globalThis<"u"?globalThis:t||self,t.StimulusPopover=e(t.Stimulus))})(this,function(t){"use strict";class e extends t.Controller{async show(r){const s=r.currentTarget;let n=null;if(this.hasContentTarget?n=this.contentTarget.innerHTML:n=await this.fetch(),!n)return;const o=document.createRange().createContextualFragment(n);s.appendChild(o)}hide(){this.hasCardTarget&&this.cardTarget.remove()}async fetch(){if(!this.remoteContent){if(!this.hasUrlValue){console.error("[stimulus-popover] You need to pass an url to fetch the popover content.");return}const r=await fetch(this.urlValue);this.remoteContent=await r.text()}return this.remoteContent}}return e.targets=["card","content"],e.values={url:String},e});
|
||||
47
node_modules/stimulus-popover/package.json
generated
vendored
Normal file
47
node_modules/stimulus-popover/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "stimulus-popover",
|
||||
"version": "6.2.0",
|
||||
"description": "A Stimulus controller to deal with HTML popover.",
|
||||
"keywords": [
|
||||
"stimulus",
|
||||
"stimulusjs",
|
||||
"stimulus controller",
|
||||
"popover"
|
||||
],
|
||||
"repository": "git@github.com:stimulus-components/stimulus-popover.git",
|
||||
"bugs": {
|
||||
"url": "https://github.com/stimulus-components/stimulus-popover/issues"
|
||||
},
|
||||
"author": "Guillaume Briday <guillaumebriday@gmail.com>",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/stimulus-components/stimulus-popover",
|
||||
"private": false,
|
||||
"main": "dist/stimulus-popover.umd.js",
|
||||
"module": "dist/stimulus-popover.mjs",
|
||||
"scripts": {
|
||||
"format": "prettier-standard '**/*.{ts,css,html}' --format",
|
||||
"lint": "prettier-standard '**/*.{ts,css,html}' --lint",
|
||||
"dev": "vite",
|
||||
"prod": "vite build --mode netlify",
|
||||
"build": "tsc --noEmit && vite build",
|
||||
"version": "yarn build",
|
||||
"np": "np --no-2fa --no-test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.20.7",
|
||||
"@babel/plugin-syntax-class-properties": "7.12.13",
|
||||
"@babel/preset-env": "^7.20.2",
|
||||
"@babel/preset-typescript": "^7.18.6",
|
||||
"@hotwired/stimulus": "^3.2.1",
|
||||
"autoprefixer": "^10.4.13",
|
||||
"np": "^7.6.2",
|
||||
"postcss": "^8.4.20",
|
||||
"prettier-standard": "16.4.1",
|
||||
"tailwindcss": "^3.2.4",
|
||||
"typescript": "^4.9.4",
|
||||
"vite": "^4.0.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@hotwired/stimulus": "^3.1.0"
|
||||
}
|
||||
}
|
||||
5
package.json
Normal file
5
package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"stimulus-popover": "^6.2.0"
|
||||
}
|
||||
}
|
||||
33
test.rb
Normal file
33
test.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
require 'http'
|
||||
|
||||
# url = "https://static.nocoda.io/remote.php/dav/calendars/pkamin/774BE10B-AEAD-4D20-BF09-9C0FFD135E56/?export"
|
||||
# a = HTTP.basic_auth(user: 'pkamin', pass: 'QDH*@8fhWekxwWjeX8MQ3H').get(url).body.to_s
|
||||
|
||||
# File.write('/Users/pkamin/Desktop/vacation.vcalendar', a)
|
||||
|
||||
a = File.read('/Users/pkamin/Desktop/vacation.vcalendar')
|
||||
|
||||
b = a.split("\r\n")
|
||||
|
||||
events = []
|
||||
e = nil
|
||||
|
||||
puts a.length
|
||||
b.each do |line|
|
||||
puts line
|
||||
if line == "BEGIN:VEVENT"
|
||||
puts "new e"
|
||||
e = Struct.new(:begin_at, :end_at)
|
||||
elsif line == "END:VEVENT"
|
||||
puts "end"
|
||||
events << e unless e.nil?
|
||||
elsif line.start_with?("DTSTART")
|
||||
puts "begin"
|
||||
e.begin_at = DateTime.parse(line.split(":")[1]) unless e.nil?
|
||||
elsif line.start_with?("DTEND")
|
||||
puts 'end'
|
||||
e.end_at = DateTime.parse(line.split(":")[1]) unless e.nil?
|
||||
end
|
||||
end
|
||||
|
||||
puts events
|
||||
8
yarn.lock
Normal file
8
yarn.lock
Normal file
@@ -0,0 +1,8 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
stimulus-popover@^6.2.0:
|
||||
version "6.2.0"
|
||||
resolved "https://registry.yarnpkg.com/stimulus-popover/-/stimulus-popover-6.2.0.tgz#67bcf725d9077f213869905e7b5c80212a92d802"
|
||||
integrity sha512-QJqGXA842qS9s+c0Si6JUKDHDZVnkClvgZPfl2KbHcT6G9BMrEK+21na00SVNpWmmzdc6E1qQrq/oVY7gGaf3w==
|
||||
Reference in New Issue
Block a user