...
This commit is contained in:
		
							
								
								
									
										17
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
__pycache__
 | 
			
		||||
*.pyc
 | 
			
		||||
.venv
 | 
			
		||||
.vscode
 | 
			
		||||
index/
 | 
			
		||||
prompts2/
 | 
			
		||||
python3.12/
 | 
			
		||||
python3.13/
 | 
			
		||||
site-packages/
 | 
			
		||||
include/
 | 
			
		||||
bin/
 | 
			
		||||
state/
 | 
			
		||||
node_modules/
 | 
			
		||||
.mypy_cache
 | 
			
		||||
target/
 | 
			
		||||
lib/investorstool/parsers/input
 | 
			
		||||
docs/
 | 
			
		||||
							
								
								
									
										19
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								README.md
									
									
									
									
									
								
							@@ -1,3 +1,20 @@
 | 
			
		||||
# www_threefold4
 | 
			
		||||
 | 
			
		||||
new version of threefold, minimalistic
 | 
			
		||||
new version of threefold, minimalistic
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## to debug / develop
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
hero git clone -u git@git.ourworld.tf:tfgrid/www_threefold4.git
 | 
			
		||||
cd ~/code/git.ourworld.tf/tfgrid/www_threefold4
 | 
			
		||||
source myenv.sh
 | 
			
		||||
# to test an example
 | 
			
		||||
cd poc
 | 
			
		||||
python server.py
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## to add package to pip
 | 
			
		||||
 | 
			
		||||
add it to https://git.ourworld.tf/projectmycelium/hero_server/src/branch/main/requirements.txt
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										24
									
								
								install.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										24
									
								
								install.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
set -ex
 | 
			
		||||
BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
 | 
			
		||||
source ${BASE_DIR}/myenv.sh
 | 
			
		||||
cd $BASE_DIR
 | 
			
		||||
 | 
			
		||||
python3 -m pip install -r "$BASE_DIR/requirements.txt" 
 | 
			
		||||
 | 
			
		||||
# pip freeze > requirements.txt
 | 
			
		||||
 | 
			
		||||
#to make sure we have the paths towards hero in our library
 | 
			
		||||
 | 
			
		||||
PYTHON_VERSION=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
 | 
			
		||||
echo "$BASE_DIR/lib" > "${VENV_DIR}/lib/python${PYTHON_VERSION}/site-packages/herolib.pth"
 | 
			
		||||
 | 
			
		||||
#for osx    
 | 
			
		||||
# pip3 install psycopg2-binary
 | 
			
		||||
# psycopg2
 | 
			
		||||
 | 
			
		||||
echo "OK"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
python3 -m pip install -r "requirements.txt" 
 | 
			
		||||
pip install --upgrade pip
 | 
			
		||||
							
								
								
									
										27
									
								
								myenv.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										27
									
								
								myenv.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
 | 
			
		||||
    # Script is being sourced
 | 
			
		||||
    export BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 | 
			
		||||
else
 | 
			
		||||
    # Script is being executed
 | 
			
		||||
    export BASE_DIR="$( cd "$( dirname "${0}" )" && pwd )"
 | 
			
		||||
fi
 | 
			
		||||
export VENV_DIR="${BASE_DIR}/.venv"
 | 
			
		||||
 | 
			
		||||
python3 -m venv "$VENV_DIR"
 | 
			
		||||
source $VENV_DIR/bin/activate
 | 
			
		||||
 | 
			
		||||
# Check if the directory exists
 | 
			
		||||
if [ ! -d "$VENV_DIR" ]; then
 | 
			
		||||
    echo "Directory $VENV_DIR does not exist. Creating it and setting up a virtual environment."
 | 
			
		||||
    # The -p flag makes mkdir create any necessary parent directories as well
 | 
			
		||||
    mkdir -p "$VENV_DIR"
 | 
			
		||||
    # Create the virtual environment
 | 
			
		||||
    python3 -m venv "$VENV_DIR"
 | 
			
		||||
    python3 -m pip install --upgrade pip
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
export CONTEXTROOT='~/context'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
echo "We're good to go"
 | 
			
		||||
@@ -7,7 +7,9 @@ import os
 | 
			
		||||
import markdown
 | 
			
		||||
import re
 | 
			
		||||
 | 
			
		||||
sources_dir = "/Users/despiegk1/code/git.ourworld.tf/freeflowuniverse/heroweb/research/dancing_banner/"
 | 
			
		||||
sources_dir = os.path.expanduser("~/code/git.ourworld.tf/tfgrid/www_threefold4/poc")
 | 
			
		||||
if not os.path.exists(sources_dir):
 | 
			
		||||
    raise RuntimeError(f"The source directory '{sources_dir}' does not exist.")
 | 
			
		||||
static_dir = f"{sources_dir}/static"
 | 
			
		||||
content_dir = f"{sources_dir}/content"
 | 
			
		||||
 | 
			
		||||
@@ -15,20 +17,20 @@ def get_content(name: str) -> str:
 | 
			
		||||
    """Get content by name from either HTML or markdown files in content directory"""
 | 
			
		||||
    # Remove any leading/trailing slashes
 | 
			
		||||
    name = name.strip('/')
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # Check for file with .html extension
 | 
			
		||||
    html_path = os.path.join(content_dir, f"{name}.html")
 | 
			
		||||
    if os.path.exists(html_path):
 | 
			
		||||
        with open(html_path, 'r') as f:
 | 
			
		||||
            return f.read()
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
    # Check for file with .md extension
 | 
			
		||||
    md_path = os.path.join(content_dir, f"{name}.md")
 | 
			
		||||
    if os.path.exists(md_path):
 | 
			
		||||
        with open(md_path, 'r') as f:
 | 
			
		||||
            content = f.read()
 | 
			
		||||
            return markdown.markdown(content)
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
    return f"[[{name} not found]]"
 | 
			
		||||
 | 
			
		||||
def process_content(content: str) -> str:
 | 
			
		||||
@@ -36,7 +38,7 @@ def process_content(content: str) -> str:
 | 
			
		||||
    def replace_content(match):
 | 
			
		||||
        name = match.group(1)
 | 
			
		||||
        return get_content(name)
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # Replace all [[name]] patterns
 | 
			
		||||
    return re.sub(r'\[\[(.*?)\]\]', replace_content, content)
 | 
			
		||||
 | 
			
		||||
@@ -69,7 +71,7 @@ async def favicon():
 | 
			
		||||
    raise HTTPException(status_code=404, detail="Favicon not found")
 | 
			
		||||
 | 
			
		||||
@app.get("/", response_class=HTMLResponse)
 | 
			
		||||
async def read_index(request: Request):    
 | 
			
		||||
async def read_index(request: Request):
 | 
			
		||||
    template = env.get_template("index.html")
 | 
			
		||||
    content = template.render(request=request)
 | 
			
		||||
    return process_content(content)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								requirements.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								requirements.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
IPython
 | 
			
		||||
colorama
 | 
			
		||||
colorlog
 | 
			
		||||
flet
 | 
			
		||||
inflect
 | 
			
		||||
jinja2
 | 
			
		||||
markdown-it-py
 | 
			
		||||
mdformat
 | 
			
		||||
mypy>=1.9.0
 | 
			
		||||
openai
 | 
			
		||||
psutil
 | 
			
		||||
pudb
 | 
			
		||||
pydantic>=2.7.1
 | 
			
		||||
pylance>=0.10.12
 | 
			
		||||
python-Levenshtein
 | 
			
		||||
pywalletconnect
 | 
			
		||||
pyyaml
 | 
			
		||||
qrcode
 | 
			
		||||
redis>=5.0.3
 | 
			
		||||
requests>=2.32
 | 
			
		||||
toml
 | 
			
		||||
urllib3
 | 
			
		||||
uvicorn
 | 
			
		||||
pillow
 | 
			
		||||
pymupdf
 | 
			
		||||
markdown
 | 
			
		||||
		Reference in New Issue
	
	Block a user