Skip to content

Commit

Permalink
added webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
SlashGordon committed Nov 21, 2023
1 parent 253b4e5 commit 27d6982
Show file tree
Hide file tree
Showing 165 changed files with 15,364 additions and 11 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,19 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Set up Python
uses: actions/setup-python@v4
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,8 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
output/
node_modules/
package-lock.json
themes/stocks/static/stylesheet/styles.css
themes/stocks/static/js/bundle.js
.DS_Store
1 change: 1 addition & 0 deletions content/about.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Title: About Us
Date: 2023-11-20
Author: Slash

# About Our Website

Expand Down
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "techstocksinsight.github.io",
"version": "1.0.0",
"description": "Welcome to the cool side of finance — where charts tell stories and success is just a click away!",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack serve --mode development --open",
"build": "webpack --mode production && mkdir -p themes/stocks/static/js && cp dist/bundle.js themes/stocks/static/js/bundle.js && cp dist/styles.css themes/stocks/static/stylesheet/styles.css"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.23.3",
"@babel/preset-env": "^7.23.3",
"babel-loader": "^9.1.3",
"css-loader": "^6.8.1",
"html-webpack-plugin": "^5.5.3",
"mini-css-extract-plugin": "^2.7.6",
"node-sass": "^9.0.0",
"sass-loader": "^13.3.2",
"style-loader": "^3.3.3",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
},
"dependencies": {
"bootstrap": "^5.3.2",
"highcharts": "^11.2.0",
"jquery": "^3.7.1"
}
}
9 changes: 6 additions & 3 deletions pelicanconf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AUTHOR = 'SlashGordon'
SITENAME = 'portfolioplus'
SITEURL = ""
SITEURL = 'https://portfolioplus.github.io'

PATH = "content"

Expand Down Expand Up @@ -29,9 +29,12 @@
("Another social link", "#"),
)
from mysiteplugins import stocks
import os

PLUGINS = [stocks]
PLUGINS = [stocks, "pelican.plugins.webassets"]
DEFAULT_PAGINATION = 10

STATIC_PATHS = ["dist"]
THEME ="themes/stocks"
# Uncomment following line if you want document-relative URLs when developing
# RELATIVE_URLS = True
RELATIVE_URLS = os.environ.get("DEBUG", "0") == "1"
139 changes: 138 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ python = "^3.11"
pelican = {extras = ["markdown"], version = "^4.9.1"}
pytickersymbols = "^1.15.0"
pyyaml = "^6.0.1"
pelican-search = "^1.1.0"
pelican-neighbors = "^1.2.0"
pelican-readtime = "^0.2.0"
pelican-webassets = "^2.0.0"


[build-system]
Expand Down
27 changes: 27 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- src/index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My NPM Project</title>
</head>
<body>
<h1>Hello, NPM Project!</h1>

<div id="chartContainer" style="height: 300px;"></div>

<script>
document.addEventListener('DOMContentLoaded', function() {
highcharts.chart('chartContainer', {
title: {
text: 'My Chart'
},
series: [{
data: [1, 3, 2, 4]
}]
});
});
</script>
</body>
</html>
30 changes: 30 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// src/index.js
import 'bootstrap';
import 'bootstrap/dist/css/bootstrap.min.css';
import highcharts from 'highcharts';

import Highcharts from 'highcharts';

console.log('Hello from index.js!');

// Dynamic chart logic
function createDynamicChart() {
// Get chart container and attributes
const chartContainer = document.getElementById('chartContainer');
const title = chartContainer.getAttribute('data-chart-title') || 'Dynamic Chart';
const dataAttribute = chartContainer.getAttribute('data-chart-data');
const chartData = dataAttribute ? JSON.parse(dataAttribute) : [5, 2, 8, 1];

// Create Highcharts chart
Highcharts.chart(chartContainer, {
title: {
text: title
},
series: [{
data: chartData
}]
});
}

// Trigger the dynamic chart creation
createDynamicChart();
36 changes: 31 additions & 5 deletions src/mysiteplugins/stocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from pelican.contents import Article
from pelican.readers import BaseReader
from pytickersymbols import PyTickerSymbols
import random

ts = PyTickerSymbols()

def stock_url(index: str, name: str):
name_url = name.lower().replace(" ", "-").replace(".", "")
index_url = index.lower().replace(" ", "-").replace(".", "")
return f"{index_url}-{name_url}.html"
name_url = name.lower().replace(" ", "-").replace(".", "").replace(",", "")
index_url = index.lower().replace(" ", "-").replace(".", "").replace(",", "")
return f"{index_url}/{name_url}.html"

def addIndices(articleGenerator):
settings = articleGenerator.settings
Expand All @@ -31,6 +32,26 @@ def addIndices(articleGenerator):

articleGenerator.articles.insert(0, newArticle)

def create_html_table(data):
# Create HTML table
html_table = '<table border="1">\n'

# Add table headers
html_table += '<tr><th>Attribute</th><th>Value</th></tr>\n'

# Add table rows with data
for key, value in data.items():
if isinstance(value, list):
value = ', '.join(map(str, value))
elif isinstance(value, dict):
value = ', '.join([f"{k}: {v}" for k, v in value.items()])
html_table += f'<tr><td>{key}</td><td>{value}</td></tr>\n'

# Close HTML table
html_table += '</table>'

return html_table


def addStocks(articleGenerator):
settings = articleGenerator.settings
Expand All @@ -40,10 +61,15 @@ def addStocks(articleGenerator):
stocks_of_index = ts.get_stocks_by_index(index)
content = ""
for stock in stocks_of_index:
content = f"{stock}"
content = create_html_table(stock)

rand_data = [random.random() for _ in range(100)]
name = stock["name"]
content += f'<div id="chartContainer" data-chart-title="My Chart {name}" data-chart-data="{rand_data}" style="height: 300px;"></div>'
newArticle = Article(content, {
"title": f"{index} {stock['name']}",
#"override_url": stock_url(index, stock['name']),
"url": stock_url(index, stock['name']),
"save_as": stock_url(index, stock['name']),
"date": datetime.datetime.now(),
"category": baseReader.process_metadata("category", "stocks"),
"tags": baseReader.process_metadata("tags", f"{index}")
Expand Down
Loading

0 comments on commit 27d6982

Please sign in to comment.