header.tmpl 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. {{with .Repository}}
  2. <div class="header-wrapper">
  3. <div class="ui container">
  4. <div class="ui vertically padded grid head">
  5. <div class="column">
  6. <div class="ui header">
  7. <div class="ui huge breadcrumb">
  8. <i class="mega-octicon octicon-{{if .IsPrivate}}lock{{else}}repo{{end}}"></i>
  9. <a href="{{AppSubURL}}/{{.Owner.Name}}">{{.Owner.Name}}</a>
  10. <div class="divider"> / </div>
  11. <a href="{{$.RepoLink}}">{{.Name}}</a>
  12. </div>
  13. {{if not $.IsGuest}}
  14. <div class="ui right">
  15. {{if and $.IsRepositoryAdmin $.IsRepositoryOwner}}
  16. <!-- CORE INNOVATION: IPFS + Blockchain Integration Button -->
  17. <button class="ui teal button" id="unified-ipfs-button">
  18. <i class="cloud upload icon"></i> Add to IPFS + Blockchain
  19. </button>
  20. {{end}}
  21. <!-- Standard repository actions -->
  22. <div class="ui labeled button">
  23. <button class="ui basic button">
  24. <i class="eye icon"></i> Watch
  25. </button>
  26. <a class="ui basic label">{{.NumWatches}}</a>
  27. </div>
  28. <div class="ui labeled button">
  29. <button class="ui basic button">
  30. <i class="star icon"></i> Star
  31. </button>
  32. <a class="ui basic label">{{.NumStars}}</a>
  33. </div>
  34. </div>
  35. {{end}}
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <!-- WEB3 INTEGRATION JAVASCRIPT -->
  42. <script>
  43. // INNOVATION: Multi-wallet Solana integration
  44. document.addEventListener('DOMContentLoaded', function() {
  45. const ipfsButton = document.getElementById('unified-ipfs-button');
  46. if (ipfsButton) {
  47. ipfsButton.addEventListener('click', handleIPFSUpload);
  48. }
  49. });
  50. async function handleIPFSUpload() {
  51. try {
  52. // STEP 1: Check for wallet connection
  53. if (!window.solana || !window.solana.isPhantom) {
  54. showWalletInstallPrompt();
  55. return;
  56. }
  57. // STEP 2: Connect wallet and check balance
  58. const wallet = await window.solana.connect();
  59. const hasBalance = await checkWalletBalance(wallet.publicKey.toString());
  60. if (!hasBalance) {
  61. showError('Insufficient balance. Need at least 0.01 SOL for transaction fees.');
  62. return;
  63. }
  64. // STEP 3: Upload to IPFS temporarily
  65. const ipfsHash = await uploadToIPFS();
  66. // STEP 4: Create blockchain transaction with IPFS hash
  67. const transaction = await createMemoTransaction(ipfsHash);
  68. // STEP 5: Request wallet signature
  69. const signature = await window.solana.signTransaction(transaction);
  70. // STEP 6: Permanent IPFS pinning after payment confirmation
  71. await permanentIPFSPin(ipfsHash, signature);
  72. // SUCCESS: Show professional success modal
  73. showSuccessModal(ipfsHash, signature);
  74. } catch (error) {
  75. if (error.message.includes('User rejected')) {
  76. showError('Transaction cancelled by user.');
  77. } else {
  78. showError('Upload failed: ' + error.message);
  79. }
  80. }
  81. }
  82. // INNOVATION: Progressive Web3 enhancement for Web2 users
  83. function showWalletInstallPrompt() {
  84. // Educational modal for traditional developers
  85. // Guides wallet installation without forcing it
  86. // ... implementation details protected ...
  87. }
  88. // BLOCKCHAIN INTEGRATION: Check wallet balance before operations
  89. async function checkWalletBalance(publicKey) {
  90. // Solana RPC call to verify sufficient balance
  91. // ... implementation details protected ...
  92. return true; // Simplified for demo
  93. }
  94. // IPFS INTEGRATION: Upload complete repository structure
  95. async function uploadToIPFS() {
  96. // POST to /repo/{owner}/{repo}/ipfs/temp_upload
  97. // Returns IPFS hash for blockchain transaction
  98. // ... implementation details protected ...
  99. return 'QmExampleHash'; // Simplified for demo
  100. }
  101. // MEMO TRANSACTION: Cost-efficient blockchain records
  102. async function createMemoTransaction(ipfsHash) {
  103. // Creates Solana memo transaction with repository data
  104. // Format: "GitBross Repository: {name} | IPFS: {hash} | Owner: {wallet}"
  105. // ... implementation details protected ...
  106. return {}; // Simplified for demo
  107. }
  108. // SECURITY: Permanent storage only after payment verification
  109. async function permanentIPFSPin(ipfsHash, signature) {
  110. // Verifies transaction on blockchain before permanent pinning
  111. // Prevents free storage abuse
  112. // ... implementation details protected ...
  113. }
  114. // UX INNOVATION: Professional cross-browser success modal
  115. function showSuccessModal(ipfsHash, signature) {
  116. // Professional modal with selectable text and copy buttons
  117. // Works across all browsers (Chrome, Firefox, Safari, Brave)
  118. // Clickable links to IPFS gateway and Solana Explorer
  119. // ... implementation details protected ...
  120. }
  121. </script>
  122. <!--
  123. FRONTEND INNOVATION SUMMARY:
  124. ===========================
  125. 1. PROGRESSIVE WEB3 ENHANCEMENT:
  126. - Web2 users see standard Git interface
  127. - "Add to IPFS + Blockchain" button appears for owners
  128. - Educational prompts guide wallet installation
  129. - No forced crypto onboarding
  130. 2. MULTI-WALLET SUPPORT:
  131. - Phantom (primary), Solflare, Backpack integration
  132. - Automatic wallet detection and connection
  133. - Fallback guidance for wallet installation
  134. 3. TRANSACTION-FIRST SECURITY:
  135. - Balance verification before any operations
  136. - Temporary IPFS upload, permanent only after payment
  137. - Clear error handling for cancelled transactions
  138. 4. PROFESSIONAL UX:
  139. - Cross-browser compatible success modals
  140. - Selectable text and copy buttons
  141. - Educational tooltips for Web3 concepts
  142. - Familiar Git workflow with Web3 benefits
  143. This creates the bridge between traditional Git workflows and
  144. decentralized Web3 benefits, enabling mass adoption.
  145. Full working implementation: https://gitbross.com
  146. -->
  147. {{end}}