### YATA Local Setup Source: https://github.com/kivou-2000607/yata/blob/master/README.md Steps to clone the YATA repository, install Python dependencies, and set up the local environment. ```Shell git clone https://github.com/Kivou-2000607/yata.git cd yata pip install -U pip pip install -r requirements.txt ``` -------------------------------- ### YATA Cron Job Execution Source: https://github.com/kivou-2000607/yata/blob/master/README.md Instructions for running the development cron jobs and viewing a production crontab example. ```Shell # To emulate cron activity ./cron/dev_cron.py can be run as a seperate process. # Cron jobs designed to run on a per minute basis will be run as such. # Cron's with a longer delay will run on a 30 minute schedule. python ./cron/dev_cron.py # See an example of a production crontab cat ./cron/crontab.txt ``` -------------------------------- ### YATA Initialization and Running Source: https://github.com/kivou-2000607/yata/blob/master/README.md Commands to initialize the project setup and run the Django development server. ```Shell python setup.py python manage.py runserver ``` -------------------------------- ### Install and Use Pre-commit for Consistent Coding Style Source: https://github.com/kivou-2000607/yata/blob/master/CONTRIBUTING.md This snippet shows how to install the pre-commit tool and set it up to enforce consistent coding style within the YATA project. Pre-commit helps maintain code quality and uniformity across contributions. ```bash pip install pre-commit pre-commit install ``` -------------------------------- ### YATA Admin Interface Access Source: https://github.com/kivou-2000607/yata/blob/master/README.md Details on how to access the Django admin interface and default login credentials. ```APIDOC Accessing the Admin Interface: URL: http://127.0.0.1:8000/admin Username: admin Password: adminpass ``` -------------------------------- ### jQuery UI Styling and Layout Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Provides CSS for styling the jQuery UI example page, including font settings, margins, and styles for dialog links and icons. It relies on jQuery UI's CSS framework. ```CSS body { font-family: "Trebuchet MS", sans-serif; margin: 50px; } .demoHeaders { margin-top: 2em; } #dialog-link { padding: .4em 1em .4em 20px; text-decoration: none; position: relative; } #dialog-link span.ui-icon { margin: 0 5px 0 0; position: absolute; left: .2em; top: 50%; margin-top: -8px; } #icons { margin: 0; padding: 0; } #icons li { margin: 2px; position: relative; padding: 4px 0; cursor: pointer; float: left; list-style: none; } #icons span.ui-icon { float: left; margin: 0 4px; } .fakewindowcontain .ui-widget-overlay { position: absolute; } select { width: 200px; } ``` -------------------------------- ### YATA Environment Configuration (.env) Source: https://github.com/kivou-2000607/yata/blob/master/README.md Configuration options for the local .env file, including database settings, secret keys, and optional parameters for caching and cron job execution. ```Shell ###### REQUIRED ###### DEBUG=True SECRET_KEY="xxx" ALLOWED_HOSTS="*" LOG_KEY="xxx" ADMIN_URL_PREFIX="prefix/" # Enter a prefix for your admin URL with a trailing slash. # Database selection DATABASE=sqlite #DATABASE=postgresql #PG_NAME=yata #PG_USER=username #PG_PASSWORD=password #PG_HOST=localhost #PG_PORT=5432 #PG_CONN_MAX_AGE=600 ###### OPTIONAL ###### # For most leaving this as default should be fine, but if you have any issues with -4 cache responses you may wish to increase this gradually CACHE_RESPONSE=10 # The amount of chain report crontabs to run when running crons manually via python ./cron/dev_cron.py CHAIN_REPORT = 1 # The amount of attack report crontabs to run when running crons manually via python ./cron/dev_cron.py ATTACK_REPORT = 1 # The amount of revive report crontabs to run when running crons manually via python ./cron/dev_cron.py REVIVE_REPORT = 1 # REDIS #USE_REDIS=True #REDIS_HOST="redis://178.62.1.116:6379/1" #REDIS_PASSWORD="xxx" # SENTRY # Sentry for error capture ENABLE_SENTRY=False #SENTRY_DSN=YOURDSN #SENTRY_ENVIRONMENT=dev #SENTRY_SAMPLE_RATE=1.0 ``` -------------------------------- ### jQuery UI Button Widgets Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Demonstrates the initialization of basic and icon-only buttons using the 'button' widget. The icon-only button hides the label. ```JavaScript $( "#button" ).button(); $( "#button-icon" ).button({ icon: "ui-icon-gear", showLabel: false }); ``` -------------------------------- ### jQuery UI Menu Widget Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Initializes the menu widget on an element with the ID 'menu', creating a navigable menu interface. ```JavaScript $( "#menu" ).menu(); ``` -------------------------------- ### jQuery UI Tooltip Widget Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Initializes the tooltip widget on an element with the ID 'tooltip', displaying helpful information on hover. ```JavaScript $( "#tooltip" ).tooltip(); ``` -------------------------------- ### YATA Bazaar Default Items Configuration Source: https://github.com/kivou-2000607/yata/blob/master/README.md Steps to modify the default items displayed on the YATA bazaar page via the admin interface. ```APIDOC Modifying Bazaar Default Items: 1. Logon To the Admin Section 2. Go to the Items table 3. Select the item you wish to add 4. Enable the flag "OnMarket" 5. Save ``` -------------------------------- ### Foreign Stock Import API Source: https://github.com/kivou-2000607/yata/blob/master/templates/api.html Imports foreign stock data via a POST request. Includes payload structure, example data, country keys, and notes on data handling and verification. ```APIDOC API Endpoint: /api/importStocks Method: POST Payload: Object { "client": String, "version": String, "author_name": String, "author_id": Number, "country": String, "items": Array [ Object { "id": Number, "quantity": Number, "cost": Number }, ... ] } Example Payload: { "client": "My cool script", "version": "v0.1", "author_name": "Kivou", "author_id": 2000607, "country": "uni", "items": [ { "id": 268, "quantity": 339, "cost": 1000 }, { "id": 266, "quantity": 1, "cost": 200 } ] } Country Keys: uni: United Kingdom mex: Mexico cay: Cayman Islands can: Canada haw: Hawaii arg: Argentina swi: Switzerland jap: Japan chi: China uae: UAE sou: South Africa Notes: - If an item is not in the list for a country, its quantity is set to 0. - This request clears the /api/exportStocks cache. - Client must be a "verified client" to write to the database. ``` -------------------------------- ### JavaScript Initialization and Event Handling Source: https://github.com/kivou-2000607/yata/blob/master/templates/faction/attacks/index.html Initializes tablesorter for the attacks report table, sets default date values, and sets up Bootstrap tooltips. It also configures datetimepicker instances for start and end dates, with event handlers to update hidden timestamp fields and validate date ranges before showing the 'Create report' button. ```JavaScript $(document).ready(function() { $("#faction-attacks-report").tablesorter({cssAsc: 'up', cssDesc: 'down', sortList: [[1,1]]}); $("#date-start").val(""); $("#date-end").val(""); var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { return new bootstrap.Tooltip(tooltipTriggerEl, {html: true}); }); $(function () { $("#date-start").datetimepicker({ step: 15, onChangeDateTime:function(dp,$input){ var d = new Date($input.val()); var dUTC = Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds()); $("#ts-start").val(dUTC/1000); var s = new Date(dUTC).toUTCString().replace("GMT", ""); $("#date-start").removeClass("is-invalid").addClass("is-valid"); $("#date-live-attacks").prop('checked', false); var start = parseInt($("#ts-start").val()); var end = parseInt($("#ts-end").val()); if(!end) { $("#date-end").removeClass("is-valid").addClass("is-invalid"); $("#create-report-attacks").hide() } else if(end < start) { $("#date-end").removeClass("is-valid").addClass("is-invalid"); $("#create-report-attacks").hide() } else { $("#date-end").removeClass("is-invalid").addClass("is-valid"); $("#create-report-attacks").show() } }, }); }); $(function () { $("#date-end").datetimepicker({ step: 15, onChangeDateTime:function(dp,$input){ var d = new Date($input.val()); var dUTC = Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds()); $("#ts-end").val(dUTC/1000); var s = new Date(dUTC).toUTCString().replace("GMT", ""); $("#date-end").removeClass("is-invalid").addClass("is-valid"); $("#date-live-attacks").prop('checked', false); var start = parseInt($("#ts-start").val()); var end = parseInt($("#ts-end").val()); if(!start) { $("#date-start").removeClass("is-valid").addClass("is-invalid"); $("#create-report-attacks").hide() } else if(end < start) { $("#date-start").removeClass("is-valid").addClass("is-invalid"); $("#create-report-attacks").hide() } else { $("#date-start").removeClass("is-invalid").addClass("is-valid"); $("#create-report-attacks").show() } }, }); }) }); ``` -------------------------------- ### Database Connector Source: https://github.com/kivou-2000607/yata/blob/master/requirements.txt The psycopg2-binary package for connecting to PostgreSQL databases. ```Python psycopg2-binary==2.9.3 ``` -------------------------------- ### jQuery UI Selectmenu Widget Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Initializes the selectmenu widget on an element with the ID 'selectmenu', enhancing standard select dropdowns. ```JavaScript $( "#selectmenu" ).selectmenu(); ``` -------------------------------- ### YATA Welcome and Information Display Source: https://github.com/kivou-2000607/yata/blob/master/templates/header.html This snippet displays a welcome message to the player and provides information about data visibility within a faction. It uses conditional logic to show different content based on player status and permissions. It also includes links to Discord and account deletion. ```HTML {% comment %} Copyright 2019 kivou.2000607@gmail.com This file is part of yata. yata is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. yata is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with yata. If not, see . {% endcomment %} {% load mathfilters %} {% load humanize %} {% load app \_filters %} {% if new_player or seen_message %} $('#modal-new-player').modal('show'); Welcome to YATA {{player.name}} ------------------------------------- I'm glad you're here and I hope you'll enjoy the features YATA provides. If you find a bug or enconter a weird behavior, if you have a question or a suggestion, please [join the discord server]({% url 'discord' %}). Kivou * * * ### Information All members of your faction will see: * your energy * your NNB All members with **AA perm*** will also see * your battle stats If you want to hide them you can go to the [members page]({% url 'faction:members' %}) to toggle it off. * * * * _AA perm means API Access permission. It's a TORN permission that leaders can give to their members._ Sounds good to me [Delete my account already]({% url 'delete' %}) {% endif %} ``` -------------------------------- ### jQuery UI Accordion Widget Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Initializes the accordion widget on an element with the ID 'accordion'. This creates a collapsible content panel. ```JavaScript $( "#accordion" ).accordion(); ``` -------------------------------- ### HTTP Server Options Source: https://github.com/kivou-2000607/yata/blob/master/requirements.txt Options for deploying Python web applications, including Gunicorn and uWSGI. ```Python # gunicorn==20.1.0 #uwsgi==2.0.20 ``` -------------------------------- ### jQuery UI Spinner Widget Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Initializes a spinner widget on an element with the ID 'spinner', allowing users to increment or decrement a value. ```JavaScript $( "#spinner" ).spinner(); ``` -------------------------------- ### Import Targets API Source: https://github.com/kivou-2000607/yata/blob/master/templates/api.html Imports or updates target information, including notes and colors. Requires an API key and a payload containing target IDs mapped to their respective data. Supports updating notes (up to 512 characters) and colors. ```APIDOC Import targets [POST] URL: /api/v1/importTargets Payload: Object { "key": String, // API key "targets": Object { Key: Object { "note": String (512 long), "color": Number }, // the keys are target id ... } } Example: { "key": "sOmThingrANdom", "targets": { "5": { "note": "Pretty strong", "color": 3 }, "1028023": { "note": "Pretty lame", "color": 1 } } } ``` -------------------------------- ### jQuery UI Progressbar Widget Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Initializes a progress bar widget on an element with the ID 'progressbar', visually indicating task completion. ```JavaScript $( "#progressbar" ).progressbar({ value: 20 }); ``` -------------------------------- ### Initialize Tablesorter and Tooltips Source: https://github.com/kivou-2000607/yata/blob/master/templates/faction/revives/index.html Initializes the tablesorter plugin for the faction-revives-report table with a default sort order and sets up Bootstrap tooltips for elements with the 'data-bs-toggle="tooltip"' attribute. ```JavaScript $(document).ready(function() { $("#faction-revives-report").tablesorter({sortList: [[1,1]]}); $("#date-start-revives").val(""); $("#date-end-revives").val(""); var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { return new bootstrap.Tooltip(tooltipTriggerEl, {html: true}); }); }); ``` -------------------------------- ### jQuery UI Tabs Widget Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Initializes the 'tabs' widget on an element with the ID 'tabs', creating a tabbed interface for content organization. ```JavaScript $( "#tabs" ).tabs(); ``` -------------------------------- ### jQuery UI Datepicker Widget Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Initializes an inline datepicker widget on an element with the ID 'datepicker', allowing users to select dates directly. ```JavaScript $( "#datepicker" ).datepicker({ inline: true }); ``` -------------------------------- ### Django Optimization and Serving Source: https://github.com/kivou-2000607/yata/blob/master/requirements.txt Packages for optimizing Django applications through HTML minification, Brotli compression, and static file serving with Whitenoise. ```Python django-htmlmin==0.11.0 django-brotli==0.2.0 whitenoise==5.3.0 ``` -------------------------------- ### jQuery UI Controlgroup and Radioset Widgets Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Initializes a 'buttonset' for radio buttons and a 'controlgroup' for grouped form elements, enhancing their appearance and behavior. ```JavaScript $( "#radioset" ).buttonset(); $( "#controlgroup" ).controlgroup(); ``` -------------------------------- ### Miscellaneous Utilities Source: https://github.com/kivou-2000607/yata/blob/master/requirements.txt A collection of utility libraries for making HTTP requests, managing environment variables, scheduling tasks, file type identification, password generation, and handling CORS headers. ```Python requests>=2.31.0 python-decouple==3.6 schedule==1.1.0 python-magic>=0.4.22 Pillow==10.3.0 xkcdpass==1.19.3 libmagic django-cors-headers==4.3.1 ``` -------------------------------- ### Django Caching and Rate Limiting Source: https://github.com/kivou-2000607/yata/blob/master/requirements.txt Libraries for implementing caching with Redis and rate limiting for Django applications. ```Python django-ratelimit==3.0.1 django-redis==5.2.0 django-redisboard==5.0.0 djangorestframework==3.15.2 ``` -------------------------------- ### Sentry Integration Source: https://github.com/kivou-2000607/yata/blob/master/requirements.txt The sentry-sdk package for integrating with Sentry for error tracking and performance monitoring. ```Python sentry-sdk==2.8.0 ``` -------------------------------- ### jQuery UI Dialog Widget with Buttons Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Configures a modal dialog box with 'open' and 'close' functionality. It includes custom buttons for user interaction. ```JavaScript $( "#dialog" ).dialog({ autoOpen: false, width: 400, buttons: [ { text: "Ok", click: function() { $( this ).dialog( "close" ); } }, { text: "Cancel", click: function() { $( this ).dialog( "close" ); } } ] }); // Link to open the dialog $( "#dialog-link" ).click(function( event ) { $( "#dialog" ).dialog( "open" ); event.preventDefault(); }); ``` -------------------------------- ### Pre-commit Hooks Source: https://github.com/kivou-2000607/yata/blob/master/requirements.txt The pre-commit package for managing and executing pre-commit hooks to automate code quality checks. ```Python pre-commit ``` -------------------------------- ### jQuery UI Slider Widget with Range Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Initializes a range slider widget on an element with the ID 'slider', allowing users to select a value range. ```JavaScript $( "#slider" ).slider({ range: true, values: [ 17, 67 ] }); ``` -------------------------------- ### jQuery UI Autocomplete Widget with Tags Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Implements an autocomplete input field using the 'autocomplete' widget. It uses a predefined array of tags for suggestions. ```JavaScript var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" ]; $( "#autocomplete" ).autocomplete({ source: availableTags }); ``` -------------------------------- ### Machine Learning Libraries Source: https://github.com/kivou-2000607/yata/blob/master/requirements.txt Libraries commonly used in machine learning workflows, including cloudpickle for serialization, XGBoost for gradient boosting, and scikit-learn for general ML algorithms. ```Python cloudpickle xgboost scikit-learn datasieve ``` -------------------------------- ### jQuery UI Accordion Widget Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Demonstrates the jQuery UI Accordion widget, allowing content to be collapsed and expanded. It requires jQuery and jQuery UI libraries. ```JavaScript $(function() { $("#accordion").accordion(); }); ``` -------------------------------- ### jQuery UI Hover States for Widgets Source: https://github.com/kivou-2000607/yata/blob/master/yata/static/thirdparty/jquery-ui-1.12.1/index.html Applies hover states to static widgets like dialog links and menu items, providing visual feedback on mouse interaction. ```JavaScript $( "#dialog-link, #icons li" ).hover( function() { $( this ).addClass( "ui-state-hover" ); }, function() { $( this ).removeClass( "ui-state-hover" ); } ); ``` -------------------------------- ### Django Core and Extensions Source: https://github.com/kivou-2000607/yata/blob/master/requirements.txt Core Django framework and related extensions for enhanced functionality, including JSON widget and bulk updates. ```Python Django==4.2.21 django-mathfilters==1.0.0 django-json-widget==1.1.1 django-extensions==3.1.5 django-bulk-update==2.2.0 ```