Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • meskio/cicer
  • quique/cicer
2 results
Show changes
Commits on Source (222)
Showing
with 1122 additions and 0 deletions
/.git
/node_modules
/.pnp
.pnp.js
/build
/cicer
/test.db
......@@ -23,3 +23,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# cordova-res
/resources/android
{}
FROM golang as go_build
WORKDIR /src/
COPY main.go go.* /src/
COPY api /src/api
RUN CGO_ENABLED=1 go build -o cicer
FROM node as js_build
WORKDIR /src/
COPY *.json /src/
COPY src /src/src
COPY public /src/public
RUN npm install && npm run build
FROM debian
ENV ASSETS_PATH="/assets"
ENV DB_PATH="/data/cicer.db"
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y ca-certificates
COPY --from=go_build /src/cicer /cicer
COPY --from=js_build /src/build /assets
VOLUME /data
ENTRYPOINT ["/cicer"]
This diff is collapsed.
.PHONY: build test apk
build:
go build
npm install
npm run build
test:
go test ./...
npm test
apk: resources/android
REACT_APP_API="https://cicer.garbanzonegro.org" REACT_APP_NATIVE="true" npm run build
npx cap sync android
npx cap copy android
cd android && ./gradlew assembleRelease
resources/android: resources/icon.png resources/splash.png
npx capacitor-assets generate
# Cicer
Cicer is a web based software to manage the stock, purchases and balance of a consumer association. It has being created for the needs of the [Garbanzo Negro](http://garbanzonegro.org).
## Requirements
- Golang >= 1.12
- Node.js
## Deployment
Build a copy using make:
```shell
make build
```
Create a secret for the authentication tokens:
```shell
head -c 21 < /dev/urandom | base64
```
Now you can copy the build folder and the cicer binary to your server and run it like:
```shell
./cicer -assets 'path/to/build' -secret 'scret' -addr ':8000'
```
Instead of flags all the params can be passed as env variables. See the names between `{` and `}` in:
```shell
./cicer -h
```
### nginx configuration
The android app requires CORS to be configured in the server:
```
location / {
if ($request_method ~ ^(OPTIONS)$ ) {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers x-authentication;
return 200;
}
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers x-authentication always;
proxy_pass http://localhost:8000;
}
```
## Running it for development
To run Cicer in development mode, build and run the backend:
```shell
go build
./cicer
```
And then run the frontend with npm:
```shell
npm start
```
The backend API will be listening on port 8080, while the frontend will be on port 3000.
Open a browser and visit `http://localhost:3000`. You will be able to see any changes you do in the javascript side as you go (the backend side needs recompilation).
## Initialize data
When you run cicer, it will print an authentication token.
Use this token to seed some initial data (such a few users and products):
```shell
./setup.sh the.token.string
```
## Android
You can use sdkmanager:
```
sudo apt install sdkmanager
export ANDROID_HOME="$HOME/Android"
sdkmanager --install "platforms;android-33"
sdkmanager --install "build-tools;30.0.3"
sdkmanager --licenses
```
With it you can build the apk from command line:
```
export JAVA_HOME="$HOME/Android/android-studio/jbr"
make apk
```
The built apk will be in `android/app/build/outputs/apk/release/app-release-unsigned.apk`.
Or open android studio to test and build the app:
```
make build
npx cap copy
npx cap open android
```
### sign the apk
To sign the apk you need to have a key generated with:
```
keytool -genkey -v -keystore release.keystore -alias release -keyalg RSA -keysize 2048 -validity 10000
```
And then sign it:
```
apksigner sign --ks ~/release.keystore --out app.apk app-release-unsigned.apk
```
# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore
# Built application files
*.apk
*.aar
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/
# Google Services (e.g. APIs or Firebase)
# google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
# Android Profiling
*.hprof
# Cordova plugins for Capacitor
capacitor-cordova-android-plugins
# Copied web assets
app/src/main/assets/public
# Generated Config files
app/src/main/assets/capacitor.config.json
app/src/main/assets/capacitor.plugins.json
app/src/main/res/xml/config.xml
/build/*
!/build/.npmkeep
apply plugin: 'com.android.application'
android {
namespace "org.garbanzonegro.cicer"
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "org.garbanzonegro.cicer"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 11
versionName "2.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
flatDir{
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')
}
apply from: 'capacitor.build.gradle'
try {
def servicesJSON = file('google-services.json')
if (servicesJSON.text) {
apply plugin: 'com.google.gms.google-services'
}
} catch(Exception e) {
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
implementation project(':capacitor-preferences')
}
if (hasProperty('postBuildExtras')) {
postBuildExtras()
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.getcapacitor.myapp;
import static org.junit.Assert.*;
import android.content.Context;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.getcapacitor.app", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
</application>
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
{
"appId": "org.garbanzonegro.cicer",
"appName": "Garbanzo Negro",
"webDir": "build",
"server": {
"androidScheme": "https"
}
}
package org.garbanzonegro.cicer;
import com.getcapacitor.BridgeActivity;
public class MainActivity extends BridgeActivity {}
android/app/src/main/res/drawable-land-hdpi/splash.png

117 KiB

android/app/src/main/res/drawable-land-ldpi/splash.png

36 KiB

android/app/src/main/res/drawable-land-mdpi/splash.png

61.5 KiB

android/app/src/main/res/drawable-land-night-hdpi/splash.png

11.9 KiB