Initial commit

This commit is contained in:
Joey Kimsey
2024-08-04 21:15:59 -04:00
parent c9d1fb983f
commit 0d469501ee
695 changed files with 70184 additions and 71 deletions

View File

@ -0,0 +1,26 @@
<?php
/**
* app/plugins/dashboards/controllers/dice.php
*
* This is the home controller for the dashboards plugin.
*
* @package TP Dashboards
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Controllers;
use TheTempusProject\Houdini\Classes\Views;
use TheTempusProject\Classes\Controller;
use TheTempusProject\Houdini\Classes\Template;
class Dashboards extends Controller {
public function index() {
self::$title = 'Dashboards - {SITENAME}';
self::$pageDescription = 'Your new home on the internet.';
Template::setTemplate( 'dashboards' );
Views::view( 'dashboards.index' );
}
}

View File

@ -0,0 +1,52 @@
/* for the google form */
form {
display: flex;
}
input[type="text"] {
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px 0 0 4px;
outline: none;
}
button {
padding: 10px 20px;
font-size: 16px;
border: 1px solid #ccc;
border-left: none;
border-radius: 0 4px 4px 0;
background-color: #f8f8f8;
cursor: pointer;
}
button:hover {
background-color: #e0e0e0;
}
/* for the weather */
#weather-widget {
border: 1px solid #ccc;
padding: 20px;
width: 300px;
margin: 20px auto;
text-align: center;
}
#zipcode {
padding: 5px;
width: calc(100% - 12px);
margin-bottom: 10px;
}
#lookup-btn {
padding: 5px 10px;
}
#weather-result {
margin-top: 20px;
}

View File

View File

@ -0,0 +1,100 @@
// chatGPT
function forwardToChatGPT() {
var query = document.getElementById("chatgptQuery").value;
var url = "https://chat.openai.com/?q=" + encodeURIComponent(query);
window.location.href = url;
}
// base script
$( document ).ready( function () {
console.log('dashboards.js loaded');
const apiKey = 'b502235c1de669b105047b6896f81eb6'; // Replace with your weather API key
const geoApiKey = '2c50be5398ec45e79655a590d62d6fd8'; // Replace with your geolocation API key
const zipcodeInput = document.getElementById('zipcode');
const lookupBtn = document.getElementById('lookup-btn');
const weatherResult = document.getElementById('weather-result');
// Get the stored zip code from cookies
const storedZipCode = getCookie('zipcode');
if (storedZipCode) {
zipcodeInput.value = storedZipCode;
getWeather(storedZipCode);
} else {
getZipCodeFromIP();
}
lookupBtn.addEventListener('click', function() {
const zipcode = zipcodeInput.value;
if (zipcode) {
setCookie('zipcode', zipcode, 7); // Store the zip code in a cookie for 7 days
getWeather(zipcode);
}
});
function getZipCodeFromIP() {
fetch(`https://api.ipgeolocation.io/ipgeo?apiKey=${geoApiKey}`)
.then(response => response.json())
.then(data => {
const zipcode = data.zipcode;
zipcodeInput.value = zipcode;
setCookie('zipcode', zipcode, 7);
getWeather(zipcode);
})
.catch(error => {
console.error('Error getting location:', error);
});
}
function getWeather(zipcode) {
fetch(`https://api.openweathermap.org/data/2.5/weather?zip=${zipcode}&appid=${apiKey}`)
.then(response => response.json())
.then(data => {
displayWeather(data);
})
.catch(error => {
console.error('Error fetching weather data:', error);
});
}
function displayWeather(data) {
if (data.cod === 200) {
weatherResult.innerHTML = `
<h4>Weather for ${data.name}</h4>
<p>Temperature: ${(data.main.temp - 273.15).toFixed(2)}°C</p>
<p>Condition: ${data.weather[0].description}</p>
`;
} else {
weatherResult.innerHTML = `<p>Error: ${data.message}</p>`;
}
}
function setCookie(name, value, days) {
const d = new Date();
d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000));
const expires = "expires=" + d.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/";
}
function getCookie(name) {
const nameEQ = name + "=";
const ca = document.cookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
});

View File

@ -0,0 +1,54 @@
<?php
/**
* app/plugins/dashboards/models/dashboards.php
*
* This class is used for the manipulation of the dashboards database table.
*
* @todo make this send a confirmation email
*
* @package TP Dashboards
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Dashboards as Plugin;
class Dashboards extends DatabaseModel {
public $tableName = 'dashboards';
public $databaseMatrix = [
[ 'name', 'varchar', '128' ],
];
public $plugin;
/**
* The model constructor.
*/
public function __construct() {
parent::__construct();
$this->plugin = new Plugin;
}
public function create( $name, $email, $dashboard ) {
if ( !$this->plugin->checkEnabled() ) {
Debug::info( 'Dashboards are disabled in the config.' );
return false;
}
$fields = [
'name' => $name,
'email' => $email,
'time' => time(),
'ip' => $_SERVER['REMOTE_ADDR'],
];
if ( !self::$db->insert( $this->tableName, $fields ) ) {
Debug::info( 'Dashboards::create - failed to insert to db' );
return false;
}
return self::$db->lastId();
}
}

View File

@ -0,0 +1,28 @@
<?php
/**
* app/plugins/dashboards/plugin.php
*
* This houses all of the main plugin info and functionality.
*
* @package TP Testing
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Plugins;
use TheTempusProject\Classes\Plugin;
class Dashboards extends Plugin {
public $pluginName = 'TP Dashboards';
public $pluginAuthor = 'JoeyK';
public $pluginWebsite = 'https://TheTempusProject.com';
public $modelVersion = '1.0';
public $pluginVersion = '3.0';
public $pluginDescription = 'A simple plugin for adding and showing custom user dashboards.';
public function __construct( $load = false ) {
parent::__construct( $load );
}
}

View File

@ -0,0 +1,31 @@
<?php
/**
* app/plugins/dashboards/templates/dashboards.inc.php
*
* This is the loader for the dashboards template.
*
* @package TP Dashboards
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Templates;
use TheTempusProject\Houdini\Classes\Components;
use TheTempusProject\Houdini\Classes\Navigation;
use TheTempusProject\Houdini\Classes\Views;
use TheTempusProject\Bedrock\Functions\Input;
use TheTempusProject\Models\Dashboards;
class DashboardsLoader extends DefaultLoader {
/**
* This is the function used to generate any components that may be
* needed by this template.
*/
public function __construct() {
$dashboards = new Dashboards;
$this->addJs( '<script language="JavaScript" crossorigin="anonymous" type="text/javascript" src="{ROOT_URL}app/plugins/dashboards/js/dashboards.js"></script>' );
parent::__construct();
}
}

View File

@ -0,0 +1,93 @@
<!DOCTYPE html>
<html lang="en">
<!--
* app/plugins/dashboards/templates/dashboards.tpl
*
* @package TP Dashboards
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta property="og:url" content="{CURRENT_URL}">
<meta name='twitter:card' content='summary' />
<title>{TITLE}</title>
<meta itemprop="name" content="{TITLE}">
<meta name="twitter:title" content="{TITLE}">
<meta property="og:title" content="{TITLE}">
<meta name="description" content="{PAGE_DESCRIPTION}">
<meta itemprop="description" content="{PAGE_DESCRIPTION}">
<meta name="twitter:description" content="{PAGE_DESCRIPTION}">
<meta property="og:description" content="{PAGE_DESCRIPTION}">
<meta itemprop="image" content="{META_IMAGE}">
<meta name="twitter:image" content="{META_IMAGE}">
<meta property="og:image" content="{META_IMAGE}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="The Tempus Project">
{ROBOT}
<link rel="alternate" hreflang="en-us" href="alternateURL">
<link rel="icon" href="{ROOT_URL}images/favicon.ico">
<!-- Required CSS -->
<link rel="stylesheet" href="{FONT_AWESOME_URL}font-awesome.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="{BOOTSTRAP_CDN}css/bootstrap-theme.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="{BOOTSTRAP_CDN}css/bootstrap.min.css" crossorigin="anonymous">
<!-- RSS -->
<link rel="alternate" href="{ROOT_URL}blog/rss" title="{TITLE} Feed" type="application/rss+xml" />
<!-- Custom styles for this template -->
{TEMPLATE_CSS_INCLUDES}
<link rel="stylesheet" href="{ROOT_URL}app/plugins/dashboards/css/dashboards.css" />
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<!--Brand and toggle should get grouped for better mobile display -->
<div class="navbar-header">
<a href="{ROOT_URL}" class="navbar-brand">{SITENAME}</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse" style="">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="container-fluid">
<div class="collapse navbar-collapse navbar-ex1-collapse">
{topNavLeft}
<div class="navbar-right">
<ul class="nav navbar-nav">
{topNavRight}
</ul>
</div>
</div>
</div>
</nav>
<div class="container-fluid top-pad foot-pad">
{ISSUES}
<div class="container">
<div class="row">
{ERROR}
{NOTICE}
{SUCCESS}
{INFO}
</div>
</div>
{/ISSUES}
<div class="container">
<div class="row">
{CONTENT}
</div>
</div>
</div>
<footer>
{COPY}
</footer>
<!-- Bootstrap core JavaScript and jquery -->
<script src="{JQUERY_CDN}jquery.min.js" crossorigin="anonymous"></script>
<script src="{BOOTSTRAP_CDN}js/bootstrap.min.js" crossorigin="anonymous"></script>
<!-- Custom javascript for this template -->
{TEMPLATE_JS_INCLUDES}
</body>
</html>

View File

@ -0,0 +1,27 @@
this is the dashboard index
<h3>Google Search</h3>
<form action="https://www.google.com/search" method="GET">
<input type="text" name="q" placeholder="Search Google" required>
<button type="submit">Search</button>
</form>
<h3>Ask ChatGPT</h3>
<form onsubmit="event.preventDefault(); forwardToChatGPT();">
<textarea id="chatgptQuery" rows="10" cols="50" maxlength="4096"></textarea><br>
<button type="submit">Submit</button>
</form>
<h3>Weather Lookup</h3>
<div id="weather-widget">
<input type="text" id="zipcode" placeholder="Enter Zip Code">
<button id="lookup-btn">Lookup Weather</button>
<div id="weather-result"></div>
</div>